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

Source for file edit_gallery_perms.php

Documentation is available at edit_gallery_perms.php

  1. <?php
  2. /**
  3.  * @version $Header$
  4.  * @package fisheye
  5.  * @subpackage functions
  6.  */
  7.  
  8. /**
  9.  * required setup
  10.  */
  11. require_once( '../kernel/setup_inc.php' );
  12.  
  13. require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
  14. require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
  15.  
  16. global $gBitSystem, $fisheyePermNameMap;
  17.  
  18. // Make sure an gallery has been specified
  19. if (empty($_REQUEST['gallery_id'])) {
  20.     $gBitSmarty->assign('msg', tra("No gallery specified"));
  21.     $gBitSystem->display( "error.tpl" , NULL, array( 'display_mode' => 'edit' ));
  22.     die;
  23. }
  24.  
  25. include_once( FISHEYE_PKG_PATH.'gallery_lookup_inc.php' );
  26.  
  27. if (empty($gContent->mContentId)) {
  28.     $gBitSmarty->assign( 'msg', tra( "The specified gallery does not exist" ));
  29.     $gBitSystem->display("error.tpl", NULL, array( 'display_mode' => 'edit' ));
  30.     die;
  31. } elseif ($gContent->mInfo['user_id'] != $gBitUser->mUserId && $gContent->mInfo['perm_level'] < FISHEYE_PERM_ADMIN) {
  32.     // This user does not own this gallery and they have not been granted the permission to edit user permissions for this gallery
  33.     $gBitSmarty->assign( 'msg', tra( "You cannot edit this image gallery" ) );
  34.     $gBitSystem->display( "error.tpl" , NULL, array( 'display_mode' => 'edit' ));
  35.     die;
  36. }
  37.  
  38. if (!empty($_REQUEST['submitNewPermissions'])) {
  39.     $gContent->grantUserPermissions($_REQUEST['new_perm_user_id'], $_REQUEST['new_perm_level']);
  40.     $fisheyeSuccess[] = $_REQUEST['found_username']." given ".$fisheyePermNameMap[$_REQUEST['name_perm_level']]." permissions";
  41. }elseif (!empty($_REQUEST['remove_perm_user_id'])) {
  42.     $gContent->revokeUserPermission($_REQUEST['remove_perm_user_id']);
  43.     $fisheyeSuccess[] = tra("User permissions successfully revoked");
  44. }
  45.  
  46. $userPerms = $gContent->loadPermissions();
  47. $gBitSmarty->assign_by_ref('userPerms', $gContent->mPerms);
  48.  
  49. if (!empty($_REQUEST['submitUpdatePerms'])) {
  50.     $existingPerms = $_REQUEST['existingPerms'];
  51.     foreach ($userPerms as $userPerm) {
  52.         if ($existingPerms[$userPerm['user_id']]['perm_level'] != $userPerm['perm_level']) {
  53.             // Permisson level for this user has been altered
  54.             $gContent->grantUserPermissions($userPerm['user_id'], $existingPerms[$userPerm['user_id']]);
  55.             $fisheyeSuccess[] = $userPerm['real_name']." given ".$fisheyePermNameMap[$existingPerms[$userPerm['user_id']]]." permissions.";
  56.         }
  57.     }
  58.     $userPerms = $gContent->getAllUserPermissions();
  59. }
  60.  
  61. $gBitSystem->display('bitpackage:fisheye/edit_gallery_perms.tpl', NULL, array( 'display_mode' => 'edit' ));
  62.  
  63. ?>

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