getUserEntitiesForRight() static public method

Get entities for which a user have a right
static public getUserEntitiesForRight ( $user_ID, $right, $is_recursive = true ) : array
$user_ID integer user ID
$right right to check
$is_recursive check also using recursive rights (true by default)
return array of entities ID
コード例 #1
0
ファイル: planning.php プロジェクト: jose-martins/glpi
         $ismine = true;
     } else {
         $entities = Profile_User::getUserEntitiesForRight($user->getID(), Planning::READGROUP);
         $groups = Group_User::getUserGroups($user->getID());
         foreach ($groups as $group) {
             if ($_GET["gID"] == $group['id'] && in_array($group['entities_id'], $entities)) {
                 $ismine = true;
             }
         }
     }
 }
 $canview = false;
 // If not mine check global right
 if (!$ismine) {
     // First check user
     $entities = Profile_User::getUserEntitiesForRight($user->getID(), Planning::READALL);
     if ($_GET["uID"]) {
         $userentities = Profile_User::getUserEntities($user->getID());
         $intersect = array_intersect($entities, $userentities);
         if (count($intersect)) {
             $canview = true;
         }
     }
     // Else check group
     if (!$canview && $_GET['gID']) {
         $group = new Group();
         if ($group->getFromDB($_GET['gID'])) {
             if (in_array($group->getEntityID(), $entities)) {
                 $canview = true;
             }
         }
コード例 #2
0
ファイル: planning.php プロジェクト: gaforeror/glpi
         $ismine = true;
     } else {
         $entities = Profile_User::getUserEntitiesForRight($user->getID(), 'show_group_planning');
         $groups = Group_User::getUserGroups($user->getID());
         foreach ($groups as $group) {
             if ($_GET["gID"] == $group['id'] && in_array($group['entities_id'], $entities)) {
                 $ismine = true;
             }
         }
     }
 }
 $canview = false;
 // If not mine check global right
 if (!$ismine) {
     // First check user
     $entities = Profile_User::getUserEntitiesForRight($user->getID(), 'show_all_planning');
     if ($_GET["uID"]) {
         $userentities = Profile_User::getUserEntities($user->getID());
         $intersect = array_intersect($entities, $userentities);
         if (count($intersect)) {
             $canview = true;
         }
     }
     // Else check group
     if (!$canview && $_GET['gID']) {
         $group = new Group();
         if ($group->getFromDB($_GET['gID'])) {
             if (in_array($group->getEntityID(), $entities)) {
                 $canview = true;
             }
         }