function canUpdateItem() { $entities = Profile_User::getUserEntities($this->fields['id'], true); if (isViewAllEntities() || haveAccessToOneOfEntities($entities)) { return true; } return false; }
/** * Show rights of a user * * @param $user User object **/ static function showForUser(User $user) { global $DB, $CFG_GLPI, $LANG; $ID = $user->getField('id'); if (!$user->can($ID, 'r')) { return false; } $canedit = $user->can($ID, 'w'); $strict_entities = self::getUserEntities($ID, false); if (!haveAccessToOneOfEntities($strict_entities) && !isViewAllEntities()) { $canedit = false; } $canshowentity = haveRight("entity", "r"); $rand = mt_rand(); echo "<form name='entityuser_form{$rand}' id='entityuser_form{$rand}' method='post' action='"; echo getItemTypeFormURL(__CLASS__) . "'>"; if ($canedit) { echo "<div class='firstbloc'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['setup'][605] . "</tr>"; echo "<tr class='tab_bg_2'><td class='center'>"; echo "<input type='hidden' name='users_id' value='{$ID}'>"; Dropdown::show('Entity', array('entity' => $_SESSION['glpiactiveentities'])); echo "</td><td class='center'>" . $LANG['profiles'][22] . " : "; Profile::dropdownUnder(array('value' => Profile::getDefault())); echo "</td><td class='center'>" . $LANG['profiles'][28] . " : "; Dropdown::showYesNo("is_recursive", 0); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>"; echo "</td></tr>"; echo "</table></div>"; } echo "<div class='spaced'><table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='2'>" . $LANG['Menu'][37] . "</th>"; echo "<th>" . $LANG['profiles'][22] . " (D=" . $LANG['profiles'][29] . ", R=" . $LANG['profiles'][28] . ")"; echo "</th></tr>"; $query = "SELECT DISTINCT `glpi_profiles_users`.`id` AS linkID,\n `glpi_profiles`.`id`,\n `glpi_profiles`.`name`,\n `glpi_profiles_users`.`is_recursive`,\n `glpi_profiles_users`.`is_dynamic`,\n `glpi_entities`.`completename`,\n `glpi_profiles_users`.`entities_id`\n FROM `glpi_profiles_users`\n LEFT JOIN `glpi_profiles`\n ON (`glpi_profiles_users`.`profiles_id` = `glpi_profiles`.`id`)\n LEFT JOIN `glpi_entities`\n ON (`glpi_profiles_users`.`entities_id` = `glpi_entities`.`id`)\n WHERE `glpi_profiles_users`.`users_id` = '{$ID}'\n ORDER BY `glpi_profiles`.`name`, `glpi_entities`.`completename`"; $result = $DB->query($query); if ($DB->numrows($result) > 0) { while ($data = $DB->fetch_array($result)) { echo "<tr class='tab_bg_1'>"; echo "<td width='10'>"; if ($canedit && in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) { echo "<input type='checkbox' name='item[" . $data["linkID"] . "]' value='1'>"; } else { echo " "; } echo "</td>"; if ($data["entities_id"] == 0) { $data["completename"] = $LANG['entity'][2]; } echo "<td>"; if ($canshowentity) { echo "<a href='" . getItemTypeFormURL('Entity') . "?id=" . $data["entities_id"] . "'>"; } echo $data["completename"] . ($_SESSION["glpiis_ids_visible"] ? " (" . $data["entities_id"] . ")" : ""); if ($canshowentity) { echo "</a>"; } echo "</td>"; echo "<td>" . $data["name"]; if ($data["is_dynamic"] || $data["is_recursive"]) { echo "<strong> ("; if ($data["is_dynamic"]) { echo "D"; } if ($data["is_dynamic"] && $data["is_recursive"]) { echo ", "; } if ($data["is_recursive"]) { echo "R"; } echo ")</strong>"; } echo "</td>"; } echo "</tr>"; } echo "</table>"; if ($canedit) { openArrowMassive("entityuser_form{$rand}", true); closeArrowMassive('delete', $LANG['buttons'][6]); } echo "</form></div>"; }