mirror of
https://github.com/tips-of-mine/GLPI-Plugin-SOC-Case-Management.git
synced 2025-06-28 05:38:42 +02:00
Start repository
This commit is contained in:
100
setup.php
Normal file
100
setup.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* Init the hooks of the plugin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function plugin_soc_install() {
|
||||
global $DB;
|
||||
|
||||
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',
|
||||
`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,
|
||||
`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',
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `name` (`name`),
|
||||
KEY `entities_id` (`entities_id`),
|
||||
KEY `is_recursive` (`is_recursive`),
|
||||
KEY `severity` (`severity`),
|
||||
KEY `status` (`status`),
|
||||
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";
|
||||
$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',
|
||||
`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";
|
||||
$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',
|
||||
`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";
|
||||
$DB->query($query) or die("Error creating glpi_plugin_soc_case_changes table" . $DB->error());
|
||||
}
|
||||
|
||||
// Create profiles rights
|
||||
PluginSocProfile::initProfile();
|
||||
PluginSocProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall the plugin
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function plugin_soc_uninstall() {
|
||||
global $DB;
|
||||
|
||||
// Delete plugin tables
|
||||
$tables = [
|
||||
'glpi_plugin_soc_cases',
|
||||
'glpi_plugin_soc_case_tickets',
|
||||
'glpi_plugin_soc_case_changes',
|
||||
'glpi_plugin_soc_profiles'
|
||||
];
|
||||
|
||||
foreach ($tables as $table) {
|
||||
$query = "DROP TABLE IF EXISTS `$table`";
|
||||
$DB->query($query) or die("Error dropping $table table");
|
||||
}
|
||||
|
||||
// Delete plugin rights from profiles table
|
||||
$query = "DELETE FROM `glpi_profilerights` WHERE `name` LIKE 'plugin_soc_%'";
|
||||
$DB->query($query) or die("Error deleting plugin_soc rights");
|
||||
|
||||
// Delete plugin display preferences
|
||||
$query = "DELETE FROM `glpi_displaypreferences` WHERE `itemtype` LIKE 'PluginSoc%'";
|
||||
$DB->query($query) or die("Error deleting plugin_soc display preferences");
|
||||
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user