Correction pour rendre le plugin visible dans GLPI

This commit is contained in:
tips-of-mine
2025-05-31 11:23:24 +02:00
committed by GitHub
parent 3b1d93e916
commit 5aa9cfb33e
4 changed files with 183 additions and 0 deletions

98
inc/config.class.php Normal file
View File

@ -0,0 +1,98 @@
<?php
/**
* SOC Config Class
*/
class PluginSocConfig extends CommonDBTM {
static $rightname = 'config';
/**
* Show config form
*
* @return void
*/
function showConfigForm() {
global $CFG_GLPI;
$config = self::getConfig();
echo "<form name='form' action='".Toolbox::getItemTypeFormURL(__CLASS__)."' method='post'>";
echo "<div class='center' id='tabsbody'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<th colspan='4'>".__('SOC Case Management Configuration', 'soc')."</th>";
echo "</tr>";
echo "<tr class='tab_bg_2'>";
echo "<td>".__('Auto-close cases after (days)', 'soc')."</td>";
echo "<td>";
Dropdown::showNumber('autoclose_delay', ['value' => $config['autoclose_delay'],
'min' => 0,
'max' => 999,
'toadd' => [0 => __('Never')]]);
echo "</td>";
echo "<td>".__('Default severity for new cases', 'soc')."</td>";
echo "<td>";
Dropdown::showFromArray('default_severity', PluginSocCase::getSeverityOptions(),
['value' => $config['default_severity']]);
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_2'>";
echo "<td colspan='4' class='center'>";
echo "<input type='submit' name='update' value=\""._sx('button', 'Save')."\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</div>";
Html::closeForm();
}
/**
* Get plugin config
*
* @return array
*/
static function getConfig() {
$config = Config::getConfigurationValues('plugin:soc');
$default_config = [
'autoclose_delay' => 0,
'default_severity' => PluginSocCase::SEVERITY_MEDIUM
];
// Set default values if not set
foreach ($default_config as $key => $value) {
if (!isset($config[$key])) {
$config[$key] = $value;
}
}
return $config;
}
/**
* Hook to install initial configuration
*/
static function install() {
$default_config = [
'autoclose_delay' => 0,
'default_severity' => PluginSocCase::SEVERITY_MEDIUM
];
Config::setConfigurationValues('plugin:soc', $default_config);
return true;
}
/**
* Hook to uninstall configuration
*/
static function uninstall() {
Config::deleteConfigurationValues('plugin:soc', ['autoclose_delay', 'default_severity']);
return true;
}
}