fields[$right]; } /** * Init profiles * * @return void */ static function initProfile() { global $DB; $profile = new self(); // Add new rights in glpi_profilerights table foreach ($profile->getAllRights() as $right) { if (!countElementsInTable("glpi_profilerights", ['name' => $right['field']])) { ProfileRight::addProfileRights([$right['field']]); } } } /** * Get all rights * * @return array */ static function getAllRights() { $rights = [ [ 'field' => 'plugin_soc_case', 'name' => __('SOC Case', 'soc'), 'rights' => [ CREATE => __('Create'), READ => __('Read'), UPDATE => __('Update'), DELETE => __('Delete'), PURGE => __('Purge') ] ] ]; return $rights; } /** * Create first access for super-admin user * * @param integer $ID * @return void */ static function createFirstAccess($ID) { $profile = new self(); foreach ($profile->getAllRights() as $right) { self::addDefaultProfileInfos($ID, [$right['field'] => ALLSTANDARDRIGHT]); } } /** * Show profile form * * @param integer $profiles_id * @param boolean $openform * @param boolean $closeform * @return void */ function showForm($profiles_id = 0, $openform = true, $closeform = true) { echo "
"; if (($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, DELETE, PURGE])) && $openform) { $profile = new Profile(); echo "
"; } $profile = new Profile(); $profile->getFromDB($profiles_id); $rights = $this->getAllRights(); $profile->displayRightsChoiceMatrix($rights, ['canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')]); if ($canedit && $closeform) { echo "
"; echo Html::hidden('id', ['value' => $profiles_id]); echo Html::submit(_sx('button', 'Save'), ['name' => 'update']); echo "
\n"; Html::closeForm(); } echo "
"; } }