diff --git a/hook.php b/hook.php index 4bc5924..d225b49 100644 --- a/hook.php +++ b/hook.php @@ -42,24 +42,27 @@ function plugin_connections_install() { // Go for 1.7.0 if (!$DB->tableExists('glpi_plugin_connection') && !$DB->tableExists('glpi_plugin_connections_connections')) { // Fresh install - $DB->runFile(GLPI_ROOT . '/plugins/connections/sql/empty-1.7.0.sql'); + $DB->runFile(GLPI_ROOT . '/plugins/connections/sql/empty-9.4.0.sql'); // We're 1.6.0 update to 1.6.4 } elseif ($DB->tableExists('glpi_plugin_connections_connectionratesguaranteed') && !$DB->tableExists('glpi_plugin_connectiond_device')) { $DB->runFile(GLPI_ROOT . '/plugins/connections/sql/update-1.6.0-to-1.6.4.sql'); - } elseif ($DB->tableExists("glpi_plugin_connection") && !FieldExists("glpi_plugin_connection", "recursive")) { + } elseif ($DB->tableExists("glpi_plugin_connection") && !$DB->FieldExists("glpi_plugin_connection", "recursive")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.3.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.4.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.5.0.sql"); - } elseif ($DB->tableExists("glpi_plugin_connection_profiles") && FieldExists("glpi_plugin_connection_profiles", "interface")) { + } elseif ($DB->tableExists("glpi_plugin_connection_profiles") && $DB->FieldExists("glpi_plugin_connection_profiles", "interface")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.4.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.3.0.sql"); - } elseif ($DB->tableExists("glpi_plugin_connection") && !FieldExists("glpi_plugin_connection", "helpdesk_visible")) { + } elseif ($DB->tableExists("glpi_plugin_connection") && !$DB->FieldExists("glpi_plugin_connection", "helpdesk_visible")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.3.0.sql"); + } elseif ($DB->tableExists("glpi_plugin_connections_connectionrates") && + !$DB->FieldExists("glpi_plugin_connections_connectionrates", "is_recursive")) { + $DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-9.4.0.sql"); } @@ -149,6 +152,7 @@ function plugin_connections_uninstall() { "glpi_documents_items", "glpi_savedsearches", "glpi_logs", + "glpi_items_tickets" ]; foreach ($tables_glpi as $table_glpi) { diff --git a/sql/empty-9.4.0.sql b/sql/empty-9.4.0.sql new file mode 100644 index 0000000..b058b29 --- /dev/null +++ b/sql/empty-9.4.0.sql @@ -0,0 +1,91 @@ +DROP TABLE IF EXISTS `glpi_plugin_connections_connections`; +CREATE TABLE `glpi_plugin_connections_connections` ( + `id` int(11) NOT NULL auto_increment, + `entities_id` int(11) NOT NULL default '0', + `is_recursive` tinyint(1) NOT NULL default '0', + `name` varchar(255) collate utf8_unicode_ci default NULL, + `plugin_connections_connectiontypes_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_connections_connectiontypes (id)', + `plugin_connections_connectionrates_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_connections_connectionrates (id)', + `plugin_connections_guaranteedconnectionrates_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_connections_connectionratesguaranteed (id)', + `bytes` varchar(255) collate utf8_unicode_ci NOT NULL default '', + `users_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_users (id)', + `groups_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_groups (id)', + `suppliers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)', + `comment` text collate utf8_unicode_ci, + `notepad` longtext collate utf8_unicode_ci, + `others` varchar(255) collate utf8_unicode_ci default NULL, + `is_helpdesk_visible` int(11) NOT NULL default '1', + `date_mod` datetime default NULL, + `is_deleted` tinyint(1) NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `name` (`name`), + KEY `entities_id` (`entities_id`), + KEY `plugin_connections_connectiontypes_id` (`plugin_connections_connectiontypes_id`), + KEY `plugin_connections_connectionrates_id` (`plugin_connections_connectionrates_id`), + KEY `plugin_connections_guaranteedconnectionrates_id` (`plugin_connections_guaranteedconnectionrates_id`), + KEY `users_id` (`users_id`), + KEY `groups_id` (`groups_id`), + KEY `suppliers_id` (`suppliers_id`), + KEY `date_mod` (`date_mod`), + KEY `is_helpdesk_visible` (`is_helpdesk_visible`), + KEY `is_deleted` (`is_deleted`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +DROP TABLE IF EXISTS `glpi_plugin_connections_connections_items`; +CREATE TABLE `glpi_plugin_connections_connections_items` ( + `id` int(11) NOT NULL auto_increment, + `plugin_connections_connections_id` int(11) NOT NULL default '0', + `items_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)', + `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file', + PRIMARY KEY (`id`), + UNIQUE KEY `unicity` (`plugin_connections_connections_id`,`itemtype`,`items_id`), + KEY `FK_device` (`items_id`,`itemtype`), + KEY `item` (`itemtype`,`items_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +DROP TABLE IF EXISTS `glpi_plugin_connections_connectiontypes`; +CREATE TABLE `glpi_plugin_connections_connectiontypes` ( + `id` int(11) NOT NULL auto_increment, + `entities_id` int(11) NOT NULL default '0', + `name` varchar(255) collate utf8_unicode_ci default NULL, + `comment` text collate utf8_unicode_ci, + `is_recursive` tinyint(1) NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +DROP TABLE IF EXISTS `glpi_plugin_connections_connectionrates`; +CREATE TABLE `glpi_plugin_connections_connectionrates` ( + `id` int(11) NOT NULL auto_increment, + `entities_id` int(11) NOT NULL default '0', + `name` varchar(255) collate utf8_unicode_ci default NULL, + `comment` text collate utf8_unicode_ci, + `is_recursive` tinyint(1) NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +DROP TABLE IF EXISTS `glpi_plugin_connections_guaranteedconnectionrates`; +CREATE TABLE `glpi_plugin_connections_guaranteedconnectionrates` ( + `id` int(11) NOT NULL auto_increment, + `entities_id` int(11) NOT NULL default '0', + `name` varchar(255) collate utf8_unicode_ci default NULL, + `comment` text collate utf8_unicode_ci, + `is_recursive` tinyint(1) NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +DROP TABLE IF EXISTS `glpi_plugin_connections_configs`; +CREATE TABLE `glpi_plugin_connections_configs` ( + `id` int(11) NOT NULL auto_increment, + `delay_expired` varchar(50) collate utf8_unicode_ci NOT NULL default '30', + `delay_whichexpire` varchar(50) collate utf8_unicode_ci NOT NULL default '30', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginConnectionsConnection','2','3','0'); +INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginConnectionsConnection','3','1','0'); +INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginConnectionsConnection','4','2','0'); +INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginConnectionsConnection','6','4','0'); +INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginConnectionsConnection','7','5','0'); diff --git a/sql/update-9.4.0.sql b/sql/update-9.4.0.sql new file mode 100644 index 0000000..f90b09d --- /dev/null +++ b/sql/update-9.4.0.sql @@ -0,0 +1,9 @@ +ALTER TABLE `glpi_plugin_connections_connectionrates` +ADD `is_recursive` tinyint(1) NOT NULL default '0'; + +ALTER TABLE `glpi_plugin_connections_guaranteedconnectionrates` +ADD `is_recursive` tinyint(1) NOT NULL default '0'; + +ALTER TABLE `glpi_plugin_connections_connectiontypes` +ADD `is_recursive` tinyint(1) NOT NULL default '0'; +