Correction du schéma de la base de données et des hooks

This commit is contained in:
tips-of-mine
2025-05-31 14:50:31 +02:00
committed by GitHub
parent 4622a1a2cd
commit 80167ce471
3 changed files with 67 additions and 35 deletions

View File

@ -76,26 +76,18 @@ function plugin_init_soc() {
// Register plugin classes
Plugin::registerClass('PluginSocCase');
Plugin::registerClass('PluginSocProfile', ['addtabtypes' => ['Profile']]);
Plugin::registerClass('PluginSocProfile', ['classname' => 'PluginSocProfile']);
// Add menu items
if (Session::haveRight('plugin_soc_case', READ)) {
$PLUGIN_HOOKS['menu_toadd']['soc'] = ['management' => 'PluginSocCase'];
}
// Add a tab to Changes
if (Session::haveRight('change', READ)) {
$PLUGIN_HOOKS['add_tab']['soc'] = [
'Change' => 'PluginSocCase',
];
}
// Add a tab to Tickets
if (Session::haveRight('ticket', READ)) {
$PLUGIN_HOOKS['add_tab']['soc'] = [
'Ticket' => 'PluginSocCase',
];
}
// Add tabs to items
$PLUGIN_HOOKS['add_tab']['soc'] = [
'Ticket' => ['PluginSocCase', 'displayTabContentForItem'],
'Change' => ['PluginSocCase', 'displayTabContentForItem']
];
// Add config page
if (Session::haveRight('config', UPDATE)) {
@ -108,8 +100,10 @@ function plugin_init_soc() {
$PLUGIN_HOOKS['item_delete']['soc'] = ['*' => 'plugin_soc_item_delete'];
$PLUGIN_HOOKS['item_purge']['soc'] = ['*' => 'plugin_soc_item_purge'];
// Display hooks
$PLUGIN_HOOKS['post_item_form']['soc'] = ['PluginSocCase', 'displayTabContentForItem'];
// Add standard hooks
$PLUGIN_HOOKS['headings']['soc'] = 'plugin_get_headings_soc';
$PLUGIN_HOOKS['headings_action']['soc'] = 'plugin_headings_actions_soc';
$PLUGIN_HOOKS['dropdown']['soc'] = 'plugin_soc_getDropdowns';
}
/**
@ -122,17 +116,17 @@ function plugin_soc_install() {
if (!$DB->tableExists('glpi_plugin_soc_cases')) {
$query = "CREATE TABLE `glpi_plugin_soc_cases` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`entities_id` int(11) NOT NULL DEFAULT '0',
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`entities_id` int(11) UNSIGNED NOT NULL DEFAULT '0',
`is_recursive` tinyint(1) NOT NULL DEFAULT '0',
`severity` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`severity` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`date_creation` timestamp NULL DEFAULT NULL,
`date_mod` timestamp NULL DEFAULT NULL,
`description` text COLLATE utf8_unicode_ci,
`users_id_tech` int(11) NOT NULL DEFAULT '0',
`groups_id_tech` int(11) NOT NULL DEFAULT '0',
`description` text COLLATE utf8mb4_unicode_ci,
`users_id_tech` int(11) UNSIGNED NOT NULL DEFAULT '0',
`groups_id_tech` int(11) UNSIGNED NOT NULL DEFAULT '0',
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `name` (`name`),
@ -143,33 +137,33 @@ function plugin_soc_install() {
KEY `users_id_tech` (`users_id_tech`),
KEY `groups_id_tech` (`groups_id_tech`),
KEY `is_deleted` (`is_deleted`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
$DB->query($query) or die("Error creating glpi_plugin_soc_cases table " . $DB->error());
}
if (!$DB->tableExists('glpi_plugin_soc_case_tickets')) {
$query = "CREATE TABLE `glpi_plugin_soc_case_tickets` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`plugin_soc_cases_id` int(11) NOT NULL DEFAULT '0',
`tickets_id` int(11) NOT NULL DEFAULT '0',
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`plugin_soc_cases_id` int(11) UNSIGNED NOT NULL DEFAULT '0',
`tickets_id` int(11) UNSIGNED NOT NULL DEFAULT '0',
`date_creation` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`plugin_soc_cases_id`,`tickets_id`),
KEY `tickets_id` (`tickets_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
$DB->query($query) or die("Error creating glpi_plugin_soc_case_tickets table" . $DB->error());
}
if (!$DB->tableExists('glpi_plugin_soc_case_changes')) {
$query = "CREATE TABLE `glpi_plugin_soc_case_changes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`plugin_soc_cases_id` int(11) NOT NULL DEFAULT '0',
`changes_id` int(11) NOT NULL DEFAULT '0',
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`plugin_soc_cases_id` int(11) UNSIGNED NOT NULL DEFAULT '0',
`changes_id` int(11) UNSIGNED NOT NULL DEFAULT '0',
`date_creation` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`plugin_soc_cases_id`,`changes_id`),
KEY `changes_id` (`changes_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
$DB->query($query) or die("Error creating glpi_plugin_soc_case_changes table" . $DB->error());
}