grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026. -------------------------------------------------------------------------- */ /** @file * @brief */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } /** * Group_User Class * * Relation between Group and User **/ class Group_User extends CommonDBRelation{ // From CommonDBRelation static $itemtype_1 = 'User'; static $items_id_1 = 'users_id'; static $itemtype_2 = 'Group'; static $items_id_2 = 'groups_id'; /** * @param $users_id * @param $condition (default '') **/ static function getUserGroups($users_id, $condition='') { global $DB; $groups = array(); $query = "SELECT `glpi_groups`.*, `glpi_groups_users`.`id` AS IDD, `glpi_groups_users`.`id` AS linkID, `glpi_groups_users`.`is_dynamic` AS is_dynamic, `glpi_groups_users`.`is_manager` AS is_manager, `glpi_groups_users`.`is_userdelegate` AS is_userdelegate FROM `glpi_groups_users` LEFT JOIN `glpi_groups` ON (`glpi_groups`.`id` = `glpi_groups_users`.`groups_id`) WHERE `glpi_groups_users`.`users_id` = '$users_id' "; if (!empty($condition)) { $query .= " AND $condition "; } $query.=" ORDER BY `glpi_groups`.`name`"; foreach ($DB->request($query) as $data) { $groups[] = $data; } return $groups; } /** * @since version 0.84 * * @param $groups_id * @param $condition (default '') **/ static function getGroupUsers($groups_id, $condition='') { global $DB; $users = array(); $query = "SELECT `glpi_users`.*, `glpi_groups_users`.`id` AS IDD, `glpi_groups_users`.`id` AS linkID, `glpi_groups_users`.`is_dynamic` AS is_dynamic, `glpi_groups_users`.`is_manager` AS is_manager, `glpi_groups_users`.`is_userdelegate` AS is_userdelegate FROM `glpi_groups_users` LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_groups_users`.`users_id`) WHERE `glpi_groups_users`.`groups_id` = '$groups_id'"; if (!empty($condition)) { $query .= " AND $condition "; } $query .= "ORDER BY `glpi_users`.`name`"; foreach ($DB->request($query) as $data) { $users[] = $data; } return $users; } /** Show groups of a user * * @param $user User object **/ static function showForUser(User $user) { global $CFG_GLPI; $ID = $user->fields['id']; if (!Group::canView() || !$user->can($ID, READ)) { return false; } $canedit = $user->can($ID, UPDATE); $rand = mt_rand(); $groups = self::getUserGroups($ID); $used = array(); if (!empty($groups)) { foreach ($groups as $data) { $used[$data["id"]] = $data["id"]; } } if ($canedit) { echo "
| "; $header_top .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_end .= " | "; } $header_end .= "".Group::getTypeName(1)." | "; $header_end .= "".__('Dynamic')." | "; $header_end .= "".__('Manager')." | "; $header_end .= "".__('Delegatee')." |
|---|---|---|---|---|
| "; Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]); echo " | "; } $link = $data["completename"]; if ($_SESSION["glpiis_ids_visible"]) { $link = sprintf(__('%1$s (%2$s)'), $link, $data["id"]); } $href = "". $link.""; if ($data["is_dynamic"]) { $href = sprintf(__('%1$s (%2$s)'), $href, "".__('D').""); } echo "".$group->getLink()." | "; echo "";
if ($data['is_dynamic']) {
echo " | ";
if ($data['is_manager']) {
echo " | ";
if ($data['is_userdelegate']) {
echo " |
| ".__('None')." | ||||