public static function createFirstAccess($ID) { $talk_profile = new self(); $profile = new Profile(); $dataprofile = array('id' => $ID); $profile->getFromDB($ID); foreach ($talk_profile->getAllRights(true) as $talk_r) { $g_rights = $profile->getRightsFor($talk_r['itemtype']); foreach ($g_rights as $g_right => $label) { $dataprofile['_' . $talk_r['field']][$g_right . "_0"] = 1; } } $profile->update($dataprofile); }
/** * Init profiles during installation : * - add rights in profile table for the current user's profile * - current profile has all rights on the plugin */ static function initProfile() { $pfProfile = new self(); $profile = new Profile(); $a_rights = $pfProfile->getAllRights(); foreach ($a_rights as $data) { if (countElementsInTable("glpi_profilerights", "`name` = '" . $data['field'] . "'") == 0) { ProfileRight::addProfileRights(array($data['field'])); $_SESSION['glpiactiveprofile'][$data['field']] = 0; } } // Add all rights to current profile of the user if (isset($_SESSION['glpiactiveprofile'])) { $dataprofile = array(); $dataprofile['id'] = $_SESSION['glpiactiveprofile']['id']; $profile->getFromDB($_SESSION['glpiactiveprofile']['id']); foreach ($a_rights as $info) { if (is_array($info) && (!empty($info['itemtype']) || !empty($info['rights'])) && !empty($info['label']) && !empty($info['field'])) { if (isset($info['rights'])) { $rights = $info['rights']; } else { $rights = $profile->getRightsFor($info['itemtype']); } foreach ($rights as $right => $label) { $dataprofile['_' . $info['field']][$right] = 1; $_SESSION['glpiactiveprofile'][$data['field']] = $right; } } } $profile->update($dataprofile); } }
/** * Initialize profiles, and migrate it necessary */ static function initProfile() { global $DB; $profile = new self(); //Add new rights in glpi_profilerights table foreach ($profile->getAllRights(true) as $data) { if (countElementsInTable("glpi_profilerights", "`name` = '" . $data['field'] . "'") == 0) { ProfileRight::addProfileRights(array($data['field'])); } } //Migration old rights in new ones foreach ($DB->request("SELECT `id` FROM `glpi_profiles`") as $prof) { self::migrateOneProfile($prof['id']); } foreach ($DB->request("SELECT *\n FROM `glpi_profilerights` \n WHERE `profiles_id`='" . $_SESSION['glpiactiveprofile']['id'] . "' \n AND `name` LIKE '%plugin_accounts%'") as $prof) { $_SESSION['glpiactiveprofile'][$prof['name']] = $prof['rights']; } }
static function uninstallProfile() { $pfProfile = new self(); $a_rights = $pfProfile->getAllRights(); foreach ($a_rights as $data) { ProfileRight::deleteProfileRights(array($data['field'])); } }
/** * Initialize profiles, and migrate it necessary */ static function initProfile() { global $DB; $profile = new self(); //Add new rights in glpi_profilerights table foreach ($profile->getAllRights(true) as $data) { if (countElementsInTable("glpi_profilerights", "`name` = '" . $data['field'] . "'") == 0) { ProfileRight::addProfileRights(array($data['field'])); } } }