mirror of
https://github.com/tips-of-mine/GLPI-Plugin-SOC-Case-Management.git
synced 2025-06-27 21:28:42 +02:00
108 lines
2.7 KiB
PHP
108 lines
2.7 KiB
PHP
<?php
|
|
/**
|
|
* SOC Profile class
|
|
*/
|
|
class PluginSocProfile extends Profile {
|
|
|
|
static $rightname = "profile";
|
|
|
|
/**
|
|
* @param string $right
|
|
* @return integer
|
|
*/
|
|
function getRight($right) {
|
|
return $this->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 "<div class='firstbloc'>";
|
|
|
|
if (($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, DELETE, PURGE]))
|
|
&& $openform) {
|
|
$profile = new Profile();
|
|
echo "<form method='post' action='".$profile->getFormURL()."'>";
|
|
}
|
|
|
|
$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 "<div class='center'>";
|
|
echo Html::hidden('id', ['value' => $profiles_id]);
|
|
echo Html::submit(_sx('button', 'Save'), ['name' => 'update']);
|
|
echo "</div>\n";
|
|
Html::closeForm();
|
|
}
|
|
|
|
echo "</div>";
|
|
}
|
|
} |