getEntitiesForUser() 정적인 공개 메소드

retrieve the entities associated to a user
static public getEntitiesForUser ( $users_id, $child = false ) : Array
$users_id Integer ID of the user
$child Boolean when true, include child entity when recursive right (false by default)
리턴 Array of entity ID
예제 #1
0
파일: link.class.php 프로젝트: Ixertec/glpi
 /**
  * Show Links for an item
  *
  * @param $item                     CommonDBTM object
  * @param $withtemplate    integer  withtemplate param (default '')
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     if (!self::canView()) {
         return false;
     }
     if ($item->isNewID($item->getID())) {
         return false;
     }
     $restrict = $item->getEntityID();
     if ($item->getType() == 'User') {
         $restrict = Profile_User::getEntitiesForUser($item->getID());
     }
     $query = "SELECT `glpi_links`.`id`,\n                       `glpi_links`.`link` AS link,\n                       `glpi_links`.`name` AS name ,\n                       `glpi_links`.`data` AS data,\n                       `glpi_links`.`open_window` AS open_window\n                FROM `glpi_links`\n                INNER JOIN `glpi_links_itemtypes`\n                     ON `glpi_links`.`id` = `glpi_links_itemtypes`.`links_id`\n                WHERE `glpi_links_itemtypes`.`itemtype`='" . $item->getType() . "' " . getEntitiesRestrictRequest(" AND", "glpi_links", "entities_id", $restrict, true) . "\n                ORDER BY name";
     $result = $DB->query($query);
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     if ($DB->numrows($result) > 0) {
         echo "<tr><th>" . self::getTypeName(Session::getPluralNumber()) . "</th></tr>";
         while ($data = $DB->fetch_assoc($result)) {
             $links = self::getAllLinksFor($item, $data);
             foreach ($links as $link) {
                 echo "<tr class='tab_bg_2'>";
                 echo "<td class='center'>{$link}</td></tr>";
             }
         }
         echo "</table></div>";
     } else {
         echo "<tr class='tab_bg_2'><th>" . self::getTypeName(Session::getPluralNumber()) . "</th></tr>";
         echo "<tr class='tab_bg_2'><td class='center b'>" . __('No link defined') . "</td></tr>";
         echo "</table></div>";
     }
 }