users
[ class tree: users ] [ index: users ] [ all elements ]

Source for file bookmark.php

Documentation is available at bookmark.php

  1. <?php
  2. /**
  3.  * A universal helper to bookmark any content object for a user
  4.  * Currently only accessible through ajax/json
  5.  * Those wishing for a non-js implementation feel free to modify
  6.  *
  7.  * @package users
  8.  */
  9.  
  10. /**
  11.  * required setup
  12.  */
  13. require_once'../kernel/setup_inc.php' );
  14.  
  15. $statusCode 205;
  16. $error TRUE;
  17. $msg "";
  18.  
  19. if$gBitUser->isRegistered() ){
  20.     if!empty$_REQUEST['content_id'&& $gContent LibertyBase::getLibertyObject$_REQUEST['content_id') ) {
  21.         // verify user has access to view this content
  22.         $gContent->load();
  23.         if$gContent->hasViewPermission() ){
  24.             if$gContent->hasServiceCONTENT_SERVICE_USERS_FAVS ) ){
  25.                 // default action is to add the favorite
  26.                 $_REQUEST['action'empty$_REQUEST['action')?'add':$_REQUEST['action']
  27.                 // add or remove 
  28.                 switch$_REQUEST['action'){
  29.                     case 'add':
  30.                         $gBitUser->storeFavorite$_REQUEST['content_id');
  31.                         $bookmarkState 1;
  32.                         $msg tra'This content has been added to your favorites' );
  33.                         break;
  34.                     case 'remove':
  35.                         $gBitUser->expungeFavorite$_REQUEST['content_id');
  36.                         $bookmarkState 0;
  37.                         $msg tra'This content has been removed from your favorites' );
  38.                         break;
  39.                 }
  40.                 $gBitSmarty->assign'bookmarkState'$bookmarkState );
  41.                 $gBitSmarty->assign'contentId'$_REQUEST['content_id');
  42.                 $error FALSE;
  43.             }else{
  44.                 $statusCode 401;
  45.                 $msg tra'You can not bookmark this type of content, bookmarking denied' );
  46.             }
  47.         }else{
  48.             $statusCode 401;
  49.             $msg tra'You do not have permission to view this content, bookmarking denied' );
  50.         }
  51.     }else{
  52.         $statusCode 400;
  53.         $msg tra'No content was specified to bookmark' );
  54.     }
  55. }else{
  56.     $msg tra'You must be a registered user to bookmark content' );
  57. }
  58.  
  59. $gBitSmarty->assign'statusCode'$statusCode );
  60. $gBitSmarty->assign'error'$error );
  61. $gBitSmarty->assign'msg'$msg );
  62. $gBitThemes->setFormatHeader'json' );
  63. $gBitSystem->display('bitpackage:users/edit_user_fav_json.tpl'nullarray'format' => 'center_only''display_mode' => 'edit' ));

Documentation generated on Wed, 29 Jul 2015 13:56:12 +0000 by phpDocumentor 1.5.0-lsces