mirror of
https://github.com/tips-of-mine/GLPI-Plugin-SOC-Case-Management.git
synced 2025-06-27 21:28:42 +02:00
Correction du schéma de la base de données et des hooks
This commit is contained in:
@ -42,13 +42,29 @@ if (isset($_POST["add"])) {
|
||||
Session::checkRight("plugin_soc_case", UPDATE);
|
||||
$case = new PluginSocCase();
|
||||
$case->getFromDB($_POST['plugin_soc_cases_id']);
|
||||
$tickets_id = $case->createTicket($_POST);
|
||||
|
||||
// Link existing ticket to case
|
||||
if (isset($_POST['tickets_id']) && $_POST['tickets_id'] > 0) {
|
||||
$case->addTicket($_POST['tickets_id']);
|
||||
} else {
|
||||
// Create new ticket from case
|
||||
$case->createTicket($_POST);
|
||||
}
|
||||
|
||||
Html::back();
|
||||
} else if (isset($_POST["add_change"])) {
|
||||
Session::checkRight("plugin_soc_case", UPDATE);
|
||||
$case = new PluginSocCase();
|
||||
$case->getFromDB($_POST['plugin_soc_cases_id']);
|
||||
$changes_id = $case->createChange($_POST);
|
||||
|
||||
// Link existing change to case
|
||||
if (isset($_POST['changes_id']) && $_POST['changes_id'] > 0) {
|
||||
$case->addChange($_POST['changes_id']);
|
||||
} else {
|
||||
// Create new change from case
|
||||
$case->createChange($_POST);
|
||||
}
|
||||
|
||||
Html::back();
|
||||
} else {
|
||||
$id = "";
|
||||
|
@ -322,4 +322,26 @@ class PluginSocCase extends CommonDBTM {
|
||||
'date_creation' => $_SESSION["glpi_currenttime"]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display tab content for item
|
||||
*
|
||||
* @param CommonGLPI $item
|
||||
* @param integer $tabnum
|
||||
* @param integer $withtemplate
|
||||
* @return boolean
|
||||
*/
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
|
||||
switch ($item->getType()) {
|
||||
case 'Ticket':
|
||||
$case_ticket = new PluginSocCaseTicket();
|
||||
$case_ticket->showForTicket($item);
|
||||
return true;
|
||||
case 'Change':
|
||||
$case_change = new PluginSocCaseChange();
|
||||
$case_change->showForChange($item);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
60
setup.php
60
setup.php
@ -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());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user