function plugin_racks_install() { global $DB; include_once GLPI_ROOT . "/plugins/racks/inc/profile.class.php"; $migration = new Migration("1.5.0"); $update = false; if (!TableExists("glpi_plugin_rack_profiles") && !TableExists("glpi_plugin_racks_profiles")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/empty-1.4.2.sql"); } elseif (TableExists("glpi_plugin_rack_content") && !FieldExists("glpi_plugin_rack_content", "first_powersupply")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.0.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql"); } elseif (!TableExists("glpi_plugin_racks_profiles")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql"); } //from 1.1 version if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "otherserial")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.2.1.sql"); } if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "users_id_tech")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.0.sql"); } if (!TableExists("glpi_plugin_racks_racktypes")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.2.sql"); } if (TableExists("glpi_plugin_racks_racktypes") && !FieldExists("glpi_plugin_racks_racktypes", "is_recursive")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.4.1.sql"); } if (TableExists("glpi_plugin_racks_profiles") && !FieldExists("glpi_plugin_racks_profiles", "open_ticket")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.4.2.sql"); } if ($update) { foreach ($DB->request('glpi_plugin_racks_profiles') as $data) { $query = "UPDATE `glpi_plugin_racks_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } $migration->dropField('glpi_plugin_racks_profiles', 'name'); Plugin::migrateItemType(array(4450 => 'PluginRacksRack', 4451 => 'PluginRacksOther'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_racks_racks_items", "glpi_plugin_racks_itemspecifications")); } $notepad_tables = array('glpi_plugin_racks_racks'); foreach ($notepad_tables as $t) { // Migrate data if (FieldExists($t, 'notepad')) { $query = "SELECT id, notepad\n FROM `{$t}`\n WHERE notepad IS NOT NULL\n AND notepad <>'';"; foreach ($DB->request($query) as $data) { $iq = "INSERT INTO `glpi_notepads`\n (`itemtype`, `items_id`, `content`, `date`, `date_mod`)\n VALUES ('" . getItemTypeForTable($t) . "', '" . $data['id'] . "',\n '" . addslashes($data['notepad']) . "', NOW(), NOW())"; $DB->queryOrDie($iq, "0.85 migrate notepad data"); } $query = "ALTER TABLE `glpi_plugin_racks_racks` DROP COLUMN `notepad`;"; $DB->query($query); } } //Migrate profiles to the system introduced in 0.85 PluginRacksProfile::initProfile(); PluginRacksProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); //Drop old profile table : not used anymore $migration->dropTable('glpi_plugin_racks_profiles'); return true; }
function plugin_manufacturersimports_install() { global $DB; include_once GLPI_ROOT . "/plugins/manufacturersimports/inc/profile.class.php"; include_once GLPI_ROOT . "/plugins/manufacturersimports/inc/config.class.php"; $migration = new Migration("1.7.0"); $update = false; //Root of SQL files for DB installation or upgrade $sql_root = GLPI_ROOT . "/plugins/manufacturersimports/sql/"; if (!TableExists("glpi_plugin_manufacturersimports_configs")) { $DB->runFile($sql_root . "/empty-1.7.0.sql"); } else { if (TableExists("glpi_plugin_suppliertag_config") && !FieldExists("glpi_plugin_suppliertag_config", "FK_entities")) { $update = true; $DB->runFile($sql_root . "/update-1.1.sql"); $DB->runFile($sql_root . "/update-1.2.0.sql"); $DB->runFile($sql_root . "/update-1.3.0.sql"); $DB->runFile($sql_root . "/update-1.4.1.sql"); $DB->runFile($sql_root . "/update-1.5.0.sql"); $DB->runFile($sql_root . "/update-1.7.0.sql"); } else { if (TableExists("glpi_plugin_suppliertag_profiles") && FieldExists("glpi_plugin_suppliertag_profiles", "interface")) { $update = true; $DB->runFile($sql_root . "/update-1.2.0.sql"); $DB->runFile($sql_root . "/update-1.3.0.sql"); $DB->runFile($sql_root . "/update-1.4.1.sql"); $DB->runFile($sql_root . "/update-1.5.0.sql"); $DB->runFile($sql_root . "/update-1.7.0.sql"); } else { if (!TableExists("glpi_plugin_manufacturersimports_profiles") && !FieldExists("glpi_plugin_manufacturersimports_configs", "supplier_key")) { $update = true; $DB->runFile($sql_root . "/update-1.3.0.sql"); $DB->runFile($sql_root . "/update-1.4.1.sql"); $DB->runFile($sql_root . "/update-1.5.0.sql"); $DB->runFile($sql_root . "/update-1.7.0.sql"); } else { if (!FieldExists("glpi_plugin_manufacturersimports_configs", "supplier_key")) { $DB->runFile($sql_root . "/update-1.7.0.sql"); } } } } } $query = "UPDATE `glpi_plugin_manufacturersimports_configs` \n SET `Supplier_url` = 'http://www.dell.com/support/troubleshooting/us/en/04/Index?c=us&l=en&s=bsd&cs=04&t=system&ServiceTag=' \n WHERE `name` ='" . PluginManufacturersimportsConfig::DELL . "'"; $DB->query($query); if ($update) { foreach ($DB->request('glpi_plugin_manufacturersimports_profiles') as $data) { $query = "UPDATE `glpi_plugin_manufacturersimports_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $DB->query($query); } $migration->dropField('glpi_plugin_manufacturersimports_profiles', 'name'); Plugin::migrateItemType(array(2150 => 'PluginManufacturersimportsModel', 2151 => 'PluginManufacturersimportsConfig'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_manufacturersimports_models", "glpi_plugin_manufacturersimports_logs")); } //Migrate profiles to the system introduced in 0.85 PluginManufacturersimportsProfile::initProfile(); PluginManufacturersimportsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); //Drop old profile table : not used anymore $migration->dropTable('glpi_plugin_manufacturersimports_profiles'); return true; }
static function install(Migration $migration) { global $DB, $GENINVENTORYNUMBER_TYPES; $table = getTableForItemType(__CLASS__); if (TableExists("glpi_plugin_geninventorynumber_fields")) { //Only migrate itemtypes when it's only necessary, otherwise it breaks upgrade procedure ! $migration->renameTable("glpi_plugin_geninventorynumber_fields", $table); } if (!TableExists($table)) { $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` int(11) NOT NULL auto_increment,\n `plugin_geninventorynumber_configs_id` int(11) NOT NULL default '0',\n `itemtype` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',\n `template` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',\n `is_active` tinyint(1) NOT NULL default '0',\n `use_index` tinyint(1) NOT NULL default '0',\n `index` bigint(20) NOT NULL default '0',\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query); } else { $migration->changeField($table, 'ID', 'id', 'autoincrement'); $migration->changeField($table, 'config_id', 'plugin_geninventorynumber_configs_id', 'integer'); if ($migration->changeField($table, 'device_type', 'itemtype', 'string')) { $migration->migrationOneTable($table); Plugin::migrateItemType(array(), array("glpi_displaypreferences"), array($table)); } $migration->changeField($table, 'enabled', 'is_active', 'boolean'); $migration->changeField($table, 'use_index', 'use_index', 'boolean'); $migration->migrationOneTable($table); } $field = new self(); foreach ($GENINVENTORYNUMBER_TYPES as $type) { if (!countElementsInTable($table, "`itemtype`='{$type}'")) { $input["plugin_geninventorynumber_configs_id"] = 1; $input["itemtype"] = $type; $input["template"] = "<#######>"; $input["is_active"] = 0; $input["index"] = 0; $field->add($input); } } }
function plugin_addressing_install() { global $DB; include_once GLPI_ROOT . "/plugins/addressing/inc/profile.class.php"; $update = false; if (!TableExists("glpi_plugin_addressing_display") && !TableExists("glpi_plugin_addressing") && !TableExists("glpi_plugin_addressing_configs")) { $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/empty-2.0.0.sql"); } else { if (!TableExists("glpi_plugin_addressing_profiles") && TableExists("glpi_plugin_addressing_display") && !FieldExists("glpi_plugin_addressing_display", "ipconf1")) { //1.4 $update = true; $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.4.sql"); } if (!TableExists("glpi_plugin_addressing") && TableExists("glpi_plugin_addressing_display") && FieldExists("glpi_plugin_addressing_display", "ipconf1")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.5.sql"); } if (TableExists("glpi_plugin_addressing_display") && !FieldExists("glpi_plugin_addressing", "ipdeb")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.6.sql"); } if (TableExists("glpi_plugin_addressing_profiles") && FieldExists("glpi_plugin_addressing_profiles", "interface")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.7.0.sql"); } if (!TableExists("glpi_plugin_addressing_configs")) { $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.8.0.sql"); $update = true; } if (TableExists("glpi_plugin_addressing_profiles") && !FieldExists("glpi_plugin_addressing_profiles", "use_ping_in_equipment")) { $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.9.0.sql"); $update = true; } } if ($update) { $query_ = "SELECT *\n FROM `glpi_plugin_addressing_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_addressing_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "'"; $result = $DB->query($query); } } if (FieldExists("glpi_plugin_addressing_profiles", "name")) { $query = "ALTER TABLE `glpi_plugin_addressing_profiles`\n DROP `name` "; $result = $DB->query($query); } Plugin::migrateItemType(array(5000 => 'PluginAddressingAddressing', 5001 => 'PluginAddressingReport'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets")); } //0.85 : new profile system PluginAddressingProfile::migrateProfiles(); //Add all rights for current user profile PluginAddressingProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); //Drop old profile table : not used anymore $migration = new Migration("2.2.0"); $migration->dropTable('glpi_plugin_addressing_profiles'); return true; }
function plugin_webapplications_install() { global $DB; include_once GLPI_ROOT . "/plugins/webapplications/inc/profile.class.php"; $update = false; if (!TableExists("glpi_application") && !TableExists("glpi_plugin_appweb") && !TableExists("glpi_plugin_webapplications_webapplications")) { $DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/empty-1.8.0.sql"); } else { if (TableExists("glpi_application") && !TableExists("glpi_plugin_appweb")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.1.sql"); } //from 1.1 version if (TableExists("glpi_plugin_appweb") && !FieldExists("glpi_plugin_appweb", "location")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.3.sql"); } //from 1.3 version if (TableExists("glpi_plugin_appweb") && !FieldExists("glpi_plugin_appweb", "recursive")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.4.sql"); } if (TableExists("glpi_plugin_appweb_profiles") && FieldExists("glpi_plugin_appweb_profiles", "interface")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.5.0.sql"); } if (TableExists("glpi_plugin_appweb") && !FieldExists("glpi_plugin_appweb", "helpdesk_visible")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.5.1.sql"); } if (!TableExists("glpi_plugin_webapplications_webapplications")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.6.0.sql"); } //from 1.6 version if (TableExists("glpi_plugin_webapplications_webapplications") && !FieldExists("glpi_plugin_webapplications_webapplications", "users_id_tech")) { $DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.8.0.sql"); } } if ($update) { $query_ = "SELECT *\n FROM `glpi_plugin_webapplications_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_webapplications_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_webapplications_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(1300 => 'PluginWebapplicationsWebapplication'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_webapplications_webapplications_items")); Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance"), array("glpi_plugin_webapplications_webapplications_items")); } PluginWebapplicationsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function plugin_manufacturersimports_install() { global $DB; include_once GLPI_ROOT . "/plugins/manufacturersimports/inc/profile.class.php"; $update = false; if (!TableExists("glpi_plugin_suppliertag_profiles") && !TableExists("glpi_plugin_manufacturersimports_profiles")) { $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/empty-1.5.0.sql"); } else { if (TableExists("glpi_plugin_suppliertag_config") && !FieldExists("glpi_plugin_suppliertag_config", "FK_entities")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.3.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.4.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.5.0.sql"); } else { if (TableExists("glpi_plugin_suppliertag_profiles") && FieldExists("glpi_plugin_suppliertag_profiles", "interface")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.3.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.4.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.5.0.sql"); } else { if (!TableExists("glpi_plugin_manufacturersimports_profiles")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.3.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.4.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.5.0.sql"); } } } } $query = "UPDATE `glpi_plugin_manufacturersimports_configs` \n SET `Supplier_url` = 'http://www.dell.com/support/troubleshooting/us/en/04/Index?c=us&l=en&s=bsd&cs=04&t=system&ServiceTag=' \n WHERE `name` ='Dell'"; $DB->query($query); if ($update) { $query_ = "SELECT *\n FROM `glpi_plugin_manufacturersimports_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_manufacturersimports_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_manufacturersimports_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(2150 => 'PluginManufacturersimportsModel', 2151 => 'PluginManufacturersimportsConfig'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_manufacturersimports_models", "glpi_plugin_manufacturersimports_logs")); } PluginManufacturersimportsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function plugin_racks_install() { global $DB; include_once GLPI_ROOT . "/plugins/racks/inc/profile.class.php"; $update = false; if (!TableExists("glpi_plugin_rack_profiles") && !TableExists("glpi_plugin_racks_profiles")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/empty-1.4.1.sql"); } else { if (TableExists("glpi_plugin_rack_content") && !FieldExists("glpi_plugin_rack_content", "first_powersupply")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.0.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql"); } else { if (!TableExists("glpi_plugin_racks_profiles")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql"); } } } //from 1.1 version if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "otherserial")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.2.1.sql"); } if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "users_id_tech")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.0.sql"); } if (!TableExists("glpi_plugin_racks_racktypes")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.2.sql"); } if (TableExists("glpi_plugin_racks_racktypes") && !FieldExists("glpi_plugin_racks_racktypes", "is_recursive")) { $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.4.1.sql"); } if ($update) { $query_ = "SELECT *\n FROM `glpi_plugin_racks_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_racks_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_racks_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(4450 => 'PluginRacksRack', 4451 => 'PluginRacksOther'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_racks_racks_items", "glpi_plugin_racks_itemspecifications")); } PluginRacksProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function plugin_financialreports_install() { global $DB; include_once GLPI_ROOT . "/plugins/financialreports/inc/profile.class.php"; $update = false; if (!TableExists("glpi_plugin_state_profiles") && !TableExists("glpi_plugin_financialreports_configs")) { $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/empty-2.1.0.sql"); } else { if (TableExists("glpi_plugin_state_parameters") && !FieldExists("glpi_plugin_state_parameters", "monitor")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.5.sql"); $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.7.0.sql"); } else { if (TableExists("glpi_plugin_state_profiles") && FieldExists("glpi_plugin_state_profiles", "interface")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.7.0.sql"); } else { if (!TableExists("glpi_plugin_financialreports_configs")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.7.0.sql"); } } } } if ($update) { //Do One time on 0.78 $query_ = "SELECT *\n FROM `glpi_plugin_financialreports_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_financialreports_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_financialreports_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(3450 => 'PluginFinancialreportsDisposalItem'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_financialreports_disposalitems")); } //Migrate profiles to the new system PluginFinancialreportsProfile::initProfile(); PluginFinancialreportsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); $migration = new Migration("2.0.0"); $migration->dropTable('glpi_plugin_financialreports_profiles'); return true; }
function plugin_connections_install() { global $DB; include_once GLPI_ROOT . "/plugins/connections/inc/profile.class.php"; $update = false; //TODO: Use "Migration" class instead (available since GLPI v0.80) // Go for 1.7.0 if (!TableExists('glpi_plugin_connection') && !TableExists('glpi_plugin_connections_connections')) { // Fresh install $DB->runFile(GLPI_ROOT . '/plugins/connections/sql/empty-1.7.0.sql'); // We're 1.6.0 update to 1.6.4 } elseif (TableExists('glpi_plugin_connections_connectionratesguaranteed') && !TableExists('glpi_plugin_connectiond_device')) { $DB->runFile(GLPI_ROOT . '/plugins/connections/sql/update-1.6.0-to-1.6.4.sql'); } elseif (TableExists("glpi_plugin_connection") && !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 (TableExists("glpi_plugin_connection_profiles") && 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 (TableExists("glpi_plugin_connection") && !FieldExists("glpi_plugin_connection", "helpdesk_visible")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.3.0.sql"); } if ($update) { $query_ = "SELECT * FROM `glpi_plugin_connections_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_connections_profiles`\r\n SET `profiles_id` = '" . $data["id"] . "'\r\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $DB->query("ALTER TABLE `glpi_plugin_connections_profiles` DROP `name`;"); Plugin::migrateItemType(array(4400 => 'PluginConnectionsConnection'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_connections_connections_items")); Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance", 1300 => "PluginWebapplicationsWebapplication"), array("glpi_plugin_connections_connections_items")); } if (TableExists("glpi_plugin_connections_profiles")) { PluginConnectionsProfile::migrateProfiles(); } PluginConnectionsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function plugin_routetables_install() { global $DB; include_once GLPI_ROOT . "/plugins/routetables/inc/profile.class.php"; $update = false; if (!TableExists("glpi_plugin_routetable_profiles") && !TableExists("glpi_plugin_routetables_profiles")) { $DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/empty-1.2.0.sql"); } else { if (TableExists("glpi_plugin_routetable_profiles") && FieldExists("glpi_plugin_routetable_profiles", "interface")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.1.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.1.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.2.0.sql"); } else { if (TableExists("glpi_plugin_routetable") && !FieldExists("glpi_plugin_routetable", "helpdesk_visible")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.1.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.2.0.sql"); } else { if (!TableExists("glpi_plugin_routetables_profiles")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.2.0.sql"); } } } } if ($update) { $query_ = "SELECT *\n FROM `glpi_plugin_routetables_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_routetables_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_routetables_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(5100 => 'PluginRoutetablesRoutetable'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_routetables_routetables_items")); } PluginRoutetablesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
public static function install(Migration $migration) { global $DB; $table = getTableForItemType(__CLASS__); if (!TableExists($table)) { $migration->displayMessage("Installing {$table}"); //Install $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_references` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `manufacturers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_manufacturers (id)',\n `manufacturers_reference` varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT '',\n `types_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtypes tables (id)',\n `models_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemmodels tables (id)',\n `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file',\n `templates_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)',\n `comment` text collate utf8_unicode_ci,\n `is_deleted` tinyint(1) NOT NULL default '0',\n `is_active` tinyint(1) NOT NULL default '1',\n `notepad` longtext collate utf8_unicode_ci,\n `date_mod` datetime default NULL,\n PRIMARY KEY (`id`),\n KEY `name` (`name`),\n KEY `entities_id` (`entities_id`),\n KEY `manufacturers_id` (`manufacturers_id`),\n KEY `types_id` (`types_id`),\n KEY `models_id` (`models_id`),\n KEY `templates_id` (`templates_id`),\n KEY `is_active` (`is_active`),\n KEY `is_deleted` (`is_deleted`),\n KEY date_mod (date_mod)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die($DB->error()); } else { //Upgrade $migration->displayMessage("Upgrading {$table}"); //1.1.0 $migration->changeField($table, "FK_manufacturer", "FK_glpi_enterprise", "int(11) NOT NULL DEFAULT '0'"); ///1.2.0 $migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment"); $migration->changeField($table, "FK_entities", "entities_id", "int(11) NOT NULL default '0'"); $migration->changeField($table, "recursive", "is_recursive", "tinyint(1) NOT NULL default '0'"); $migration->changeField($table, "name", "name", "varchar(255) collate utf8_unicode_ci default NULL"); $migration->changeField($table, "FK_glpi_enterprise", "manufacturers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_manufacturers (id)'"); $migration->changeField($table, "FK_type", "types_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtypes tables (id)'"); $migration->changeField($table, "FK_model", "models_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemmodels tables (id)'"); $migration->changeField($table, "type", "itemtype", "varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file'"); $migration->changeField($table, "template", "templates_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)'"); $migration->changeField($table, "comments", "comment", "text collate utf8_unicode_ci"); $migration->changeField($table, "deleted", "is_deleted", "tinyint(1) NOT NULL default '0'"); $migration->addField($table, "notepad", "longtext collate utf8_unicode_ci"); $migration->addField($table, "is_active", "TINYINT(1) NOT NULL DEFAULT '1'"); $migration->addField($table, "date_mod", "datetime"); $migration->addKey($table, "name"); $migration->addKey($table, "entities_id"); $migration->addKey($table, "manufacturers_id"); $migration->addKey($table, "types_id"); $migration->addKey($table, "models_id"); $migration->addKey($table, "templates_id"); $migration->addKey($table, "is_deleted"); $migration->addKey($table, "is_active"); $migration->addKey($table, "date_mod"); $migration->migrationOneTable($table); Plugin::migrateItemType(array(3151 => 'PluginOrderReference'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs")); if (FieldExists('glpi_tickets', 'itemtype')) { Plugin::migrateItemType(array(3151 => 'PluginOrderReference'), array("glpi_tickets")); } Plugin::migrateItemType(array(), array(), array($table)); //1.3.0 $DB->query("UPDATE `glpi_plugin_order_references` SET\n `itemtype`='ConsumableItem'\n WHERE `itemtype` ='Consumable'") or die($DB->error()); $DB->query("UPDATE `glpi_plugin_order_references` SET\n `itemtype`='CartridgeItem'\n WHERE `itemtype` ='Cartridge'") or die($DB->error()); //1.7.0 $migration->addField($table, "date_mod", "DATETIME NULL"); $migration->addKey($table, "date_mod"); //Displayprefs $prefs = array(1 => 1, 2 => 4, 4 => 5, 5 => 9, 6 => 6, 7 => 7); foreach ($prefs as $num => $rank) { if (!countElementsInTable("glpi_displaypreferences", "`itemtype`='PluginOrderReference' AND `num`='{$num}'\n AND `users_id`='0'")) { $DB->query("INSERT INTO glpi_displaypreferences\n VALUES (NULL,'PluginOrderReference','{$num}','{$rank}','0');"); } } //Fix error naming field if (FieldExists($table, 'manufacturer_reference')) { $migration->changeField($table, "manufacturer_reference", "manufacturers_reference", "varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT ''"); $migration->migrationOneTable($table); } //2.0.1 if (!FieldExists($table, 'manufacturers_reference')) { $migration->addField($table, "manufacturers_reference", "varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT ''"); $migration->migrationOneTable($table); } } }
public static function install(Migration $migration) { global $DB; $table = getTableForItemType(__CLASS__); if (!TableExists($table)) { if (!TableExists("glpi_plugin_order_suppliers")) { $migration->displayMessage("Installing {$table}"); //install $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_orders_suppliers` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `plugin_order_orders_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)',\n `suppliers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)',\n `num_quote` varchar(255) collate utf8_unicode_ci default NULL,\n `num_order` varchar(255) collate utf8_unicode_ci default NULL,\n `num_bill` varchar(255) collate utf8_unicode_ci default NULL,\n PRIMARY KEY (`id`),\n KEY `plugin_order_orders_id` (`plugin_order_orders_id`),\n KEY `entities_id` (`entities_id`),\n KEY `suppliers_id` (`suppliers_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die($DB->error()); } else { //Upgrade $migration->displayMessage("Upgrading {$table}"); //1.2.0 $migration->renameTable("glpi_plugin_order_suppliers", $table); $migration->addField($table, "entities_id", "int(11) NOT NULL default '0'"); $migration->addField($table, "is_recursive", "tinyint(1) NOT NULL default '0'"); $migration->addField($table, "suppliers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)'"); $migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment"); $migration->changeField($table, "FK_order", "plugin_order_orders_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)'"); $migration->changeField($table, "numquote", "num_quote", "varchar(255) collate utf8_unicode_ci default NULL"); $migration->changeField($table, "numbill", "num_bill", "varchar(255) collate utf8_unicode_ci default NULL"); $migration->changeField($table, "numorder", "num_order", "varchar(255) collate utf8_unicode_ci default NULL"); $migration->addKey($table, "plugin_order_orders_id"); $migration->addKey($table, "suppliers_id"); $migration->migrationOneTable($table); Plugin::migrateItemType(array(3154 => 'PluginOrderOrder_Supplier'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"), array()); //1.5.0 $query = "SELECT `suppliers_id`, `entities_id`,`is_recursive`,`id`\n FROM `glpi_plugin_order_orders` "; foreach ($DB->request($query) as $data) { $query = "UPDATE `glpi_plugin_order_orders_suppliers` SET\n `suppliers_id` = '{$data["suppliers_id"]}'\n WHERE `plugin_order_orders_id` = '{$data["id"]}' "; $DB->query($query) or die($DB->error()); $query = "UPDATE `glpi_plugin_order_orders_suppliers` SET\n `entities_id` = '{$data["entities_id"]}',\n `is_recursive` = '{$data["is_recursive"]}'\n WHERE `plugin_order_orders_id` = '{$data["id"]}' "; $DB->query($query) or die($DB->error()); } } } }
/** * Upgrade => 1.2 */ function plugin_customfields_upgradeto12() { global $DB; $glpi_tables = array('glpi_plugin_customfields_software' => 'glpi_plugin_customfields_softwares', 'glpi_plugin_customfields_networking' => 'glpi_plugin_customfields_networkequipments', 'glpi_plugin_customfields_enterprises' => 'glpi_plugin_customfields_suppliers', 'glpi_plugin_customfields_docs' => 'glpi_plugin_customfields_documents', 'glpi_plugin_customfields_tracking' => 'glpi_plugin_customfields_tickets', 'glpi_plugin_customfields_user' => 'glpi_plugin_customfields_users', 'glpi_plugin_customfields_networking_ports' => 'glpi_plugin_customfields_networkports'); foreach ($glpi_tables as $oldtable => $newtable) { if (!TableExists("{$newtable}") && TableExists("{$oldtable}")) { $query = "RENAME TABLE `{$oldtable}` TO `{$newtable}`"; $DB->query($query) or die($DB->error()); } } if (TableExists("glpi_plugin_customfields")) { $query = "RENAME TABLE `glpi_plugin_customfields`\n TO `glpi_plugin_customfields_itemtypes`"; $DB->query($query) or die($DB->error()); $query = "ALTER TABLE `glpi_plugin_customfields_itemtypes`\n CHANGE `ID` `id` int(11) NOT NULL auto_increment,\n CHANGE `device_type` `itemtype` VARCHAR(100) NOT NULL\n default ''"; $DB->query($query) or die($DB->error()); $tables = array('glpi_plugin_customfields_itemtypes'); Plugin::migrateItemType(array(-1 => 'Version'), array(), $tables); $query = "SELECT `itemtype`\n FROM `glpi_plugin_customfields_itemtypes`\n WHERE `itemtype` <> 'Version' "; $result = $DB->query($query); $enabled = array(); while ($data = $DB->fetch_array($result)) { $enabled[] = $data['itemtype']; $table = plugin_customfields_table($data['itemtype']); if (TableExists($table)) { $query = "ALTER TABLE `{$table}`\n CHANGE `ID` `id` int(11) NOT NULL auto_increment"; $DB->query($query) or die($DB->error()); } } foreach ($enabled as $itemtype) { $sql = "UPDATE `glpi_plugin_customfields_itemtypes`\n SET `enabled` = 1\n WHERE `itemtype` = '{$itemtype}';"; $DB->query($sql) or die($DB->error()); } } if (TableExists("glpi_plugin_customfields_dropdowns")) { $query = "ALTER TABLE `glpi_plugin_customfields_dropdowns`\n CHANGE `ID` `id` int(11) NOT NULL auto_increment"; $DB->query($query) or die($DB->error()); } if (TableExists("glpi_plugin_customfields_fields")) { $query = "ALTER TABLE `glpi_plugin_customfields_fields`\n CHANGE `ID` `id` int(11) NOT NULL auto_increment,\n CHANGE `device_type` `itemtype` VARCHAR(100) NOT NULL\n default ''"; $DB->query($query) or die($DB->error()); $tables = array('glpi_plugin_customfields_fields'); Plugin::migrateItemType(array(-1 => 'Version'), array(), $tables); } if (TableExists("glpi_plugin_customfields_profiledata")) { $query = "RENAME TABLE `glpi_plugin_customfields_profiledata` \n TO `glpi_plugin_customfields_profiles`"; $DB->query($query) or die($DB->error()); $query = "ALTER TABLE `glpi_plugin_customfields_profiles`\n CHANGE `ID` `id` int(11) NOT NULL auto_increment"; $DB->query($query) or die($DB->error()); } }
function plugin_archires_install() { global $DB; include_once GLPI_ROOT . "/plugins/archires/inc/profile.class.php"; $update = false; if (!TableExists("glpi_plugin_archires_config") && !TableExists("glpi_plugin_archires_views")) { $DB->runFile(GLPI_ROOT . "/plugins/archires/sql/empty-2.1.0.sql"); } else { $update = true; // update to 1.3 if (TableExists("glpi_plugin_archires_display") && !FieldExists("glpi_plugin_archires_display", "display_ports")) { $migration = new Migration(13); $migration->addField("glpi_plugin_archires_display", "display_ports", "ENUM('1', '0') NOT NULL DEFAULT '0'"); $migration->executeMigration(); } // update to 1.4 if (TableExists("glpi_plugin_archires_display") && !TableExists("glpi_plugin_archires_profiles")) { plugin_archires_updateTo14(); } // update to 1.5 if (TableExists("glpi_plugin_archires_display") && !TableExists("glpi_plugin_archires_image_device")) { plugin_archires_updateTo15(); } // update to 1.7.0 if (TableExists("glpi_plugin_archires_profiles") && FieldExists("glpi_plugin_archires_profiles", "interface")) { plugin_archires_updateTo170(); } // update to 1.7.2 if (TableExists("glpi_plugin_archires_config") && FieldExists("glpi_plugin_archires_config", "system")) { $migration = new Migration(172); $migration->dropField("glpi_plugin_archires_config", "system"); $migration->executeMigration(); } // update to 1.8.0 if (!TableExists("glpi_plugin_archires_views")) { plugin_archires_updateTo180(); } // update to 2.1.0 if (TableExists("glpi_plugin_archires_appliancequeries") && !FieldExists("glpi_plugin_archires_appliancequeries", "plugin_appliances_appliances_id")) { plugin_archires_updateTo210(); } } if ($update) { $table = "glpi_plugin_archires_statecolors"; $index = "state"; if (isIndex($table, $index)) { $query = "ALTER TABLE `{$table}` DROP INDEX `{$index}`;"; $result = $DB->query($query); } $query_ = "SELECT *\n FROM `glpi_plugin_archires_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_archires_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } if (FieldExists("glpi_plugin_archires_profiles", "name")) { $query = "ALTER TABLE `glpi_plugin_archires_profiles`\n DROP `name`"; } $result = $DB->query($query); Plugin::migrateItemType(array(3000 => 'PluginArchiresLocationQuery', 3001 => 'PluginArchiresNetworkEquipmentQuery', 3002 => 'PluginArchiresApplianceQuery', 3003 => 'PluginArchiresView'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_archires_querytypes", "glpi_plugin_archires_imageitems")); } $rep_files_archires = realpath(GLPI_PLUGIN_DOC_DIR) . "/archires"; if (!is_dir($rep_files_archires) && !mkdir($rep_files_archires)) { die(sprintf(__('Failed to create the directory %s. Verify that you have the correct permission'), $rep_files_archires)); } PluginArchiresProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function plugin_domains_install() { global $DB; include_once GLPI_ROOT . "/plugins/domains/inc/profile.class.php"; $install = false; $update78 = false; $update80 = false; if (!TableExists("glpi_plugin_domain") && !TableExists("glpi_plugin_domains_domains")) { $install = true; $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/empty-1.4.0.sql"); } else { if (TableExists("glpi_plugin_domain") && !FieldExists("glpi_plugin_domain", "recursive")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql"); } else { if (TableExists("glpi_plugin_domain_profiles") && FieldExists("glpi_plugin_domain_profiles", "interface")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql"); } else { if (TableExists("glpi_plugin_domain") && !FieldExists("glpi_plugin_domain", "helpdesk_visible")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql"); } else { if (!TableExists("glpi_plugin_domains_domains")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql"); } } } } } //from 1.3 version if (TableExists("glpi_plugin_domains_domains") && !FieldExists("glpi_plugin_domains_domains", "users_id_tech")) { $DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.5.0.sql"); } if ($install || $update78) { //Do One time on 0.78 $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginDomainsDomain' AND `name` = 'Alert Domains'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##domain.action## : ##domain.entity##',\n '##lang.domain.entity## :##domain.entity##\n ##FOREACHdomains##\n ##lang.domain.name## : ##domain.name## - ##lang.domain.dateexpiration## : ##domain.dateexpiration##\n ##ENDFOREACHdomains##',\n '<p>##lang.domain.entity## :##domain.entity##<br /> <br />\n ##FOREACHdomains##<br />\n ##lang.domain.name## : ##domain.name## - ##lang.domain.dateexpiration## : ##domain.dateexpiration##<br /> \n ##ENDFOREACHdomains##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Expired Domains', 0, 'PluginDomainsDomain', 'ExpiredDomains',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Domains Which Expire', 0, 'PluginDomainsDomain', 'DomainsWhichExpire',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); } if ($update78) { $query_ = "SELECT *\n FROM `glpi_plugin_domains_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_domains_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_domains_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(4400 => 'PluginDomainsDomain'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_domains_domains_items")); Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance", 1300 => "PluginWebapplicationsWebapplication"), array("glpi_plugin_domains_domains_items")); } CronTask::Register('PluginDomainsDomain', 'DomainsAlert', DAY_TIMESTAMP); PluginDomainsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function plugin_ideabox_install() { global $DB; include_once GLPI_ROOT . "/plugins/ideabox/inc/profile.class.php"; $install = false; $update78 = false; $update80 = false; if (!TableExists("glpi_plugin_ideabox_profiles") && !TableExists("glpi_plugin_ideabox_ideaboxes")) { $install = true; $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/empty-1.8.0.sql"); } else { if (TableExists("glpi_plugin_ideabox_mailing") && !FieldExists("glpi_plugin_ideabox", "begin_date")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.5.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.1.sql"); } else { if (TableExists("glpi_plugin_ideabox_profiles") && FieldExists("glpi_plugin_ideabox_profiles", "interface")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.1.sql"); } else { if (!TableExists("glpi_plugin_ideabox_ideaboxs") && !FieldExists("glpi_plugin_ideabox_profiles", "profiles_id")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.1.sql"); } else { if (!TableExists("glpi_plugin_ideabox_ideaboxes")) { $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/ideabox/sql/update-1.7.1.sql"); } } } } } if ($install || $update78) { //Do One time on 0.78 $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginIdeaboxIdeabox' AND `name` = 'Idea'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.ideabox.title##',\n '##lang.ideabox.url## : ##ideabox.url##\n ##lang.ideabox.entity## : ##ideabox.entity##\n ##IFideabox.name####lang.ideabox.name## : ##ideabox.name##\n ##ENDIFideabox.name##\n ##IFideabox.comment####lang.ideabox.comment## : ##ideabox.comment##\n ##ENDIFideabox.comment##\n\n ##FOREACHupdates##----------\n ##lang.update.title##:\n ##IFupdate.name####lang.ideabox.name## : ##update.name####ENDIFupdate.name##\n ##IFupdate.comment##\n ##lang.ideabox.comment## : ##update.comment##\n ##ENDIFupdate.comment##\n ----------##ENDFOREACHupdates##\n\n ##lang.comment.title##\n ----------\n ##FOREACHcomments##\n ##IFcomment.name####lang.comment.name## : ##comment.name####ENDIFcomment.name##\n ##IFcomment.author####lang.comment.author## : ##comment.author####ENDIFcomment.author##\n ##IFcomment.datecomment####lang.comment.datecomment## : ##comment.datecomment####ENDIFcomment.datecomment##\n ##IFcomment.comment####lang.comment.comment## : ##comment.comment####ENDIFcomment.comment##\n -------\n ##ENDFOREACHcomments##',\n '<p><strong>##lang.ideabox.url##</strong> : <a href=\"##ideabox.url##\">##ideabox.url##</a><br /><br /><strong>##lang.ideabox.entity##</strong> : ##ideabox.entity##<br /> ##IFideabox.name##<strong>##lang.ideabox.name##</strong> : ##ideabox.name####ENDIFideabox.name##<br /><br /> ##IFideabox.comment##<strong>##lang.ideabox.comment##</strong> : ##ideabox.comment####ENDIFideabox.comment##<br /><br />##FOREACHupdates##----------<br /><strong>##lang.update.title## :</strong><br />##IFupdate.name##<strong>##lang.ideabox.name##</strong> : ##update.name####ENDIFupdate.name##<br />##IFupdate.comment##<br /><strong>##lang.ideabox.comment##</strong> : ##update.comment##<br />##ENDIFupdate.comment##<br />----------##ENDFOREACHupdates##<br /><br /><strong>##lang.comment.title## :</strong><br />----------<br />##FOREACHcomments####IFcomment.name##<strong>##lang.comment.name##</strong> : ##comment.name####ENDIFcomment.name##<br />##IFcomment.author##<strong>##lang.comment.author##</strong> : ##comment.author####ENDIFcomment.author##<br />##IFcomment.datecomment##<strong>##lang.comment.datecomment##</strong> : ##comment.datecomment####ENDIFcomment.datecomment##<br />##IFcomment.comment##<strong>##lang.comment.comment##</strong> : ##comment.comment####ENDIFcomment.comment##<br />----------<br />##ENDFOREACHcomments##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Idea', 0, 'PluginIdeaboxIdeabox', 'new',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Idea', 0, 'PluginIdeaboxIdeabox', 'update',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Idea', 0, 'PluginIdeaboxIdeabox', 'delete',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Idea Comment', 0, 'PluginIdeaboxIdeabox', 'newcomment',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Idea Comment', 0, 'PluginIdeaboxIdeabox', 'updatecomment',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Idea Comment', 0, 'PluginIdeaboxIdeabox', 'deletecomment',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); } if ($update78) { $query_ = "SELECT *\n FROM `glpi_plugin_ideabox_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_ideabox_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_ideabox_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(4900 => 'PluginIdeaboxIdeabox', 4901 => 'PluginIdeaboxIdeabox'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets")); } PluginIdeaboxProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function update110to120() { global $DB; echo "<strong>Update 1.1.0 to 1.2.0</strong><br/>"; if (FieldExists("glpi_plugin_projet_projets", "begin_date")) { $query = "ALTER TABLE `glpi_plugin_projet_projets` \n CHANGE `begin_date` `date_begin` date default NULL"; $DB->query($query); } if (FieldExists("glpi_plugin_projet_projets", "end_date")) { $query = "ALTER TABLE `glpi_plugin_projet_projets` \n CHANGE `end_date` `date_end` date default NULL"; $DB->query($query); } if (FieldExists("glpi_plugin_projet_projets", "notes")) { $query = "ALTER TABLE `glpi_plugin_projet_projets` \n CHANGE `notes` `notepad` longtext collate utf8_unicode_ci"; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_projets", "is_helpdesk_visible")) { $query = "ALTER TABLE `glpi_plugin_projet_projets` \n ADD `is_helpdesk_visible` int(11) NOT NULL default '1'"; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_projets", "date_mod")) { $query = "ALTER TABLE `glpi_plugin_projet_projets` \n ADD `date_mod` datetime default NULL"; $DB->query($query); } if (FieldExists("glpi_plugin_projet_projets", "show_export")) { $query = "ALTER TABLE `glpi_plugin_projet_projets` \n DROP `show_export`"; $DB->query($query); } if (TableExists("glpi_plugin_projet_projets")) { $query = "ALTER TABLE `glpi_plugin_projet_projets` \n ADD INDEX (`name`),\n ADD INDEX (`entities_id`),\n ADD INDEX (`users_id`),\n ADD INDEX (`groups_id`),\n ADD INDEX (`date_mod`),\n ADD INDEX (`is_helpdesk_visible`),\n ADD INDEX (`is_template`),\n ADD INDEX (`is_deleted`)"; $DB->query($query); } if (TableExists("glpi_plugin_projet_mailings")) { $query = "DROP TABLE `glpi_plugin_projet_mailings`"; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_projetstates", "color")) { $query = "ALTER TABLE `glpi_plugin_projet_projetstates` \n ADD `color` char(20) COLLATE utf8_unicode_ci DEFAULT '#CCCCCC'"; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_projetstates", "type")) { $query = "ALTER TABLE `glpi_plugin_projet_projetstates` \n ADD `type` tinyint(1) NOT NULL default '0'"; $DB->query($query); } if (TableExists("glpi_plugin_projet_projetitems")) { $query = "RENAME TABLE `glpi_plugin_projet_projetitems` TO `glpi_plugin_projet_projets_items` "; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_tasks", "entities_id")) { $query = "ALTER TABLE `glpi_plugin_projet_tasks` \n ADD `entities_id` int(11) NOT NULL default '0'"; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_tasks", "is_recursive")) { $query = "ALTER TABLE `glpi_plugin_projet_tasks` \n ADD `is_recursive` tinyint(1) NOT NULL default '0'"; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_tasks", "contacts_id")) { $query = "ALTER TABLE `glpi_plugin_projet_tasks` \n CHANGE `suppliers_id` `contacts_id` int(11) NOT NULL default '0';"; $DB->query($query); } if (FieldExists("glpi_plugin_projet_tasks", "begin_date")) { $query = "ALTER TABLE `glpi_plugin_projet_tasks` \n CHANGE `begin_date` `date_begin` datetime default NULL"; $DB->query($query); } if (FieldExists("glpi_plugin_projet_tasks", "end_date")) { $query = "ALTER TABLE `glpi_plugin_projet_tasks` \n CHANGE `end_date` `date_end` datetime default NULL"; $DB->query($query); } if (FieldExists("glpi_plugin_projet_tasks", "contents")) { $query = "ALTER TABLE `glpi_plugin_projet_tasks` \n CHANGE `contents` `comment` text collate utf8_unicode_ci"; $DB->query($query); } if (FieldExists("glpi_plugin_projet_tasks", "use_planning")) { $query = "ALTER TABLE `glpi_plugin_projet_tasks` \n DROP `use_planning`"; $DB->query($query); } if (FieldExists("glpi_plugin_projet_tasks", "show_export")) { $query = "ALTER TABLE `glpi_plugin_projet_tasks` \n DROP `show_export`"; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_tasks", "date_mod")) { $query = "ALTER TABLE `glpi_plugin_projet_tasks` \n ADD `date_mod` datetime default NULL"; $DB->query($query); } if (TableExists("glpi_plugin_projet_tasks")) { $query = "ALTER TABLE `glpi_plugin_projet_tasks` \n ADD INDEX (`name`),\n ADD INDEX (`entities_id`),\n ADD INDEX (`users_id`),\n ADD INDEX (`groups_id`),\n ADD INDEX (`locations_id`),\n ADD INDEX (`plugin_projet_tasktypes_id`),\n ADD INDEX (`is_template`),\n ADD INDEX (`is_deleted`)"; $DB->query($query); } if (!TableExists("glpi_plugin_projet_taskplannings")) { $query = "CREATE TABLE `glpi_plugin_projet_taskplannings` (\n `id` int(11) NOT NULL auto_increment,\n `plugin_projet_tasks_id` int(11) NOT NULL default '0'COMMENT 'RELATION to glpi_plugin_projet_tasks (id)',\n `begin` datetime default NULL,\n `end` datetime default NULL,\n PRIMARY KEY (`id`),\n KEY `begin` (`begin`),\n KEY `end` (`end`),\n KEY `plugin_projet_tasks_id` (`plugin_projet_tasks_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query); } if (TableExists("glpi_plugin_projet_taskitems")) { $query = "RENAME TABLE `glpi_plugin_projet_taskitems` TO `glpi_plugin_projet_tasks_items` "; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_taskstates", "color")) { $query = "ALTER TABLE `glpi_plugin_projet_taskstates` \n ADD `color` char(20) COLLATE utf8_unicode_ci DEFAULT '#CCCCCC'"; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_taskstates", "for_dependency")) { $query = "ALTER TABLE `glpi_plugin_projet_taskstates` \n ADD `for_dependency` tinyint(1) NOT NULL default '0'"; $DB->query($query); } if (!FieldExists("glpi_plugin_projet_taskstates", "for_planning")) { $query = "ALTER TABLE `glpi_plugin_projet_taskstates` \n ADD `for_planning` tinyint(1) NOT NULL default '0'"; $DB->query($query); } // ** Update glpi_plugin_projet_profiles if (!FieldExists("glpi_plugin_projet_profiles", "profiles_id")) { $query = "ALTER TABLE `glpi_plugin_projet_profiles` \n ADD `profiles_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n ADD INDEX (`profiles_id`);"; $DB->query($query); } //Clean profiles $query_ = "SELECT *\n FROM `glpi_plugin_projet_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_projet_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_projet_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(2300 => 'PluginProjetProjet', 2301 => 'PluginProjetTask'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_projet_projets_items", "glpi_plugin_projet_tasks_items")); Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance"), array("glpi_plugin_projet_projets_items", "glpi_plugin_projet_tasks_items")); // ADD entities to tasks $PluginProjetTask = new PluginProjetTask(); $tasks = getAllDatasFromTable("glpi_plugin_projet_tasks"); if (!empty($tasks)) { foreach ($tasks as $task) { $restrict = "`id` = '" . $task["plugin_projet_projets_id"] . "'"; $projets = getAllDatasFromTable("glpi_plugin_projet_projets", $restrict); if (!empty($projets)) { foreach ($projets as $projet) { $input["entities_id"] = $projet["entities_id"]; } } $query = "UPDATE `glpi_plugin_projet_tasks` SET `entities_id` = '" . $input["entities_id"] . "' \n WHERE `glpi_plugin_projet_tasks`.`id` ='" . $task["id"] . "';"; $result = $DB->query($query); } } // ADD plannings for tasks $PluginProjetTask = new PluginProjetTask(); $PluginProjetTaskPlanning = new PluginProjetTaskPlanning(); $restrict = "`date_begin` IS NOT NULL"; $tasks = getAllDatasFromTable("glpi_plugin_projet_tasks", $restrict); if (!empty($tasks)) { foreach ($tasks as $task) { $query = "INSERT INTO `glpi_plugin_projet_taskplannings` (\n `id` ,\n `plugin_projet_tasks_id` ,\n `begin` ,\n `end`\n )\n VALUES (\n NULL , '" . $task["id"] . "', '" . $task["date_begin"] . "', '" . $task["date_end"] . "');"; $result = $DB->query($query); unset($input); } } $query = "ALTER TABLE `glpi_plugin_projet_tasks`\n DROP `date_begin`, DROP `date_end` ;"; $result = $DB->query($query); //Do One time on 0.80 $query = "INSERT INTO `glpi_notificationtemplates` VALUES(NULL, 'Projets', 'PluginProjetProjet', '2010-12-29 11:04:46','',NULL);"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notificationtemplates` VALUES(NULL, 'Alert Projets Tasks', 'PluginProjetProjet', '2010-12-29 11:04:46','',NULL);"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginProjetProjet' AND `name` = 'Projets'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.projet.title## - ##projet.name##',\n '##lang.projet.url## : ##projet.url##\n\n##lang.projet.entity## : ##projet.entity##\n##IFprojet.name####lang.projet.name## : ##projet.name####ENDIFprojet.name##\n##IFprojet.datebegin####lang.projet.datebegin## : ##projet.datebegin####ENDIFprojet.datebegin##\n##IFprojet.dateend####lang.projet.dateend## : ##projet.dateend####ENDIFprojet.dateend##\n##IFprojet.users####lang.projet.users## : ##projet.users####ENDIFprojet.users##\n##IFprojet.groups####lang.projet.groups## : ##projet.groups####ENDIFprojet.groups##\n##IFprojet.status####lang.projet.status## : ##projet.status####ENDIFprojet.status##\n##IFprojet.parent####lang.projet.parent## : ##projet.parent####ENDIFprojet.parent##\n##IFprojet.advance####lang.projet.advance## : ##projet.advance####ENDIFprojet.advance##\n##IFprojet.comment## ##lang.projet.comment## : ##projet.comment####ENDIFprojet.comment##\n##IFprojet.description####lang.projet.description## : ##projet.description####ENDIFprojet.description##\n##IFprojet.helpdesk####lang.projet.helpdesk## : ##projet.helpdesk####ENDIFprojet.helpdesk##\n##FOREACHupdates##----------\n##lang.update.title## : \n##IFupdate.name####lang.projet.name## : ##update.name####ENDIFupdate.name##\n##IFupdate.datebegin####lang.projet.datebegin## : ##update.datebegin####ENDIFupdate.datebegin##\n##IFupdate.dateend####lang.projet.dateend## : ##update.dateend####ENDIFupdate.dateend##\n##IFupdate.users####lang.projet.users## : ##update.users####ENDIFupdate.users##\n##IFupdate.groups####lang.projet.groups## : ##update.groups####ENDIFupdate.groups##\n##IFupdate.status####lang.projet.status## : ##update.status####ENDIFupdate.status##\n##IFupdate.parent####lang.projet.parent## : ##update.parent####ENDIFupdate.parent##\n##IFupdate.advance####lang.projet.advance## : ##update.advance####ENDIFupdate.advance##\n##IFupdate.comment## ##lang.projet.comment## : ##update.comment####ENDIFupdate.comment##\n##IFupdate.description####lang.projet.description## : ##update.description####ENDIFupdate.description##\n##IFupdate.helpdesk####lang.projet.helpdesk## : ##update.helpdesk####ENDIFupdate.helpdesk##\n##ENDFOREACHupdates##----------\n##IFtask.title## ##lang.task.title####ENDIFtask.title##\n##FOREACHtasks##----------\n##IFtask.name####lang.task.name## : ##task.name####ENDIFtask.name##\n##IFtask.users####lang.task.users## : ##task.users####ENDIFtask.users##\n##IFtask.groups####lang.task.groups## : ##task.groups####ENDIFtask.groups##\n##IFtask.contacts## ##lang.task.contacts## : ##task.contacts####ENDIFtask.contacts##\n##IFtask.type####lang.task.type## : ##task.type####ENDIFtask.type##\n##IFtask.status####lang.task.status## : ##task.status####ENDIFtask.status##\n##IFtask.location####lang.task.location## : ##task.location####ENDIFtask.location##\n##IFtask.advance####lang.task.advance## : ##task.advance####ENDIFtask.advance##\n##IFtask.priority####lang.task.priority## : ##task.priority####ENDIFtask.priority##\n##IFtask.comment####lang.task.comment## : ##task.comment####ENDIFtask.comment##\n##IFtask.sub####lang.task.sub## : ##task.sub####ENDIFtask.sub##\n##IFtask.others####lang.task.others## : ##task.others####ENDIFtask.others##\n##IFtask.affect####lang.task.affect## : ##task.affect####ENDIFtask.affect##\n##IFtask.depends####lang.task.depends## : ##task.depends####ENDIFtask.depends##\n##IFtask.parenttask####lang.task.parenttask## : ##task.parenttask####ENDIFtask.parenttask##\n##IFtask.realtime####lang.task.realtime## : ##task.realtime## ##ENDIFtask.realtime##\n----------##ENDFOREACHtasks##',\n '<p><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.url##</strong> : <a href=\"##projet.url##\">##projet.url##</a></span> <br /><br /> <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.entity##</strong> : ##projet.entity##</span> <br /> ##IFprojet.name##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.name##</strong> : ##projet.name##<br /></span>##ENDIFprojet.name## ##IFprojet.datebegin##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.datebegin##</strong> : ##projet.datebegin##<br /></span>##ENDIFprojet.datebegin## ##IFprojet.dateend##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.dateend##</strong> : ##projet.dateend##<br /></span>##ENDIFprojet.dateend## ##IFprojet.users##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.users##</strong> : ##projet.users##<br /></span>##ENDIFprojet.users## ##IFprojet.groups##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.groups##</strong> : ##projet.groups##<br /></span>##ENDIFprojet.groups## ##IFprojet.status##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.status##</strong> : ##projet.status##<br /></span>##ENDIFprojet.status## ##IFprojet.parent##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.parent##</strong> : ##projet.parent##<br /></span>##ENDIFprojet.parent## ##IFprojet.advance##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.advance##</strong> : ##projet.advance##<br /></span>##ENDIFprojet.advance## ##IFprojet.comment##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.comment##</strong> : ##projet.comment##<br /></span>##ENDIFprojet.comment## ##IFprojet.description##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.description##</strong> : ##projet.description##<br /></span>##ENDIFprojet.description## ##IFprojet.helpdesk##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.helpdesk##</strong> : ##projet.helpdesk##<br /></span>##ENDIFprojet.helpdesk## ##FOREACHupdates##----------<br /><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.update.title## :</strong></span> <br /> ##IFupdate.name##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.name##</strong> : ##update.name##<br /></span>##ENDIFupdate.name## ##IFupdate.datebegin##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.datebegin##</strong> : ##update.datebegin##<br /></span>##ENDIFupdate.datebegin## ##IFupdate.dateend##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.dateend##</strong> : ##update.dateend##<br /></span>##ENDIFupdate.dateend## ##IFupdate.users##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.users##</strong> : ##update.users##<br /></span>##ENDIFupdate.users## ##IFupdate.groups##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.groups##</strong> : ##update.groups##<br /></span>##ENDIFupdate.groups## ##IFupdate.status##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.status##</strong> : ##update.status##<br /></span>##ENDIFupdate.status## ##IFupdate.parent##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.parent##</strong> : ##update.parent##<br /></span>##ENDIFupdate.parent## ##IFupdate.advance##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.advance##</strong> : ##update.advance##<br /></span>##ENDIFupdate.advance## ##IFupdate.comment##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.comment##</strong> : ##update.comment##<br /></span>##ENDIFupdate.comment## ##IFupdate.description##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.description##</strong> : ##update.description##<br /></span>##ENDIFupdate.description## ##IFupdate.helpdesk##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.projet.helpdesk##</strong> : ##update.helpdesk##<br /></span>##ENDIFupdate.helpdesk## ##ENDFOREACHupdates##----------<br /> ##IFtask.title##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.title##</strong></span><br />##ENDIFtask.title## ##FOREACHtasks##----------<br /> ##IFtask.name##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.name##</strong> : ##task.name##<br /></span>##ENDIFtask.name## ##IFtask.users##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.users##</strong> : ##task.users##<br /></span>##ENDIFtask.users## ##IFtask.groups##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.groups##</strong> : ##task.groups##<br /></span>##ENDIFtask.groups## ##IFtask.contacts##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.contacts##</strong> : ##task.contacts##<br /></span>##ENDIFtask.contacts## ##IFtask.type##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.type##</strong> : ##task.type##<br /></span>##ENDIFtask.type## ##IFtask.status##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.status##</strong> : ##task.status##<br /></span>##ENDIFtask.status## ##IFtask.location##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.location##</strong> : ##task.location##<br /></span>##ENDIFtask.location## ##IFtask.advance##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.advance##</strong> : ##task.advance##<br /></span>##ENDIFtask.advance## ##IFtask.priority##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.priority##</strong> : ##task.priority##<br /></span>##ENDIFtask.priority## ##IFtask.comment##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.comment##</strong> : ##task.comment##<br /></span>##ENDIFtask.comment## ##IFtask.sub##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.sub##</strong> : ##task.sub##<br /></span>##ENDIFtask.sub## ##IFtask.others##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.others##</strong> : ##task.others##<br /></span>##ENDIFtask.others## ##IFtask.affect##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.affect##</strong> : ##task.affect##<br /></span>##ENDIFtask.affect## ##IFtask.depends##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.depends##</strong> : ##task.depends##<br /></span>##ENDIFtask.depends## ##IFtask.parenttask##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.parenttask##</strong> : ##task.parenttask##<br /></span>##ENDIFtask.parenttask## ##IFtask.realtime##<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.task.realtime##</strong> : ##task.realtime##</span>##ENDIFtask.realtime## <br />----------##ENDFOREACHtasks##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Project', 0, 'PluginProjetProjet', 'new',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Project', 0, 'PluginProjetProjet', 'update',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Project', 0, 'PluginProjetProjet', 'delete',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Project Task', 0, 'PluginProjetProjet', 'newtask',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Project Task', 0, 'PluginProjetProjet', 'updatetask',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Project Task', 0, 'PluginProjetProjet', 'deletetask',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginProjetProjet' AND `name` = 'Alert Projets Tasks'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##projet.action## : ##projet.entity##',\n '##FOREACHtasks## \n ##lang.task.name## : ##task.name##\n ##lang.task.type## : ##task.type##\n ##lang.task.users## : ##task.users##\n ##lang.task.groups## : ##task.groups##\n ##lang.task.datebegin## : ##task.datebegin##\n ##lang.task.dateend## : ##task.dateend##\n ##lang.task.comment## : ##task.comment##\n ##lang.task.projet## : ##task.projet##\n ##ENDFOREACHtasks##',\n '<table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\">\n <tbody>\n <tr>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.name##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.type##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.users##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.groups##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.datebegin##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.dateend##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.comment##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.projet##</span></td>\n </tr>\n ##FOREACHtasks## \n <tr>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.name##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.type##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.users##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.groups##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.datebegin##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.dateend##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.comment##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.projet##</span></td>\n </tr>\n ##ENDFOREACHtasks##\n </tbody>\n </table>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Expired Projects Tasks', 0, 'PluginProjetProjet', 'AlertExpiredTasks',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); CronTask::Register('PluginProjetTask', 'ProjetTask', WEEK_TIMESTAMP); }
public static function install(Migration $migration) { global $DB; $table = getTableForItemType(__CLASS__); if (!TableExists($table) && !TableExists("glpi_plugin_order_detail")) { $migration->displayMessage("Installing {$table}"); //install $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `plugin_order_orders_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)',\n `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file',\n `items_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)',\n `plugin_order_references_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_references (id)',\n `plugin_order_deliverystates_id` int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_deliverystates (id)',\n `plugin_order_ordertaxes_id` float NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertaxes (id)',\n `delivery_number` varchar(255) collate utf8_unicode_ci default NULL,\n `delivery_comment` text collate utf8_unicode_ci,\n `price_taxfree` decimal(20,6) NOT NULL DEFAULT '0.000000',\n `price_discounted` decimal(20,6) NOT NULL DEFAULT '0.000000',\n `discount` decimal(20,6) NOT NULL DEFAULT '0.000000',\n `price_ati` decimal(20,6) NOT NULL DEFAULT '0.000000',\n `states_id` int(11) NOT NULL default 1,\n `delivery_date` date default NULL,\n `plugin_order_bills_id` INT( 11 ) NOT NULL DEFAULT '0',\n `plugin_order_billstates_id` INT( 11 ) NOT NULL DEFAULT '0',\n `comment` text collate utf8_unicode_ci,\n PRIMARY KEY (`id`),\n KEY `FK_device` (`items_id`,`itemtype`),\n KEY `entities_id` (`entities_id`),\n KEY `item` (`itemtype`,`items_id`),\n KEY `plugin_order_references_id` (`plugin_order_references_id`),\n KEY `plugin_order_deliverystates_id` (`plugin_order_deliverystates_id`),\n KEY `states_id` (`states_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die($DB->error()); } else { //Upgrade $migration->displayMessage("Upgrading {$table}"); //1.1.2 if (TableExists("glpi_plugin_order_detail")) { $migration->addField("glpi_plugin_order_detail", "delivery_status", "int(1) NOT NULL default '0'"); $migration->addField("glpi_plugin_order_detail", "delivery_comments", "TEXT"); $migration->migrationOneTable("glpi_plugin_order_detail"); } //1.2.0 $migration->renameTable("glpi_plugin_order_detail", $table); $migration->changeField($table, "ID", "id", "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($table, "FK_order", "plugin_order_orders_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)'"); $migration->changeField($table, "device_type", "itemtype", "varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file'"); $migration->changeField($table, "FK_device", "items_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)'"); $migration->changeField($table, "FK_reference", "plugin_order_references_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_references (id)'"); $migration->changeField($table, "delivery_status", "plugin_order_deliverystates_id", "int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_deliverystates (id)'"); $migration->changeField($table, "deliverynum", "delivery_number", "varchar(255) collate utf8_unicode_ci default NULL"); $migration->changeField($table, "delivery_comments", "delivery_comment", "text collate utf8_unicode_ci"); $migration->changeField($table, "status", "states_id", "int(11) NOT NULL default 1"); $migration->changeField($table, "date", "delivery_date", "date default NULL"); $migration->addKey($table, array("items_id", "itemtype"), "FK_device"); $migration->addKey($table, array("itemtype", "items_id"), "item"); $migration->addKey($table, "plugin_order_references_id"); $migration->addKey($table, "plugin_order_deliverystates_id"); $migration->addKey($table, "states_id"); $migration->migrationOneTable($table); Plugin::migrateItemType(array(), array(), array($table)); //1.4.0 $migration->addField($table, "plugin_order_ordertaxes_id", "INT (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertaxes (id)'"); $migration->migrationOneTable($table); /* Migrate VAT */ foreach ($DB->request("glpi_plugin_order_orders") as $data) { $query = "UPDATE `glpi_plugin_order_orders_items`\n SET `plugin_order_ordertaxes_id` = '" . $data["plugin_order_ordertaxes_id"] . "'\n WHERE `plugin_order_orders_id` = '" . $data["id"] . "'"; $result = $DB->query($query) or die($DB->error()); } //1.5.0 $migration->addField($table, "entities_id", "INT( 11 ) NOT NULL DEFAULT '0'"); $migration->addField($table, "is_recursive", "TINYINT( 1 ) NOT NULL DEFAULT '0'"); $migration->addField($table, "plugin_order_bills_id", "INT( 11 ) NOT NULL DEFAULT '0'"); $migration->addField($table, "plugin_order_billstates_id", "INT( 11 ) NOT NULL DEFAULT '0'"); $migration->addKey($table, "entities_id"); $migration->addKey($table, "plugin_order_bills_id"); $migration->addKey($table, "plugin_order_billstates_id"); $migration->addField($table, "comment", "text collate utf8_unicode_ci"); $migration->migrationOneTable($table); //Change format for prices : from float to decimal $migration->changeField($table, "price_taxfree", "price_taxfree", "decimal(20,6) NOT NULL DEFAULT '0.000000'"); $migration->changeField($table, "price_discounted", "price_discounted", "decimal(20,6) NOT NULL DEFAULT '0.000000'"); $migration->changeField($table, "price_ati", "price_ati", "decimal(20,6) NOT NULL DEFAULT '0.000000'"); $migration->changeField($table, "discount", "discount", "decimal(20,6) NOT NULL DEFAULT '0.000000'"); //Drop unused fields from previous migration $migration->dropField($table, "price_taxfree2"); $migration->dropField($table, "price_discounted2"); $migration->migrationOneTable($table); //Forward entities_id and is_recursive into table glpi_plugin_order_orders_items $query = "SELECT `go`.`entities_id` as entities_id ,\n `go`.`is_recursive` as is_recursive, `goi`.`id` as items_id\n FROM `glpi_plugin_order_orders` as go, `{$table}` as `goi`\n WHERE `goi`.`plugin_order_orders_id`=`go`.`id`"; foreach ($DB->request($query) as $data) { $update = "UPDATE `{$table}`\n SET `entities_id`='" . $data['entities_id'] . "'\n AND `is_recursive`='" . $data['is_recursive'] . "'\n WHERE `id`='" . $data['items_id'] . "'"; $DB->query($update) or die($DB->error()); } $migration->executeMigration(); } }
function plugin_badges_install() { global $DB; include_once GLPI_ROOT . "/plugins/badges/inc/profile.class.php"; $install = false; $update78 = false; $update80 = false; if (!TableExists("glpi_plugin_badges") && !TableExists("glpi_plugin_badges_badgetypes")) { $install = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/empty-1.7.0.sql"); } else { if (TableExists("glpi_plugin_badges_users") && !TableExists("glpi_plugin_badges_default")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.4.sql"); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.0.sql"); plugin_badges_configure15(); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql"); } else { if (TableExists("glpi_plugin_badges_profiles") && FieldExists("glpi_plugin_badges_profiles", "interface")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.0.sql"); plugin_badges_configure15(); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql"); } else { if (TableExists("glpi_plugin_badges") && !FieldExists("glpi_plugin_badges", "date_mod")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql"); } else { if (!TableExists("glpi_plugin_badges_badgetypes")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql"); } } } } } if ($install || $update78) { //Do One time on 0.78 $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Alert Badges'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##badge.action## : ##badge.entity##',\n '##lang.badge.entity## :##badge.entity##\n ##FOREACHbadges##\n ##lang.badge.name## : ##badge.name## - ##lang.badge.dateexpiration## : ##badge.dateexpiration####IFbadge.serial## - ##lang.badge.serial## : ##badge.serial####ENDIFbadge.serial####IFbadge.users## - ##lang.badge.users## : ##badge.users####ENDIFbadge.users##\n ##ENDFOREACHbadges##',\n '<p>##lang.badge.entity## :##badge.entity##<br /> <br />\n ##FOREACHbadges##<br />\n ##lang.badge.name## : ##badge.name## - ##lang.badge.dateexpiration## : ##badge.dateexpiration####IFbadge.serial## - ##lang.badge.serial## : ##badge.serial####ENDIFbadge.serial####IFbadge.users## - ##lang.badge.users## : ##badge.users####ENDIFbadge.users##<br /> \n ##ENDFOREACHbadges##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Expired Badges', 0, 'PluginBadgesBadge', 'ExpiredBadges',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Badges Which Expire', 0, 'PluginBadgesBadge', 'BadgesWhichExpire',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); } if ($update78) { $query_ = "SELECT *\n FROM `glpi_plugin_badges_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_badges_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_badges_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(1600 => 'PluginBadgesBadge'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets")); } CronTask::Register('PluginBadgesBadge', 'BadgesAlert', DAY_TIMESTAMP); PluginBadgesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function plugin_appliances_install() { global $DB; if (TableExists("glpi_plugin_applicatifs_profiles")) { if (FieldExists("glpi_plugin_applicatifs_profiles", "create_applicatifs")) { // version <1.3 $DB->runFile(GLPI_ROOT . "/plugins/appliances/sql/update-1.3.sql"); } } if (TableExists("glpi_plugin_applicatifs")) { if (!FieldExists("glpi_plugin_applicatifs", "recursive")) { // version 1.3 $DB->runFile(GLPI_ROOT . "/plugins/appliances/sql/update-1.4.sql"); } if (!FieldExists("glpi_plugin_applicatifs", "FK_groups")) { // version 1.4 $DB->runFile(GLPI_ROOT . "/plugins/appliances/sql/update-1.5.0.sql"); } if (!FieldExists("glpi_plugin_applicatifs", "helpdesk_visible")) { // version 1.5.0 $DB->runFile(GLPI_ROOT . "/plugins/appliances/sql/update-1.5.1.sql"); } if (FieldExists("glpi_plugin_applicatifs", "state")) { // empty 1.5.0 not in update 1.5.0 $DB->query("ALTER TABLE `glpi_plugin_applicatifs` DROP `state`"); } if (isIndex("glpi_plugin_applicatifs_optvalues_machines", "optvalue_ID")) { // in empty 1.5.0 not in update 1.5.0 $DB->query("ALTER TABLE `glpi_plugin_applicatifs_optvalues_machines`\n DROP KEY `optvalue_ID`"); } $DB->runFile(GLPI_ROOT . "/plugins/appliances/sql/update-1.6.0.sql"); Plugin::migrateItemType(array(1200 => 'PluginAppliancesAppliance'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_appliances_appliances_items", "glpi_plugin_appliances_optvalues_items")); Plugin::migrateItemType(array(4450 => "PluginRacksRack"), array("glpi_plugin_appliances_appliances_items")); } if (!TableExists("glpi_plugin_appliances_appliances")) { // not installed $DB->runFile(GLPI_ROOT . '/plugins/appliances/sql/empty-1.8.0.sql'); } else { $migration = new Migration(180); include_once GLPI_ROOT . "/plugins/appliances/inc/appliance.class.php"; PluginAppliancesAppliance::updateSchema($migration); $migration->executeMigration(); } // required cause autoload don't work for unactive plugin' include_once GLPI_ROOT . "/plugins/appliances/inc/profile.class.php"; PluginAppliancesProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function plugin_datainjection_update170_20() { global $DB; $migration = new Migration('2.0'); $migration->changeField('glpi_plugin_datainjection_models', 'ID', 'id', 'autoincrement'); $migration->changeField('glpi_plugin_datainjection_models', 'type', 'filetype', 'string', array('value' => 'csv')); $migration->addField('glpi_plugin_datainjection_models', 'step', 'integer'); $migration->changeField('glpi_plugin_datainjection_models', 'comments', 'comment', 'text'); $migration->changeField('glpi_plugin_datainjection_models', 'device_type', 'itemtype', 'string', array('value' => '')); $migration->changeField('glpi_plugin_datainjection_models', 'FK_entities', 'entities_id', 'integer'); $migration->changeField('glpi_plugin_datainjection_models', 'private', 'is_private', 'bool'); $migration->changeField('glpi_plugin_datainjection_models', 'FK_users', 'users_id', 'integer'); $migration->changeField('glpi_plugin_datainjection_models', 'recursive', 'is_recursive', 'bool'); $migration->migrationOneTable('glpi_plugin_datainjection_models'); $query = "UPDATE `glpi_plugin_datainjection_models`\n SET `step` = '5'"; $DB->query($query); $query = "UPDATE `glpi_plugin_datainjection_models`\n SET `filetype` = 'csv'"; $DB->queryOrDie($query, "update filetype of glpi_plugin_datainjection_models"); $migration->dropTable('glpi_plugin_datainjection_filetype'); $migration->renameTable('glpi_plugin_datainjection_models_csv', 'glpi_plugin_datainjection_modelcsvs'); $migration->changeField('glpi_plugin_datainjection_modelcsvs', 'model_id', 'models_id', 'integer'); $migration->changeField('glpi_plugin_datainjection_modelcsvs', 'device_type', 'itemtype', 'string', array('value' => '')); $migration->changeField('glpi_plugin_datainjection_modelcsvs', 'header_present', 'is_header_present', 'bool', array('value' => 1)); $migration->changeField('glpi_plugin_datainjection_mappings', 'mandatory', 'is_mandatory', 'bool'); $migration->changeField('glpi_plugin_datainjection_mappings', 'type', 'itemtype', 'string', array('value' => '')); $migration->changeField('glpi_plugin_datainjection_mappings', 'model_id', 'models_id', 'integer'); $migration->changeField('glpi_plugin_datainjection_infos', 'type', 'itemtype', 'string', array('value' => '')); $migration->changeField('glpi_plugin_datainjection_infos', 'model_id', 'models_id', 'integer'); $migration->changeField('glpi_plugin_datainjection_infos', 'mandatory', 'is_mandatory', 'bool'); $glpitables = array('glpi_plugin_datainjection_models', 'glpi_plugin_datainjection_mappings', 'glpi_plugin_datainjection_infos', 'glpi_plugin_datainjection_modelcsvs', 'glpi_plugin_datainjection_profiles'); foreach ($glpitables as $table) { $migration->changeField($table, 'ID', 'id', 'autoincrement'); } $migration->migrationOneTable('glpi_plugin_datainjection_mappings'); $migration->migrationOneTable('glpi_plugin_datainjection_infos'); $migration->migrationOneTable('glpi_plugin_datainjection_modelcsvs'); $glpitables = array('glpi_plugin_datainjection_models', 'glpi_plugin_datainjection_mappings', 'glpi_plugin_datainjection_infos', 'glpi_plugin_datainjection_modelcsvs'); Plugin::migrateItemType(array(), array(), $glpitables); $query = "UPDATE `glpi_plugin_datainjection_mappings`\n SET `itemtype` = 'none' ,\n `value`='none'\n WHERE `itemtype` = '-1'"; $DB->queryOrDie($query, "Datainjection mappings tables : error updating not mapped fields"); $migration->migrationOneTable('glpi_plugin_datainjection_infos'); $query = "UPDATE `glpi_plugin_datainjection_infos`\n SET `itemtype` = 'none', `value` = 'none'\n WHERE `itemtype` = '-1'"; $DB->queryOrDie($query, "Datainjection infos table : error updating not mapped fields"); $foreignkeys = array('assign' => array(array('to' => 'users_id_assign', 'tables' => array('glpi_tickets'))), 'assign_group' => array(array('to' => 'groups_id_assign', 'tables' => array('glpi_tickets'))), 'assign_ent' => array(array('to' => 'suppliers_id_assign', 'tables' => array('glpi_tickets'))), 'auth_method' => array(array('to' => 'authtype', 'noindex' => array('glpi_users'), 'tables' => array('glpi_users'))), 'author' => array(array('to' => 'users_id', 'tables' => array('glpi_ticketfollowups', 'glpi_knowbaseitems', 'glpi_tickets'))), 'auto_update' => array(array('to' => 'autoupdatesystems_id', 'tables' => array('glpi_computers'))), 'budget' => array(array('to' => 'budgets_id', 'tables' => array('glpi_infocoms'))), 'buy_version' => array(array('to' => 'softwareversions_id_buy', 'tables' => array('glpi_softwarelicenses'))), 'category' => array(array('to' => 'ticketcategories_id', 'tables' => array('glpi_tickets')), array('to' => 'softwarecategories_id', 'tables' => array('glpi_softwares'))), 'categoryID' => array(array('to' => 'knowbaseitemcategories_id', 'tables' => array('glpi_knowbaseitems'))), 'cID' => array(array('to' => 'computers_id', 'tables' => array('glpi_computers_softwareversions'))), 'computer' => array(array('to' => 'items_id', 'tables' => array('glpi_tickets'))), 'computer_id' => array(array('to' => 'computers_id', 'tables' => array('glpi_registrykeys'))), 'contract_type' => array(array('to' => 'contracttypes_id', 'tables' => array('glpi_contracts'))), 'default_rubdoc_tracking' => array(array('to' => 'documentcategories_id_forticket', 'tables' => array('glpi_configs'), 'comments' => array('glpi_configs' => 'default category for documents added with a ticket'))), 'device_type' => array(array('to' => 'itemtype', 'tables' => array('glpi_alerts', 'glpi_contracts_items', 'glpi_documents_items', 'glpi_infocoms', 'glpi_bookmarks', 'glpi_bookmarks_users', 'glpi_links_itemtypes', 'glpi_networkports', 'glpi_reservationitems', 'glpi_tickets'))), 'domain' => array(array('to' => 'domains_id', 'tables' => array('glpi_computers', 'glpi_networkequipments', 'glpi_printers'))), 'end1' => array(array('to' => 'items_id', 'tables' => array('glpi_computers_items'), 'comments' => array('glpi_computers_items' => 'RELATION to various table, according to itemtype (ID)')), array('to' => 'networkports_id_1', 'tables' => array('glpi_networkports_networkports'))), 'end2' => array(array('to' => 'computers_id', 'tables' => array('glpi_computers_items')), array('to' => 'networkports_id_2', 'tables' => array('glpi_networkports_networkports'))), 'firmware' => array(array('to' => 'networkequipmentfirmwares_id', 'tables' => array('glpi_networkequipments'))), 'FK_bookmark' => array(array('to' => 'bookmarks_id', 'tables' => array('glpi_bookmarks_users'))), 'FK_computers' => array(array('to' => 'computers_id', 'tables' => array('glpi_computerdisks', 'glpi_softwarelicenses'))), 'FK_contact' => array(array('to' => 'contacts_id', 'tables' => array('glpi_contacts_suppliers'))), 'FK_contract' => array(array('to' => 'contracts_id', 'tables' => array('glpi_contracts_suppliers', 'glpi_contracts_items'))), 'FK_device' => array(array('to' => 'items_id', 'tables' => array('glpi_alerts', 'glpi_contracts_items', 'glpi_documents_items', 'glpi_infocoms'))), 'FK_doc' => array(array('to' => 'documents_id', 'tables' => array('glpi_documents_items'))), 'manufacturer' => array(array('to' => 'suppliers_id', 'tables' => array('glpi_contacts_suppliers', 'glpi_contracts_suppliers', 'glpi_infocoms')), array('to' => 'manufacturers_id', 'tables' => array('glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', 'glpi_devicecases', 'glpi_devicecontrols', 'glpi_devicedrives', 'glpi_devicegraphiccards', 'glpi_deviceharddrives', 'glpi_devicenetworkcards', 'glpi_devicemotherboards', 'glpi_devicepcis', 'glpi_devicepowersupplies', 'glpi_deviceprocessors', 'glpi_devicememories', 'glpi_devicesoundcards', 'glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwares'))), 'FK_entities' => array(array('to' => 'entities_id', 'tables' => array('glpi_bookmarks', 'glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', 'glpi_contacts', 'glpi_contracts', 'glpi_documents', 'glpi_locations', 'glpi_netpoints', 'glpi_suppliers', 'glpi_entitydatas', 'glpi_groups', 'glpi_knowbaseitems', 'glpi_links', 'glpi_mailcollectors', 'glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_reminders', 'glpi_rules', 'glpi_softwares', 'glpi_softwarelicenses', 'glpi_softwareversions', 'glpi_tickets', 'glpi_users', 'glpi_profiles_users'), 'default' => array('glpi_bookmarks' => "-1"))), 'FK_filesystems' => array(array('to' => 'filesystems_id', 'tables' => array('glpi_computerdisks'))), 'FK_glpi_cartridges_type' => array(array('to' => 'cartridgeitems_id', 'tables' => array('glpi_cartridges', 'glpi_cartridges_printermodels'))), 'FK_glpi_consumables_type' => array(array('to' => 'consumableitems_id', 'tables' => array('glpi_consumables'))), 'FK_glpi_dropdown_model_printers' => array(array('to' => 'printermodels_id', 'tables' => array('glpi_cartridges_printermodels'))), 'FK_glpi_printers' => array(array('to' => 'printers_id', 'tables' => array('glpi_cartridges'))), 'FK_group' => array(array('to' => 'groups_id', 'tables' => array('glpi_tickets'))), 'FK_groups' => array(array('to' => 'groups_id', 'tables' => array('glpi_computers', 'glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwares', 'glpi_groups_users'))), 'FK_interface' => array(array('to' => 'interfacetypes_id', 'tables' => array('glpi_devicegraphiccards'))), 'FK_item' => array(array('to' => 'items_id', 'tables' => array('glpi_mailingsettings'))), 'FK_links' => array(array('to' => 'links_id', 'tables' => array('glpi_links_itemtypes'))), 'FK_port' => array(array('to' => 'networkports_id', 'tables' => array('glpi_networkports_vlans'))), 'FK_profiles' => array(array('to' => 'profiles_id', 'tables' => array('glpi_profiles_users', 'glpi_users'))), 'FK_users' => array(array('to' => 'users_id', 'tables' => array('glpi_bookmarks', 'glpi_displaypreferences', 'glpi_documents', 'glpi_groups', 'glpi_reminders', 'glpi_bookmarks_users', 'glpi_groups_users', 'glpi_profiles_users', 'glpi_computers', 'glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwares'))), 'FK_vlan' => array(array('to' => 'vlans_id', 'tables' => array('glpi_networkports_vlans'))), 'glpi_id' => array(array('to' => 'computers_id', 'tables' => array('glpi_ocslinks'))), 'id_assign' => array(array('to' => 'users_id', 'tables' => array('glpi_ticketplannings'))), 'id_auth' => array(array('to' => 'auths_id', 'tables' => array('glpi_users'))), 'id_device' => array(array('to' => 'items_id', 'tables' => array('glpi_reservationitems'))), 'id_item' => array(array('to' => 'reservationitems_id', 'tables' => array('glpi_reservations'))), 'id_user' => array(array('to' => 'users_id', 'tables' => array('glpi_consumables', 'glpi_reservations'))), 'iface' => array(array('to' => 'networkinterfaces_id', 'tables' => array('glpi_networkports'))), 'interface' => array(array('to' => 'interfacetypes_id', 'tables' => array('glpi_devicecontrols', 'glpi_deviceharddrives', 'glpi_devicedrives'))), 'location' => array(array('to' => 'locations_id', 'tables' => array('glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', 'glpi_netpoints', 'glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_users', 'glpi_softwares'))), 'model' => array(array('to' => 'computermodels_id', 'tables' => array('glpi_computers')), array('to' => 'monitormodels_id', 'tables' => array('glpi_monitors')), array('to' => 'networkequipmentmodels_id', 'tables' => array('glpi_networkequipments')), array('to' => 'peripheralmodels_id', 'tables' => array('glpi_peripherals')), array('to' => 'phonemodels_id', 'tables' => array('glpi_phones')), array('to' => 'printermodels_id', 'tables' => array('glpi_printers'))), 'netpoint' => array(array('to' => 'netpoints_id', 'tables' => array('glpi_networkports'))), 'network' => array(array('to' => 'networks_id', 'tables' => array('glpi_computers', 'glpi_networkequipments', 'glpi_printers'))), 'on_device' => array(array('to' => 'items_id', 'tables' => array('glpi_networkports'))), 'os' => array(array('to' => 'operatingsystems_id', 'tables' => array('glpi_computers'))), 'os_license_id' => array(array('to' => 'os_licenseid', 'tables' => array('glpi_computers'))), 'os_version' => array(array('to' => 'operatingsystemversions_id', 'tables' => array('glpi_computers'))), 'parentID' => array(array('to' => 'knowbaseitemcategories_id', 'tables' => array('glpi_knowbaseitemcategories')), array('to' => 'locations_id', 'tables' => array('glpi_locations')), array('to' => 'ticketcategories_id', 'tables' => array('glpi_ticketcategories')), array('to' => 'entities_id', 'tables' => array('glpi_entities'))), 'platform' => array(array('to' => 'operatingsystems_id', 'tables' => array('glpi_softwares'))), 'power' => array(array('to' => 'phonepowersupplies_id', 'tables' => array('glpi_phones'))), 'recipient' => array(array('to' => 'users_id_recipient', 'tables' => array('glpi_tickets'))), 'rubrique' => array(array('to' => 'documentcategories_id', 'tables' => array('glpi_documents'))), 'sID' => array(array('to' => 'softwares_id', 'tables' => array('glpi_softwarelicenses', 'glpi_softwareversions'))), 'state' => array(array('to' => 'states_id', 'tables' => array('glpi_computers', 'glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwareversions'))), 'tech_num' => array(array('to' => 'users_id_tech', 'tables' => array('glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', 'glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwares'))), 'title' => array(array('to' => 'usertitles_id', 'tables' => array('glpi_users'))), 'type' => array(array('to' => 'cartridgeitemtypes_id', 'tables' => array('glpi_cartridgeitems')), array('to' => 'computertypes_id', 'tables' => array('glpi_computers')), array('to' => 'consumableitemtypes_id', 'tables' => array('glpi_consumableitems')), array('to' => 'contacttypes_id', 'tables' => array('glpi_contacts')), array('to' => 'devicecasetypes_id', 'tables' => array('glpi_devicecases')), array('to' => 'devicememorytypes_id', 'tables' => array('glpi_devicememories')), array('to' => 'suppliertypes_id', 'tables' => array('glpi_suppliers')), array('to' => 'monitortypes_id', 'tables' => array('glpi_monitors')), array('to' => 'networkequipmenttypes_id', 'tables' => array('glpi_networkequipments')), array('to' => 'peripheraltypes_id', 'tables' => array('glpi_peripherals')), array('to' => 'phonetypes_id', 'tables' => array('glpi_phones')), array('to' => 'printertypes_id', 'tables' => array('glpi_printers')), array('to' => 'softwarelicensetypes_id', 'tables' => array('glpi_softwarelicenses')), array('to' => 'usercategories_id', 'tables' => array('glpi_users')), array('to' => 'itemtype', 'tables' => array('glpi_computers_items', 'glpi_displaypreferences'))), 'update_software' => array(array('to' => 'softwares_id', 'tables' => array('glpi_softwares'))), 'use_version' => array(array('to' => 'softwareversions_id_use', 'tables' => array('glpi_softwarelicenses'))), 'vID' => array(array('to' => 'softwareversions_id', 'tables' => array('glpi_computers_softwareversions'))), 'conpta_num' => array(array('to' => 'accounting_number', 'tables' => array('glpi_contracts'))), 'num_commande' => array(array('to' => 'order_number', 'tables' => array('glpi_infocoms'))), 'bon_livraison' => array(array('to' => 'delivery_number', 'tables' => array('glpi_infocoms'))), 'num_immo' => array(array('to' => 'immo_number', 'tables' => array('glpi_infocoms'))), 'facture' => array(array('to' => 'bill', 'tables' => array('glpi_infocoms'))), 'amort_time' => array(array('to' => 'sink_time', 'tables' => array('glpi_infocoms'))), 'amort_type' => array(array('to' => 'sink_type', 'tables' => array('glpi_infocoms'))), 'ifmac' => array(array('to' => 'mac', 'tables' => array('glpi_networkequipments'))), 'ifaddr' => array(array('to' => 'ip', 'tables' => array('glpi_networkequipments', 'glpi_networkports'))), 'ramSize' => array(array('to' => 'memory_size', 'tables' => array('glpi_printers'))), 'ramSize' => array(array('to' => 'memory_size', 'tables' => array('glpi_printers'))), 'facturation' => array(array('to' => 'billing', 'tables' => array('glpi_contracts'))), 'monday' => array(array('to' => 'use_monday', 'tables' => array('glpi_contracts'))), 'saturday' => array(array('to' => 'use_saturday', 'tables' => array('glpi_contracts'))), 'recursive' => array(array('to' => 'is_recursive', 'tables' => array('glpi_networkequipments', 'glpi_groups', 'glpi_contracts', 'glpi_contacts', 'glpi_suppliers', 'glpi_printers', 'glpi_softwares', 'glpi_softwareversions', 'glpi_softwarelicences'))), 'faq' => array(array('to' => 'is_faq', 'tables' => array('glpi_knowbaseitems'))), 'flags_micro' => array(array('to' => 'have_micro', 'tables' => array('glpi_monitors'))), 'flags_speaker' => array(array('to' => 'have_speaker', 'tables' => array('glpi_monitors'))), 'flags_subd' => array(array('to' => 'have_subd', 'tables' => array('glpi_monitors'))), 'flags_bnc' => array(array('to' => 'have_bnc', 'tables' => array('glpi_monitors'))), 'flags_dvi' => array(array('to' => 'have_dvi', 'tables' => array('glpi_monitors'))), 'flags_pivot' => array(array('to' => 'have_pivot', 'tables' => array('glpi_monitors'))), 'flags_hp' => array(array('to' => 'have_hp', 'tables' => array('glpi_phones'))), 'flags_casque' => array(array('to' => 'have_headset', 'tables' => array('glpi_phones'))), 'flags_usb' => array(array('to' => 'have_usb', 'tables' => array('glpi_printers'))), 'flags_par' => array(array('to' => 'have_parallel', 'tables' => array('glpi_printers'))), 'flags_serial' => array(array('to' => 'have_serial', 'tables' => array('glpi_printers'))), 'initial_pages' => array(array('to' => 'init_pages_counter', 'tables' => array('glpi_printers'))), 'global' => array(array('to' => 'is_global', 'tables' => array('glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwares'))), 'template' => array(array('to' => 'template_name', 'tables' => array('glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', 'glpi_devicecases', 'glpi_devicecontrols', 'glpi_devicedrives', 'glpi_devicegraphiccards', 'glpi_deviceharddrives', 'glpi_devicenetworkcards', 'glpi_devicemotherboards', 'glpi_devicepcis', 'glpi_devicepowersupplies', 'glpi_deviceprocessors', 'glpi_devicememories', 'glpi_devicesoundcards', 'glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwares'))), 'comments' => array(array('to' => 'comment', 'tables' => array('glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', 'glpi_contacts', 'glpi_contracts', 'glpi_documents', 'glpi_autoupdatesystems', 'glpi_budgets', 'glpi_cartridgeitemtypes', 'glpi_devicecasetypes', 'glpi_consumableitemtypes', 'glpi_contacttypes', 'glpi_contracttypes', 'glpi_domains', 'glpi_suppliertypes', 'glpi_filesystems', 'glpi_networkequipmentfirmwares', 'glpi_networkinterfaces', 'glpi_interfacetypes', 'glpi_knowbaseitemcategories', 'glpi_softwarelicensetypes', 'glpi_locations', 'glpi_manufacturers', 'glpi_computermodels', 'glpi_monitormodels', 'glpi_networkequipmentmodels', 'glpi_peripheralmodels', 'glpi_phonemodels', 'glpi_printermodels', 'glpi_netpoints', 'glpi_networks', 'glpi_operatingsystems', 'glpi_operatingsystemservicepacks', 'glpi_operatingsystemversions', 'glpi_phonepowersupplies', 'glpi_devicememorytypes', 'glpi_documentcategories', 'glpi_softwarecategories', 'glpi_states', 'glpi_ticketcategories', 'glpi_usertitles', 'glpi_usercategories', 'glpi_vlans', 'glpi_suppliers', 'glpi_entities', 'glpi_groups', 'glpi_infocoms', 'glpi_monitors', 'glpi_phones', 'glpi_printers', 'glpi_peripherals', 'glpi_networkequipments', 'glpi_reservationitems', 'glpi_rules', 'glpi_softwares', 'glpi_softwarelicenses', 'glpi_softwareversions', 'glpi_computertypes', 'glpi_monitortypes', 'glpi_networkequipmenttypes', 'glpi_peripheraltypes', 'glpi_phonetypes', 'glpi_printertypes', 'glpi_users'))), 'notes' => array(array('to' => 'notepad', 'tables' => array('glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', 'glpi_contacts', 'glpi_contracts', 'glpi_documents', 'glpi_suppliers', 'glpi_entitydatas', 'glpi_printers', 'glpi_monitors', 'glpi_phones', 'glpi_peripherals', 'glpi_networkequipments', 'glpi_softwares')))); $foreignkeys = Plugin::doHookFunction("plugin_datainjection_migratefields", $foreignkeys); $query = "SELECT `itemtype`, `value`\n FROM `glpi_plugin_datainjection_mappings`\n WHERE `itemtype` NOT IN ('none')\n GROUP BY `itemtype`,`value`"; foreach ($DB->request($query) as $data) { if (isset($foreignkeys[$data['value']])) { foreach ($foreignkeys[$data['value']] as $field_info) { $table = getTableForItemType($data['itemtype']); if (in_array($table, $field_info['tables'])) { $query = "UPDATE `glpi_plugin_datainjection_mappings`\n SET `value` = '" . $field_info['to'] . "'\n WHERE `itemtype` = '" . $data['itemtype'] . "'\n AND `value` = '" . $data['value'] . "'"; $DB->queryOrDie($query, "Datainjection : error converting mapping fields"); $query = "UPDATE `glpi_plugin_datainjection_infos`\n SET `value` = '" . $field_info['to'] . "'\n WHERE `itemtype` = '" . $data['itemtype'] . "'\n AND `value` = '" . $data['value'] . "'"; $DB->queryOrDie($query, "Datainjection : error converting infos fields"); } } } } }
function plugin_certificates_install() { global $DB; include_once (GLPI_ROOT."/plugins/certificates/inc/profile.class.php"); $install=false; $update78=false; $update80=false; if (!TableExists("glpi_plugin_certificates") && !TableExists("glpi_plugin_certificates_certificatetypes")) { $install=true; $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/empty-2.0.0.sql"); } else if (TableExists("glpi_plugin_certificates_mailing") && !FieldExists("glpi_plugin_certificates","recursive")) { $update78=true; $update80=true; $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.4.sql"); $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.5.0.sql"); $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.6.0.sql"); } else if (TableExists("glpi_plugin_certificates_profiles") && FieldExists("glpi_plugin_certificates_profiles","interface")) { $update78=true; $update80=true; $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.5.0.sql"); $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.6.0.sql"); } else if (TableExists("glpi_plugin_certificates") && !FieldExists("glpi_plugin_certificates","date_mod")) { $update78=true; $update80=true; $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.6.0.sql"); } else if (!TableExists("glpi_plugin_certificates_certificatetypes")) { $update78=true; $update80=true; $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.6.0.sql"); } //from 1.6 version if (TableExists("glpi_plugin_certificates_certificates") && !FieldExists("glpi_plugin_certificates_certificates","users_id_tech")) { $DB->runFile(GLPI_ROOT ."/plugins/certificates/sql/update-1.8.0.sql"); } if (TableExists("glpi_plugin_certificates_profiles")) { $notepad_tables = array('glpi_plugin_certificates_certificates'); foreach ($notepad_tables as $t) { // Migrate data if (FieldExists($t, 'notepad')) { $query = "SELECT id, notepad FROM `$t` WHERE notepad IS NOT NULL AND notepad <>'';"; foreach ($DB->request($query) as $data) { $iq = "INSERT INTO `glpi_notepads` (`itemtype`, `items_id`, `content`, `date`, `date_mod`) VALUES ('".getItemTypeForTable($t)."', '".$data['id']."', '".addslashes($data['notepad'])."', NOW(), NOW())"; $DB->queryOrDie($iq, "0.85 migrate notepad data"); } $query = "ALTER TABLE `glpi_plugin_certificates_certificates` DROP COLUMN `notepad`;"; $DB->query($query); } } } if ($install || $update78) { //Do One time on 0.78 $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginCertificatesCertificate' AND `name` = 'Alert Certificates'"; $result = $DB->query($query_id) or die ($DB->error()); $itemtype = $DB->result($result,0,'id'); $query="INSERT INTO `glpi_notificationtemplatetranslations` VALUES(NULL, ".$itemtype.", '','##certificate.action## : ##certificate.entity##', '##lang.certificate.entity## :##certificate.entity## ##FOREACHcertificates## ##lang.certificate.name## : ##certificate.name## - ##lang.certificate.dateexpiration## : ##certificate.dateexpiration## ##ENDFOREACHcertificates##', '<p>##lang.certificate.entity## :##certificate.entity##<br /> <br /> ##FOREACHcertificates##<br /> ##lang.certificate.name## : ##certificate.name## - ##lang.certificate.dateexpiration## : ##certificate.dateexpiration##<br /> ##ENDFOREACHcertificates##</p>');"; $result=$DB->query($query); $query = "INSERT INTO `glpi_notifications` VALUES (NULL, 'Alert Expired Certificates', 0, 'PluginCertificatesCertificate', 'ExpiredCertificates', 'mail',".$itemtype.", '', 1, 1, '2010-02-17 22:36:46');"; $result=$DB->query($query); $query = "INSERT INTO `glpi_notifications` VALUES (NULL, 'Alert Certificates Which Expire', 0, 'PluginCertificatesCertificate', 'CertificatesWhichExpire', 'mail',".$itemtype.", '', 1, 1, '2010-02-17 22:36:46');"; $result=$DB->query($query); } if ($update78) { $query_="SELECT * FROM `glpi_plugin_certificates_profiles` "; $result_=$DB->query($query_); if ($DB->numrows($result_)>0) { while ($data=$DB->fetch_array($result_)) { $query="UPDATE `glpi_plugin_certificates_profiles` SET `profiles_id` = '".$data["id"]."' WHERE `id` = '".$data["id"]."';"; $result=$DB->query($query); } } $query="ALTER TABLE `glpi_plugin_certificates_profiles` DROP `name` ;"; $result=$DB->query($query); Plugin::migrateItemType( array(1700=>'PluginCertificatesCertificate'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_certificates_certificates_items")); Plugin::migrateItemType( array(1200 => "PluginAppliancesAppliance",1300 => "PluginWebapplicationsWebapplication"), array("glpi_plugin_certificates_certificates_items")); } CronTask::Register('PluginCertificatesCertificate', 'CertificatesAlert', DAY_TIMESTAMP); PluginCertificatesProfile::initProfile(); PluginCertificatesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); $migration = new Migration("2.0.0"); $migration->dropTable('glpi_plugin_certificates_profiles'); return true; }
function plugin_badges_install() { global $DB; include_once GLPI_ROOT . "/plugins/badges/inc/profile.class.php"; $install = false; $update78 = false; $update85 = false; $update201 = false; if (!TableExists("glpi_plugin_badges") && !TableExists("glpi_plugin_badges_badgetypes")) { $install = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/empty-2.0.1.sql"); } else { if (TableExists("glpi_plugin_badges_users") && !TableExists("glpi_plugin_badges_default")) { $update78 = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.4.sql"); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.0.sql"); plugin_badges_configure15(); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql"); } else { if (TableExists("glpi_plugin_badges_profiles") && FieldExists("glpi_plugin_badges_profiles", "interface")) { $update78 = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.0.sql"); plugin_badges_configure15(); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql"); } else { if (TableExists("glpi_plugin_badges") && !FieldExists("glpi_plugin_badges", "date_mod")) { $update78 = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql"); } else { if (!TableExists("glpi_plugin_badges_badgetypes")) { $update78 = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql"); } else { if (TableExists("glpi_plugin_badges_profiles")) { $update85 = true; } } } } } } if (!TableExists("glpi_plugin_badges_requests")) { $update201 = true; $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-2.0.1.sql"); } if ($install || $update201) { // Badge request notification $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Request'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); if (empty($itemtype)) { $query_id = "INSERT INTO `glpi_notificationtemplates`(`id`, `name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('','Access Badges Request','PluginBadgesBadge', NOW(),'','');"; $result = $DB->query($query_id) or die($DB->error()); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Request'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); } $query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\n VALUES(NULL, '" . $itemtype . "', '','##badge.action## : ##badge.entity##',\r\n '##lang.badge.entity## :##badge.entity##\r\n ##FOREACHbadgerequest## \r\n ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##\t\r\n ##lang.badgerequest.requester## : ##badgerequest.requester##\t\r\n ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##\t\r\n ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##\r\n ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##\r\n ##ENDFOREACHbadgerequest##',\r\n '<p>##lang.badge.entity## :##badge.entity##<br /> <br />\r\n ##FOREACHbadgerequest##<br />\r\n ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##<br />\t\r\n ##lang.badgerequest.requester## : ##badgerequest.requester##<br />\r\n ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##<br />\r\n ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##<br />\r\n ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##<br />\r\n ##ENDFOREACHbadgerequest##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\r\n VALUES (NULL, 'Access badge request', 0, 'PluginBadgesBadge', 'AccessBadgeRequest',\r\n 'mail','" . $itemtype . "',\r\n '', 1, 1, '" . date('Y-m-d H:i:s') . "');"; $result = $DB->query($query); } // Badge expiration alert notification $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Return'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); if (empty($itemtype)) { $query_id = "INSERT INTO `glpi_notificationtemplates`(`id`, `name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('','Access Badges Return','PluginBadgesBadge', NOW(),'','');"; $result = $DB->query($query_id) or die($DB->error()); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Return'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); } $query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\n VALUES(NULL, '" . $itemtype . "', '','##badge.action## : ##badge.entity##',\r\n '##lang.badge.entity## :##badge.entity##\r\n ##FOREACHbadgerequest## \r\n ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##\t\r\n ##lang.badgerequest.requester## : ##badgerequest.requester##\t\r\n ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##\t\r\n ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##\r\n ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##\r\n ##ENDFOREACHbadgerequest##',\r\n '<p>##lang.badge.entity## :##badge.entity##<br /> <br />\r\n ##FOREACHbadgerequest##<br />\r\n ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##<br />\t\r\n ##lang.badgerequest.requester## : ##badgerequest.requester##<br />\r\n ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##<br />\r\n ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##<br />\r\n ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##<br />\r\n ##ENDFOREACHbadgerequest##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\r\n VALUES (NULL, 'Access badge return', 0, 'PluginBadgesBadge', 'BadgesReturn',\r\n 'mail','" . $itemtype . "',\r\n '', 1, 1, '" . date('Y-m-d H:i:s') . "');"; $result = $DB->query($query); if ($update78) { $query_ = "SELECT *\r\n FROM `glpi_plugin_badges_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_badges_profiles`\r\n SET `profiles_id` = '" . $data["id"] . "'\r\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_badges_profiles`\r\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(1600 => 'PluginBadgesBadge'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets")); } if ($update85) { $notepad_tables = array('glpi_plugin_badges_badges'); foreach ($notepad_tables as $t) { // Migrate data if (FieldExists($t, 'notepad')) { $query = "SELECT id, notepad\r\n FROM `{$t}`\r\n WHERE notepad IS NOT NULL\r\n AND notepad <>'';"; foreach ($DB->request($query) as $data) { $iq = "INSERT INTO `glpi_notepads`\r\n (`itemtype`, `items_id`, `content`, `date`, `date_mod`)\r\n VALUES ('" . getItemTypeForTable($t) . "', '" . $data['id'] . "',\r\n '" . addslashes($data['notepad']) . "', NOW(), NOW())"; $DB->queryOrDie($iq, "0.85 migrate notepad data"); } $query = "ALTER TABLE `glpi_plugin_badges_badges` DROP COLUMN `notepad`;"; $DB->query($query); } } } CronTask::Register('PluginBadgesBadge', 'BadgesAlert', DAY_TIMESTAMP); CronTask::Register('PluginBadgesReturn', 'BadgesReturnAlert', DAY_TIMESTAMP); PluginBadgesProfile::initProfile(); PluginBadgesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); $migration = new Migration("2.0.0"); $migration->dropTable('glpi_plugin_badges_profiles'); return true; }
function plugin_databases_install() { global $DB; include_once GLPI_ROOT . "/plugins/databases/inc/profile.class.php"; $update = false; if (!TableExists("glpi_plugin_sgbd") && !TableExists("glpi_plugin_databases_databases")) { $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/empty-1.5.0.sql"); } else { if (TableExists("glpi_plugin_sgbd") && !TableExists("glpi_plugin_sgbd_instances")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql"); } else { if (TableExists("glpi_plugin_sgbd") && !TableExists("glpi_dropdown_plugin_sgbd_category")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql"); } else { if (TableExists("glpi_plugin_sgbd") && !FieldExists("glpi_plugin_sgbd", "helpdesk_visible")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql"); } else { if (!TableExists("glpi_plugin_databases_databases")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql"); } } } } } //from 1.3 version if (TableExists("glpi_plugin_databases_databases") && !FieldExists("glpi_plugin_databases_databases", "users_id_tech")) { $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.5.0.sql"); } if ($update) { $query_ = "SELECT *\n FROM `glpi_plugin_databases_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_databases_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_databases_profiles`\n DROP `name` ;"; $result = $DB->query($query); $query = "SELECT `entities_id`,`is_recursive`,`id` FROM `glpi_plugin_databases_databases` "; $result = $DB->query($query); $number = $DB->numrows($result); if ($number) { while ($data = $DB->fetch_array($result)) { $query = "UPDATE `glpi_plugin_databases_instances`\n SET `entities_id` = '" . $data["entities_id"] . "'\n AND `is_recursive` = '" . $data["is_recursive"] . "'\n WHERE `plugin_databases_databases_id` = '" . $data["id"] . "' "; $DB->query($query) or die($DB->error()); $query = "UPDATE `glpi_plugin_databases_scripts`\n SET `entities_id` = '" . $data["entities_id"] . "'\n AND `is_recursive` = '" . $data["is_recursive"] . "'\n WHERE `plugin_databases_databases_id` = '" . $data["id"] . "' "; $DB->query($query) or die($DB->error()); } } Plugin::migrateItemType(array(2400 => 'PluginDatabasesDatabase'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_databases_databases_items")); Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance", 1300 => "PluginWebapplicationsWebapplication"), array("glpi_plugin_databases_databases_items")); } PluginDatabasesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function plugin_accounts_install() { global $DB, $CFG_GLPI; include_once GLPI_ROOT . "/plugins/accounts/inc/profile.class.php"; $install = false; $update78 = false; $update80 = false; $update171 = false; if (!TableExists("glpi_plugin_compte") && !TableExists("glpi_plugin_comptes") && !TableExists("glpi_comptes") && !TableExists("glpi_plugin_accounts_accounts")) { $install = true; $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/empty-1.9.0.sql"); } else { if (TableExists("glpi_comptes") && !FieldExists("glpi_comptes", "notes")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.3.sql"); plugin_accounts_updatev14(); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql"); $_SESSION['plugin_acounts_upgrading'] = 1; } else { if (TableExists("glpi_plugin_comptes") && !FieldExists("glpi_plugin_comptes", "all_users")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.3.sql"); plugin_accounts_updatev14(); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql"); $_SESSION['plugin_acounts_upgrading'] = 1; } else { if (TableExists("glpi_plugin_compte_profiles") && !FieldExists("glpi_plugin_compte_profiles", "my_groups")) { $update78 = true; $update80 = true; plugin_accounts_updatev14(); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql"); $_SESSION['plugin_acounts_upgrading'] = 1; } else { if (TableExists("glpi_plugin_compte_profiles") && FieldExists("glpi_plugin_compte_profiles", "interface")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql"); $_SESSION['plugin_acounts_upgrading'] = 1; } else { if (TableExists("glpi_plugin_compte") && !FieldExists("glpi_plugin_compte", "date_mod")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql"); } else { if (TableExists("glpi_plugin_compte") && !TableExists("glpi_plugin_compte_aeskey")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.5.3.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql"); } else { if (TableExists("glpi_plugin_compte") && !TableExists("glpi_plugin_accounts_accounts")) { $update78 = true; $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql"); } else { if (TableExists("glpi_plugin_accounts_accounts") && !FieldExists("glpi_plugin_accounts_accounts", "locations_id")) { $update80 = true; $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql"); } else { if (TableExists("glpi_plugin_accounts_hashes") && !FieldExists("glpi_plugin_accounts_hashes", "entities_id")) { $update171 = true; $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.7.1.sql"); } } } } } } } } } } //from 1.6 version if (TableExists("glpi_plugin_accounts_accounts") && !FieldExists("glpi_plugin_accounts_accounts", "users_id_tech")) { $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.8.0.sql"); } //from 1.9 version if (TableExists("glpi_plugin_accounts_accounttypes") && !FieldExists("glpi_plugin_accounts_accounttypes", "is_recursive")) { $DB->runFile(GLPI_ROOT . "/plugins/accounts/sql/update-1.9.0.sql"); } if ($install || $update78) { //Do One time on 0.78 $query_id = "SELECT `id` FROM `glpi_notificationtemplates`\n WHERE `itemtype`='PluginAccountsAccount'\n AND `name` = 'New Accounts'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.account.title##',\n '##lang.account.url## : ##account.url##\r\n\r\n\n ##lang.account.entity## : ##account.entity##\r\n\n ##IFaccount.name####lang.account.name## : ##account.name##\r\n##ENDIFaccount.name##\n ##IFaccount.type####lang.account.type## : ##account.type##\r\n##ENDIFaccount.type##\n ##IFaccount.state####lang.account.state## : ##account.state##\r\n##ENDIFaccount.state##\n ##IFaccount.login####lang.account.login## : ##account.login##\r\n##ENDIFaccount.login##\n ##IFaccount.users_id####lang.account.users_id## : ##account.users_id##\r\n##ENDIFaccount.users_id##\n ##IFaccount.groups_id####lang.account.groups_id## : ##account.groups_id##\r\n##ENDIFaccount.groups_id##\n ##IFaccount.others####lang.account.others## : ##account.others##\r\n##ENDIFaccount.others##\n ##IFaccount.datecreation####lang.account.datecreation## : ##account.datecreation##\r\n##ENDIFaccount.datecreation##\n ##IFaccount.dateexpiration####lang.account.dateexpiration## : ##account.dateexpiration##\r\n##ENDIFaccount.dateexpiration##\n ##IFaccount.comment####lang.account.comment## : ##account.comment##\r\n##ENDIFaccount.comment##',\n '<p><strong>##lang.account.url##</strong> : <a href=\"##account.url##\">##account.url##</a></p>\n <p><strong>##lang.account.entity##</strong> : ##account.entity##<br /> ##IFaccount.name##<strong>##lang.account.name##</strong> : ##account.name##<br />##ENDIFaccount.name## ##IFaccount.type##<strong>##lang.account.type##</strong> : ##account.type##<br />##ENDIFaccount.type## ##IFaccount.state##<strong>##lang.account.state##</strong> : ##account.state##<br />##ENDIFaccount.state## ##IFaccount.login##<strong>##lang.account.login##</strong> : ##account.login##<br />##ENDIFaccount.login## ##IFaccount.users##<strong>##lang.account.users##</strong> : ##account.users##<br />##ENDIFaccount.users## ##IFaccount.groups##<strong>##lang.account.groups##</strong> : ##account.groups##<br />##ENDIFaccount.groups## ##IFaccount.others##<strong>##lang.account.others##</strong> : ##account.others##<br />##ENDIFaccount.others## ##IFaccount.datecreation##<strong>##lang.account.datecreation##</strong> : ##account.datecreation##<br />##ENDIFaccount.datecreation## ##IFaccount.dateexpiration##<strong>##lang.account.dateexpiration##</strong> : ##account.dateexpiration##<br />##ENDIFaccount.dateexpiration## ##IFaccount.comment##<strong>##lang.account.comment##</strong> : ##account.comment####ENDIFaccount.comment##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Accounts', 0, 'PluginAccountsAccount', 'new',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates`\n WHERE `itemtype`='PluginAccountsAccount'\n AND `name` = 'Alert Accounts'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##account.action## : ##account.entity##',\n '##lang.account.entity## :##account.entity##\n ##FOREACHaccounts##\n ##lang.account.name## : ##account.name## - ##lang.account.dateexpiration## : ##account.dateexpiration##\n ##ENDFOREACHaccounts##',\n '<p>##lang.account.entity## :##account.entity##<br /> <br />\n ##FOREACHaccounts##<br />\n ##lang.account.name## : ##account.name## - ##lang.account.dateexpiration## : ##account.dateexpiration##<br />\n ##ENDFOREACHaccounts##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Expired Accounts', 0, 'PluginAccountsAccount', 'ExpiredAccounts',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Accounts Which Expire', 0, 'PluginAccountsAccount', 'AccountsWhichExpire',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); } if ($update78) { //Do One time on 0.78 $query_ = "SELECT *\n FROM `glpi_plugin_accounts_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_accounts_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_accounts_profiles`\n DROP `name` ;"; $result = $DB->query($query); Plugin::migrateItemType(array(1900 => 'PluginAccountsAccount', 1901 => 'PluginAccountsHelpdesk', 1902 => 'PluginAccountsGroup'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_accounts_accounts_items")); Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance", 1300 => "PluginWebapplicationsWebapplication", 1700 => "PluginCertificatesCertificate", 4400 => "PluginDomainsDomain", 2400 => "PluginDatabasesDatabase"), array("glpi_plugin_accounts_accounts_items")); } if ($update171) { $query = "UPDATE `glpi_plugin_accounts_hashes`\n SET `is_recursive` = '1'\n WHERE `id` = '1';"; $result = $DB->query($query); $query = "UPDATE `glpi_plugin_accounts_aeskeys`\n SET `plugin_accounts_hashes_id` = '1'\n WHERE `id` = '1';"; $result = $DB->query($query); } if (isset($_SESSION['plugin_acounts_upgrading'])) { $msg = __('After plugin installation, you must do upgrade of your passwords from here : ', 'accounts'); $msg .= "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/accounts/front/upgrade.form.php'>" . __('Upgrading page', 'accounts') . "</a>"; Session::addMessageAfterRedirect($msg, ERROR); } CronTask::Register('PluginAccountsAccount', 'AccountsAlert', DAY_TIMESTAMP); PluginAccountsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
public static function install(Migration $migration) { global $DB; $table = getTableForItemType(__CLASS__); //Installation if (!TableExists($table) && !TableExists("glpi_plugin_order")) { $migration->displayMessage("Installing {$table}"); $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_orders` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_template` tinyint(1) NOT NULL default '0',\n `template_name` varchar(255) collate utf8_unicode_ci default NULL,\n `is_recursive` tinyint(1) NOT NULL default '0',\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `num_order` varchar(255) collate utf8_unicode_ci default NULL,\n `budgets_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_budgets (id)',\n `plugin_order_ordertaxes_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertaxes (id)',\n `plugin_order_orderpayments_id` int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orderpayments (id)',\n `order_date` date default NULL,\n `duedate` date default NULL,\n `deliverydate` date default NULL,\n `is_late` tinyint(1) NOT NULL default '0',\n `suppliers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)',\n `contacts_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_contacts (id)',\n `locations_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_locations (id)',\n `plugin_order_orderstates_id` int(11) NOT NULL default 1,\n `plugin_order_billstates_id` int(11) NOT NULL default 1,\n `port_price` float NOT NULL default 0,\n `comment` text collate utf8_unicode_ci,\n `notepad` longtext collate utf8_unicode_ci,\n `is_deleted` tinyint(1) NOT NULL default '0',\n `users_id` int(11) NOT NULL default '0',\n `groups_id` int(11) NOT NULL default '0',\n `users_id_delivery` int(11) NOT NULL default '0',\n `groups_id_delivery` int(11) NOT NULL default '0',\n `plugin_order_ordertypes_id` int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertypes (id)',\n `date_mod` datetime default NULL,\n `is_helpdesk_visible` tinyint(1) NOT NULL default '1',\n PRIMARY KEY (`id`),\n KEY `name` (`name`),\n KEY `entities_id` (`entities_id`),\n KEY `plugin_order_ordertaxes_id` (`plugin_order_ordertaxes_id`),\n KEY `plugin_order_orderpayments_id` (`plugin_order_orderpayments_id`),\n KEY `states_id` (`plugin_order_orderstates_id`),\n KEY `suppliers_id` (`suppliers_id`),\n KEY `contacts_id` (`contacts_id`),\n KEY `locations_id` (`locations_id`),\n KEY `is_late` (`locations_id`),\n KEY `is_template` (`is_template`),\n KEY `is_deleted` (`is_deleted`),\n KEY date_mod (date_mod)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die($DB->error()); Crontask::Register(__CLASS__, 'computeLateOrders', HOUR_TIMESTAMP, array('param' => 24, 'mode' => CronTask::MODE_EXTERNAL)); } else { //Upgrade $migration->displayMessage("Upgrading {$table}"); if (TableExists('glpi_plugin_order')) { //Update to 1.1.0 $migration->addField('glpi_plugin_order', "port_price", "FLOAT NOT NULL default '0'"); $migration->addField('glpi_plugin_order', "taxes", "FLOAT NOT NULL default '0'"); if (FieldExists("glpi_plugin_order", "numordersupplier")) { foreach ($DB->request("glpi_plugin_order") as $data) { $query = "INSERT INTO `glpi_plugin_order_suppliers`\n (`ID`, `FK_order`, `numorder`, `numbill`) VALUES\n (NULL, '" . $data["ID"] . "', '" . $data["numordersupplier"] . "', '" . $data["numbill"] . "') "; $DB->query($query) or die($DB->error()); } } $migration->dropField('glpi_plugin_order', 'numordersupplier'); $migration->dropField('glpi_plugin_order', 'numbill'); $migration->migrationOneTable('glpi_plugin_order'); } //1.2.0 $domigration_itemtypes = false; if ($migration->renameTable("glpi_plugin_order", $table)) { $domigration_itemtypes = true; } $migration->changeField($table, "ID", "id", "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($table, "FK_entities", "entities_id", "int(11) NOT NULL default 0"); $migration->changeField($table, "recursive", "is_recursive", "tinyint(1) NOT NULL default 0"); $migration->changeField($table, "name", "name", "varchar(255) collate utf8_unicode_ci default NULL"); $migration->changeField($table, "budget", "budgets_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_budgets (id)'"); $migration->changeField($table, "numorder", "num_order", "varchar(255) collate utf8_unicode_ci default NULL"); $migration->changeField($table, "taxes", "plugin_order_ordertaxes_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertaxes (id)'"); $migration->changeField($table, "payment", "plugin_order_orderpayments_id", "int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orderpayments (id)'"); $migration->changeField($table, "date", "order_date", "date default NULL"); $migration->changeField($table, "FK_enterprise", "suppliers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)'"); $migration->changeField($table, "FK_contact", "contacts_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_contacts (id)'"); $migration->changeField($table, "location", "locations_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_locations (id)'"); $migration->changeField($table, "status", "states_id", "int(11) NOT NULL default '0'"); $migration->changeField($table, "comment", "comment", "text collate utf8_unicode_ci"); $migration->changeField($table, "notes", "notepad", "longtext collate utf8_unicode_ci"); $migration->changeField($table, "deleted", "is_deleted", "tinyint(1) NOT NULL default '0'"); $migration->addKey($table, "name"); $migration->addKey($table, "entities_id"); $migration->addKey($table, "plugin_order_ordertaxes_id"); $migration->addKey($table, "plugin_order_orderpayments_id"); $migration->addKey($table, "states_id"); $migration->addKey($table, "suppliers_id"); $migration->addKey($table, "contacts_id"); $migration->addKey($table, "locations_id"); $migration->addKey($table, "is_deleted"); $migration->migrationOneTable($table); //Only migrate itemtypes when it's only necessary, otherwise it breaks upgrade procedure ! if ($domigration_itemtypes) { Plugin::migrateItemType(array(3150 => 'PluginOrderOrder'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array()); } if (TableExists("glpi_plugin_order_budgets")) { //Manage budgets (here because class has been remove since 1.4.0) $migration->changeField("glpi_plugin_order_budgets", "ID", "id", " int(11) NOT NULL auto_increment"); $migration->changeField("glpi_plugin_order_budgets", "FK_entities", "entities_id", "int(11) NOT NULL default '0'"); $migration->changeField("glpi_plugin_order_budgets", "FK_budget", "budgets_id", "int(11) NOT NULL default '0'"); $migration->changeField("glpi_plugin_order_budgets", "comments", "comment", "text collate utf8_unicode_ci"); $migration->changeField("glpi_plugin_order_budgets", "deleted", "is_deleted", "tinyint(1) NOT NULL default '0'"); $migration->changeField("glpi_plugin_order_budgets", "startdate", "start_date", "date default NULL"); $migration->changeField("glpi_plugin_order_budgets", "enddate", "end_date", "date default NULL"); $migration->changeField("glpi_plugin_order_budgets", "value", "value", "float NOT NULL DEFAULT '0'"); $migration->addKey("glpi_plugin_order_budgets", "entities_id"); $migration->addKey("glpi_plugin_order_budgets", "is_deleted"); $migration->migrationOneTable("glpi_plugin_order_budgets"); Plugin::migrateItemType(array(3153 => 'PluginOrderBudget'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array()); //Manage budgets migration before dropping the table $budget = new Budget(); $matchings = array('budgets_id' => 'id', 'name' => 'name', 'start_date' => 'begin_date', 'end_date' => 'end_date', 'value' => 'value', 'comment' => 'comment', 'entities_id' => 'entities_id', 'is_deleted' => 'is_deleted'); foreach (getAllDatasFromTable("glpi_plugin_order_budgets") as $data) { $tmp = array(); $id = false; foreach ($matchings as $old => $new) { if (!is_null($data[$old])) { $tmp[$new] = $data[$old]; } } $tmp['comment'] = Toolbox::addslashes_deep($tmp['comment']); //Budget already exists in the core: update it if ($budget->getFromDB($data['budgets_id'])) { $budget->update($tmp); $id = $tmp['id']; } else { //Budget doesn't exists in the core: create it unset($tmp['id']); $id = $budget->add($tmp); } } $DB->query("DROP TABLE `glpi_plugin_order_budgets`"); foreach (array('glpi_displaypreferences', 'glpi_documents_items', 'glpi_bookmarks', 'glpi_logs') as $t) { $DB->query("DELETE FROM `{$t}` WHERE `itemtype` = 'PluginOrderBudget'"); } } //1.3.0 $migration->addField($table, "plugin_order_ordertypes_id", "int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertypes (id)'"); $migration->migrationOneTable($table); //1.4.0 if ($migration->changeField("glpi_plugin_order_orders", "states_id", "plugin_order_orderstates_id", "int(11) NOT NULL default 1")) { $migration->migrationOneTable($table); $query = "UPDATE `glpi_plugin_order_orders` SET `plugin_order_orderstates_id`=`plugin_order_orderstates_id`+1"; $DB->query($query) or die($DB->error()); } $migration->addField($table, "duedate", "DATETIME NULL"); $migration->migrationOneTable($table); //1.5.0 if (TableExists("glpi_dropdown_plugin_order_status")) { $DB->query("DROP TABLE `glpi_dropdown_plugin_order_status`") or die($DB->error()); } if (TableExists("glpi_plugin_order_mailing")) { $DB->query("DROP TABLE IF EXISTS `glpi_plugin_order_mailing`;") or die($DB->error()); } $migration->addField($table, 'plugin_order_billstates_id', "int(11) NOT NULL default 0"); //1.5.2 $migration->addField($table, 'deliverydate', "DATETIME NULL"); $migration->addField($table, "is_late", "TINYINT(1) NOT NULL DEFAULT '0'"); $migration->addKey($table, "is_late"); if (!countElementsInTable('glpi_crontasks', "`name`='computeLateOrders'")) { Crontask::Register(__CLASS__, 'computeLateOrders', HOUR_TIMESTAMP, array('param' => 24, 'mode' => CronTask::MODE_EXTERNAL)); } $migration->migrationOneTable($table); if ($migration->addField($table, "is_template", "tinyint(1) NOT NULL DEFAULT 0")) { $migration->addField($table, "template_name", "VARCHAR(255) collate utf8_unicode_ci default NULL"); $migration->migrationOneTable($table); } $migration->addField($table, "users_id", "INT(11) NOT NULL DEFAULT '0'"); $migration->addField($table, "groups_id", "INT(11) NOT NULL DEFAULT '0'"); $migration->addField($table, "users_id_delivery", "INT(11) NOT NULL DEFAULT '0'"); $migration->addField($table, "groups_id_delivery", "INT(11) NOT NULL DEFAULT '0'"); //1.7.0 $migration->addField($table, "date_mod", "datetime"); $migration->addKey($table, "date_mod"); //1.7.2 $migration->addField($table, "is_helpdesk_visible", "bool", array('value' => 1)); $migration->migrationOneTable($table); //Displayprefs $prefs = array(1 => 1, 2 => 2, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 10 => 10); foreach ($prefs as $num => $rank) { if (!countElementsInTable("glpi_displaypreferences", "`itemtype`='PluginOrderOrder' AND `num`='{$num}'\n AND `users_id`='0'")) { $DB->query("INSERT INTO glpi_displaypreferences\n VALUES (NULL,'PluginOrderOrder','{$num}','{$rank}','0');"); } } //Remove unused notifications $notification = new Notification(); $notification->deleteByCriteria("`itemtype`='PluginOrderOrder_Item'"); } }
public static function install(Migration $migration) { global $DB; $table = getTableForItemType(__CLASS__); if (!TableExists($table) && !TableExists("glpi_plugin_order_references_manufacturers")) { $migration->displayMessage("Installing {$table}"); $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_references_suppliers` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `plugin_order_references_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_references (id)',\n `suppliers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)',\n `price_taxfree` decimal(20,4) NOT NULL DEFAULT '0.0000',\n `reference_code` varchar(255) collate utf8_unicode_ci default NULL,\n PRIMARY KEY (`id`),\n KEY `entities_id` (`entities_id`),\n KEY `plugin_order_references_id` (`plugin_order_references_id`),\n KEY `suppliers_id` (`suppliers_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die($DB->error()); } else { $migration->displayMessage("Upgrading {$table}"); //1.1.0 if (TableExists("glpi_plugin_order_references_manufacturers")) { $migration->addField("glpi_plugin_order_references_manufacturers", "reference_code", "varchar(255) NOT NULL collate utf8_unicode_ci default ''"); $migration->migrationOneTable("glpi_plugin_order_references_manufacturers"); } //1.2.0 $migration->renameTable("glpi_plugin_order_references_manufacturers", $table); $migration->addField($table, "is_recursive", "int(11) NOT NULL default '0'"); $migration->addKey($table, "suppliers_id"); $migration->addKey($table, "plugin_order_references_id"); $migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment"); $migration->changeField($table, "FK_entities", "entities_id", "int(11) NOT NULL default '0'"); $migration->changeField($table, "FK_reference", "plugin_order_references_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_references (id)'"); $migration->changeField($table, "FK_enterprise", "suppliers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)'"); $migration->changeField($table, "reference_code", "reference_code", "varchar(255) collate utf8_unicode_ci default NULL"); $migration->changeField($table, "price_taxfree", "price_taxfree", "decimal(20,4) NOT NULL DEFAULT '0.0000'"); $migration->migrationOneTable($table); Plugin::migrateItemType(array(3152 => 'PluginOrderReference_Supplier'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs"), array()); if (FieldExists('glpi_tickets', 'itemtype')) { Plugin::migrateItemType(array(3152 => 'PluginOrderReference_Supplier'), array("glpi_tickets"), array()); } //1.5.0 $query = "SELECT `entities_id`,`is_recursive`,`id` FROM `glpi_plugin_order_references` "; foreach ($DB->request($query) as $data) { $query = "UPDATE `glpi_plugin_order_references_suppliers`\n SET `entities_id` = '" . $data["entities_id"] . "',`is_recursive` = '" . $data["is_recursive"] . "'\n WHERE `plugin_order_references_id` = '" . $data["id"] . "' "; $DB->query($query) or die($DB->error()); } } }
function plugin_databases_install() { global $DB; include_once GLPI_ROOT . "/plugins/databases/inc/profile.class.php"; $update = false; if (!TableExists("glpi_plugin_sgbd") && !TableExists("glpi_plugin_databases_databases")) { $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/empty-1.7.0.sql"); } else { if (TableExists("glpi_plugin_sgbd") && !TableExists("glpi_plugin_sgbd_instances")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql"); } else { if (TableExists("glpi_plugin_sgbd") && !TableExists("glpi_dropdown_plugin_sgbd_category")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql"); } else { if (TableExists("glpi_plugin_sgbd") && !FieldExists("glpi_plugin_sgbd", "helpdesk_visible")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql"); } else { if (!TableExists("glpi_plugin_databases_databases")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql"); } } } } } //from 1.3 version if (TableExists("glpi_plugin_databases_databases") && !FieldExists("glpi_plugin_databases_databases", "users_id_tech")) { $DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.5.0.sql"); } if (TableExists("glpi_plugin_databases_profiles")) { $notepad_tables = array('glpi_plugin_databases_databases'); foreach ($notepad_tables as $t) { // Migrate data if (FieldExists($t, 'notepad')) { $query = "SELECT id, notepad\n FROM `{$t}`\n WHERE notepad IS NOT NULL\n AND notepad <>'';"; foreach ($DB->request($query) as $data) { $iq = "INSERT INTO `glpi_notepads`\n (`itemtype`, `items_id`, `content`, `date`, `date_mod`)\n VALUES ('" . getItemTypeForTable($t) . "', '" . $data['id'] . "',\n '" . addslashes($data['notepad']) . "', NOW(), NOW())"; $DB->queryOrDie($iq, "0.85 migrate notepad data"); } $query = "ALTER TABLE `glpi_plugin_databases_databases` DROP COLUMN `notepad`;"; $DB->query($query); } } } if ($update) { $query_ = "SELECT *\n FROM `glpi_plugin_databases_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_databases_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_databases_profiles`\n DROP `name` ;"; $result = $DB->query($query); $query = "SELECT `entities_id`,`is_recursive`,`id` FROM `glpi_plugin_databases_databases` "; $result = $DB->query($query); $number = $DB->numrows($result); if ($number) { while ($data = $DB->fetch_array($result)) { $query = "UPDATE `glpi_plugin_databases_instances`\n SET `entities_id` = '" . $data["entities_id"] . "'\n AND `is_recursive` = '" . $data["is_recursive"] . "'\n WHERE `plugin_databases_databases_id` = '" . $data["id"] . "' "; $DB->query($query) or die($DB->error()); $query = "UPDATE `glpi_plugin_databases_scripts`\n SET `entities_id` = '" . $data["entities_id"] . "'\n AND `is_recursive` = '" . $data["is_recursive"] . "'\n WHERE `plugin_databases_databases_id` = '" . $data["id"] . "' "; $DB->query($query) or die($DB->error()); } } Plugin::migrateItemType(array(2400 => 'PluginDatabasesDatabase'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"), array("glpi_plugin_databases_databases_items")); Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance", 1300 => "PluginWebapplicationsWebapplication"), array("glpi_plugin_databases_databases_items")); } PluginDatabasesProfile::initProfile(); PluginDatabasesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); $migration = new Migration("1.7.0"); $migration->dropTable('glpi_plugin_databases_profiles'); return true; }
function plugin_resources_install() { global $DB; foreach (glob(GLPI_ROOT . '/plugins/resources/inc/*.php') as $file) { if (!preg_match('/resourceinjection/', $file) && !preg_match('/clientinjection/', $file) && !preg_match('/resourcepdf/', $file) && !preg_match('/datecriteria/', $file)) { include_once $file; } } $update = false; $update78 = false; $update80 = false; $update804 = false; $update83 = false; $install = false; if (!TableExists("glpi_plugin_resources_resources") && !TableExists("glpi_plugin_resources_employments")) { $install = true; // $DB->runFile(GLPI_ROOT ."/plugins/resources/sql/empty-1.9.0.sql"); // $DB->runFile(GLPI_ROOT ."/plugins/resources/sql/update-1.9.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/empty-1.9.1.sql"); $query = "INSERT INTO `glpi_plugin_resources_contracttypes` ( `id`, `name`,`comment`)\n VALUES (1, '" . __('Long term contract', 'resources') . "', '')"; $DB->query($query) or die($DB->error()); $query = "INSERT INTO `glpi_plugin_resources_contracttypes` ( `id`, `name`,`comment`)\n VALUES (2, '" . __('Fixed term contract', 'resources') . "', '')"; $DB->query($query) or die($DB->error()); $query = "INSERT INTO `glpi_plugin_resources_contracttypes` ( `id`, `name`,`comment`)\n VALUES (3, '" . __('Trainee', 'resources') . "', '')"; $DB->query($query) or die($DB->error()); } else { if (TableExists("glpi_plugin_resources") && !TableExists("glpi_plugin_resources_employee")) { $update = true; $update78 = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.4.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.5.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (TableExists("glpi_plugin_resources_profiles") && FieldExists("glpi_plugin_resources_profiles", "interface")) { $update = true; $update78 = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.5.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (TableExists("glpi_plugin_resources") && !FieldExists("glpi_plugin_resources", "helpdesk_visible")) { $update = true; $update78 = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (!TableExists("glpi_plugin_resources_contracttypes")) { $update = true; $update78 = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (TableExists("glpi_plugin_resources_contracttypes") && !FieldExists("glpi_plugin_resources_resources", "plugin_resources_resourcestates_id")) { $update = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (!TableExists("glpi_plugin_resources_reportconfigs")) { $update = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (!TableExists("glpi_plugin_resources_checklistconfigs")) { $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (!TableExists("glpi_plugin_resources_choiceitems")) { $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (!TableExists("glpi_plugin_resources_employments")) { $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); $query = "SELECT *\n FROM `glpi_plugin_resources_employers`"; $result = $DB->query($query); if ($DB->numrows($result) > 0) { while ($data = $DB->fetch_array($result)) { $queryUpdate = "UPDATE `glpi_plugin_resources_employers`\n SET `completename`= '" . $data["name"] . "'\n WHERE `id`= '" . $data["id"] . "'"; $DB->query($queryUpdate) or die($DB->error()); } } } else { if (TableExists("glpi_plugin_resources_ranks") && !FieldExists("glpi_plugin_resources_ranks", "begin_date")) { $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } } } } } } } } } } } if ($update78 || $install) { //Do One time on 0.78 $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Resources'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.resource.title## - ##resource.firstname## ##resource.name##',\n '##lang.resource.url## : ##resource.url##\n\n ##lang.resource.entity## : ##resource.entity##\n ##IFresource.name####lang.resource.name## : ##resource.name##\n ##ENDIFresource.name## ##IFresource.firstname####lang.resource.firstname## : ##resource.firstname##\n ##ENDIFresource.firstname## ##IFresource.type####lang.resource.type## : ##resource.type##\n ##ENDIFresource.type## ##IFresource.users####lang.resource.users## : ##resource.users##\n ##ENDIFresource.users## ##IFresource.usersrecipient####lang.resource.usersrecipient## : ##resource.usersrecipient##\n ##ENDIFresource.usersrecipient## ##IFresource.datedeclaration####lang.resource.datedeclaration## : ##resource.datedeclaration##\n ##ENDIFresource.datedeclaration## ##IFresource.datebegin####lang.resource.datebegin## : ##resource.datebegin##\n ##ENDIFresource.datebegin## ##IFresource.dateend####lang.resource.dateend## : ##resource.dateend##\n ##ENDIFresource.dateend## ##IFresource.department####lang.resource.department## : ##resource.department##\n ##ENDIFresource.department## ##IFresource.status####lang.resource.status## : ##resource.status##\n ##ENDIFresource.status## ##IFresource.location####lang.resource.location## : ##resource.location##\n ##ENDIFresource.location## ##IFresource.comment####lang.resource.comment## : ##resource.comment##\n ##ENDIFresource.comment## ##IFresource.usersleaving####lang.resource.usersleaving## : ##resource.usersleaving##\n ##ENDIFresource.usersleaving## ##IFresource.leaving####lang.resource.leaving## : ##resource.leaving##\n ##ENDIFresource.leaving## ##IFresource.helpdesk####lang.resource.helpdesk## : ##resource.helpdesk##\n ##ENDIFresource.helpdesk## ##FOREACHupdates##----------\n ##lang.update.title## :\n ##IFupdate.name####lang.resource.name## : ##update.name##\n ##ENDIFupdate.name## ##IFupdate.firstname####lang.resource.firstname## : ##update.firstname##\n ##ENDIFupdate.firstname## ##IFupdate.type####lang.resource.type## : ##update.type##\n ##ENDIFupdate.type## ##IFupdate.users####lang.resource.users## : ##update.users##\n ##ENDIFupdate.users## ##IFupdate.usersrecipient####lang.resource.usersrecipient## : ##update.usersrecipient##\n ##ENDIFupdate.usersrecipient## ##IFupdate.datedeclaration####lang.resource.datedeclaration## : ##update.datedeclaration##\n ##ENDIFupdate.datedeclaration## ##IFupdate.datebegin####lang.resource.datebegin## : ##update.datebegin##\n ##ENDIFupdate.datebegin## ##IFupdate.dateend####lang.resource.dateend## : ##update.dateend##\n ##ENDIFupdate.dateend## ##IFupdate.department####lang.resource.department## : ##update.department##\n ##ENDIFupdate.department## ##IFupdate.status####lang.resource.status## : ##update.status##\n ##ENDIFupdate.status## ##IFupdate.location####lang.resource.location## : ##update.location##\n ##ENDIFupdate.location## ##IFupdate.comment####lang.resource.comment## : ##update.comment##\n ##ENDIFupdate.comment## ##IFupdate.usersleaving####lang.resource.usersleaving## : ##update.usersleaving##\n ##ENDIFupdate.usersleaving## ##IFupdate.leaving####lang.resource.leaving## : ##update.leaving##\n ##ENDIFupdate.leaving## ##IFupdate.helpdesk####lang.resource.helpdesk## : ##update.helpdesk##\n ##ENDIFupdate.helpdesk## ----------##ENDFOREACHupdates##\n ##FOREACHtasks####lang.task.title## :\n ##IFtask.name####lang.task.name## : ##task.name##\n ##ENDIFtask.name## ##IFtask.type####lang.task.type## : ##task.type##\n ##ENDIFtask.type## ##IFtask.users####lang.task.users## : ##task.users##\n ##ENDIFtask.users## ##IFtask.groups####lang.task.groups## : ##task.groups##\n ##ENDIFtask.groups## ##IFtask.datebegin####lang.task.datebegin## : ##task.datebegin##\n ##ENDIFtask.datebegin## ##IFtask.dateend####lang.task.dateend## : ##task.dateend##\n ##ENDIFtask.dateend## ##IFtask.comment####lang.task.comment## : ##task.comment##\n ##ENDIFtask.comment## ##IFtask.finished####lang.task.finished## : ##task.finished##\n ##ENDIFtask.finished## ##IFtask.realtime####lang.task.realtime## : ##task.realtime##\n ##ENDIFtask.realtime## ----------##ENDFOREACHtasks## ',\n '<p><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.url##\n </strong> :\n <a href=\"##resource.url##\">##resource.url##\n </a></span> <br /><br />\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.entity##</strong> : ##resource.entity##\n </span> <br /> ##IFresource.name##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.name##</strong> : ##resource.name##\n <br /></span>##ENDIFresource.name## ##IFresource.firstname##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.firstname##</strong> : ##resource.firstname##\n <br /></span>##ENDIFresource.firstname## ##IFresource.type##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.type##</strong> : ##resource.type##<br />\n </span>##ENDIFresource.type## ##IFresource.status##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.status##</strong> : ##resource.status##<br />\n </span>##ENDIFresource.status## ##IFresource.users##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.users##</strong> : ##resource.users##<br />\n </span>##ENDIFresource.users## ##IFresource.usersrecipient##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.usersrecipient##\n </strong> : ##resource.usersrecipient##<br />\n </span>##ENDIFresource.usersrecipient## ##IFresource.datedeclaration##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.datedeclaration##\n </strong> : ##resource.datedeclaration##<br />\n </span>##ENDIFresource.datedeclaration## ##IFresource.datebegin##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.datebegin##</strong> : ##resource.datebegin##\n <br /></span>##ENDIFresource.datebegin## ##IFresource.dateend##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.dateend##</strong> : ##resource.dateend##\n <br /></span>##ENDIFresource.dateend## ##IFresource.department##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.department##</strong> : ##resource.department##\n <br /></span>##ENDIFresource.department## ##IFresource.location##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.location##</strong> : ##resource.location##\n <br /></span>##ENDIFresource.location## ##IFresource.comment##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.comment##</strong> : ##resource.comment##\n <br /></span>##ENDIFresource.comment## ##IFresource.usersleaving##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.usersleaving##</strong> : ##resource.usersleaving##\n <br /></span>##ENDIFresource.usersleaving## ##IFresource.leaving##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.leaving##</strong> : ##resource.leaving##\n <br /></span>##ENDIFresource.leaving## ##IFresource.helpdesk##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.helpdesk##</strong> : ##resource.helpdesk##\n <br /></span>##ENDIFresource.helpdesk## ##FOREACHupdates##----------\n <br />\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.update.title## :</strong></span>\n <br /> ##IFupdate.name##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.name##</strong> : ##update.name##<br />\n </span>##ENDIFupdate.name## ##IFupdate.firstname##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.firstname##</strong> : ##update.firstname##\n <br /></span>##ENDIFupdate.firstname## ##IFupdate.type##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.type##</strong> : ##update.type##<br />\n </span>##ENDIFupdate.type## ##IFupdate.status##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.status##</strong> : ##update.status##<br />\n </span>##ENDIFupdate.status## ##IFupdate.users##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.users##</strong> : ##update.users##<br />\n </span>##ENDIFupdate.users## ##IFupdate.usersrecipient##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.usersrecipient##</strong> : ##update.usersrecipient##\n <br /></span>##ENDIFupdate.usersrecipient## ##IFupdate.datedeclaration##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.datedeclaration##\n </strong> : ##update.datedeclaration##<br />\n </span>##ENDIFupdate.datedeclaration## ##IFupdate.datebegin##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.datebegin##</strong> : ##update.datebegin##\n <br /></span>##ENDIFupdate.datebegin## ##IFupdate.dateend##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.dateend##</strong> : ##update.dateend##\n <br /></span>##ENDIFupdate.dateend## ##IFupdate.department##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.department##</strong> : ##update.department##\n <br /></span>##ENDIFupdate.department## ##IFupdate.location##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.location##</strong> : ##update.location##\n <br /></span>##ENDIFupdate.location## ##IFupdate.comment##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.comment##</strong> : ##update.comment##\n <br /></span>##ENDIFupdate.comment## ##IFupdate.usersleaving##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.usersleaving##\n </strong> : ##update.usersleaving##<br />\n </span>##ENDIFupdate.usersleaving## ##IFupdate.leaving##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.leaving##</strong> : ##update.leaving##\n <br /></span>##ENDIFupdate.leaving## ##IFupdate.helpdesk##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.helpdesk##</strong> : ##update.helpdesk##\n <br /></span>##ENDIFupdate.helpdesk####ENDFOREACHupdates## ##FOREACHtasks##----------\n <br /><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.title## :</strong></span> <br /> ##IFtask.name##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.name##</strong> : ##task.name##<br />\n </span>##ENDIFtask.name## ##IFtask.type##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.type##</strong> : ##task.type##<br />\n </span>##ENDIFtask.type## ##IFtask.users##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.users##</strong> : ##task.users##<br />\n </span>##ENDIFtask.users## ##IFtask.groups##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.groups##</strong> : ##task.groups##<br />\n </span>##ENDIFtask.groups## ##IFtask.datebegin##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.datebegin##</strong> : ##task.datebegin##<br />\n </span>##ENDIFtask.datebegin## ##IFtask.dateend##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.dateend##</strong> : ##task.dateend##<br />\n </span>##ENDIFtask.dateend## ##IFtask.comment##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.comment##</strong> : ##task.comment##<br />\n </span>##ENDIFtask.comment## ##IFtask.finished##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.finished##</strong> : ##task.finished##<br />\n </span>##ENDIFtask.finished## ##IFtask.realtime##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.realtime##</strong> : ##task.realtime##\n </span>##ENDIFtask.realtime##<br />----------##ENDFOREACHtasks##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Resource', 0, 'PluginResourcesResource', 'new',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Resource', 0, 'PluginResourcesResource', 'update',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Resource', 0, 'PluginResourcesResource', 'delete',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Resource Task', 0, 'PluginResourcesResource', 'newtask',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Resource Task', 0, 'PluginResourcesResource', 'updatetask',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Resource Task', 0, 'PluginResourcesResource', 'deletetask',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Alert Resources Tasks'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##resource.action## : ##resource.entity##',\n '##FOREACHtasks##\n ##lang.task.name## : ##task.name##\n ##lang.task.type## : ##task.type##\n ##lang.task.users## : ##task.users##\n ##lang.task.groups## : ##task.groups##\n ##lang.task.datebegin## : ##task.datebegin##\n ##lang.task.dateend## : ##task.dateend##\n ##lang.task.comment## : ##task.comment##\n ##lang.task.resource## : ##task.resource##\n ##ENDFOREACHtasks##',\n '<table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\">\n <tbody>\n <tr>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.name##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.type##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.users##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.groups##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.datebegin##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.dateend##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.comment##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.resource##</span></td>\n </tr>\n ##FOREACHtasks##\n <tr>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.name##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.type##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.users##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.groups##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.datebegin##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.dateend##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.comment##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.resource##</span></td>\n </tr>\n ##ENDFOREACHtasks##\n </tbody>\n </table>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Expired Resources Tasks', 0, 'PluginResourcesResource', 'AlertExpiredTasks',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Alert Leaving Resources'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##resource.action## : ##resource.entity##',\n '##FOREACHresources##\n ##lang.resource.name## : ##resource.name##\n ##lang.resource.firstname## : ##resource.firstname##\n ##lang.resource.type## : ##resource.type##\n ##lang.resource.location## : ##resource.location##\n ##lang.resource.users## : ##resource.users##\n ##lang.resource.dateend## : ##resource.dateend##\n ##ENDFOREACHresources##',\n '<table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\">\n <tbody>\n <tr>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.name##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.firstname##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.type##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.location##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.users##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.dateend##</span></td>\n </tr>\n ##FOREACHresources##\n <tr>\n <td><a href=\"##resource.url##\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.name##</span></a></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.firstname##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.type##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.location##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.users##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.dateend##</span></td>\n </tr>\n ##ENDFOREACHresources##\n </tbody>\n </table>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Leaving Resources', 0, 'PluginResourcesResource', 'AlertLeavingResources',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Alert Resources Checklists'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##checklist.action## : ##checklist.entity##',\n '##lang.checklist.title##\n\n ##FOREACHchecklists##\n ##lang.checklist.name## ##lang.checklist.firstname## : ##checklist.name## ##checklist.firstname##\n ##lang.checklist.datebegin## : ##checklist.datebegin##\n ##lang.checklist.dateend## : ##checklist.dateend##\n ##lang.checklist.entity## : ##checklist.entity##\n ##lang.checklist.location## : ##checklist.location##\n ##lang.checklist.type## : ##checklist.type##\n\n ##lang.checklist.title2## :\n ##tasklist.name##\n ##ENDFOREACHchecklists##',\n '<table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\">\n <tbody>\n <tr bgcolor=\"#d9c4b8\">\n <th colspan=\"7\"><span style=\"font-family: Verdana; font-size: 11px; text-align: center;\">##lang.checklist.title##</span></th>\n </tr>\n <tr>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.name## ##lang.checklist.firstname##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.datebegin##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.dateend##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.entity##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.location##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.type##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.title2##</span></td>\n </tr>\n ##FOREACHchecklists##\n <tr>\n <td><a href=\"##checklist.url##\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.name## ##checklist.firstname##</span></a></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.datebegin##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.dateend##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.entity##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.location##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.type##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <table width=\"100%\">\n <tbody>\n <tr>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"> ##tasklist.name## </span></td>\n </tr>\n </tbody>\n </table>\n </span></td>\n </tr>\n ##ENDFOREACHchecklists##\n </tbody>\n </table>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Arrival Checklists', 0, 'PluginResourcesResource', 'AlertArrivalChecklists',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Leaving Checklists', 0, 'PluginResourcesResource', 'AlertLeavingChecklists',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Leaving Resource'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.resource.title## - ##resource.firstname## ##resource.name##',\n '##lang.resource.title2##\n\n ##lang.resource.url## : ##resource.url##\n\n ##lang.resource.entity## : ##resource.entity##\n ##IFresource.name## ##lang.resource.name## : ##resource.name##\n ##ENDIFresource.name##\n ##IFresource.firstname## ##lang.resource.firstname## : ##resource.firstname##\n ##ENDIFresource.firstname##\n\n ##lang.resource.badge##',\n '<p><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.resource.title2##</strong>\n <p><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.url##</strong> :\n <a href=\"##resource.url##\">##resource.url##</a>\n </span> <br /><br />\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.entity##</strong> : ##resource.entity##</span>\n <br /> ##IFresource.name##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.name##</strong> : ##resource.name##<br />\n </span>##ENDIFresource.name## ##IFresource.firstname##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.firstname##</strong> : ##resource.firstname##\n <br /></span>##ENDIFresource.firstname##</p>\n <p><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.resource.badge##</strong></span></p>\n </span></p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Leaving Resource', 0, 'PluginResourcesResource', 'LeavingResource',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); } if ($update78) { $profiles = getAllDatasFromTable("glpi_plugin_resources_profiles"); if (!empty($profiles)) { foreach ($profiles as $profile) { $query = "UPDATE `glpi_plugin_resources_profiles`\n SET `profiles_id` = '" . $resource["id"] . "'\n WHERE `id` = '" . $resource["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_resources_profiles`\n DROP `name` ;"; $result = $DB->query($query); $tables = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets"); foreach ($tables as $table) { $query = "DELETE FROM `{$table}` WHERE (`itemtype` = '4302' ) "; $DB->query($query); } Plugin::migrateItemType(array(4300 => 'PluginResourcesResource', 4301 => 'PluginResourcesTask', 4303 => 'PluginResourcesDirectory'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_resources_resources_items", "glpi_plugin_resources_choices", "glpi_plugin_resources_tasks_items")); Plugin::migrateItemType(array(1600 => "PluginBadgesBadge"), array("glpi_plugin_resources_resources_items", "glpi_plugin_resources_choices", "glpi_plugin_resources_tasks_items")); } if ($update || $install) { //Do One time on 0.78 for 1.6.2 $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Resource Report Creation'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.resource.title## - ##resource.firstname## ##resource.name##',\n '##lang.resource.creationtitle##\n\n##lang.resource.entity## : ##resource.entity##\n\n##lang.resource.name## : ##resource.name##\n##lang.resource.firstname## : ##resource.firstname##\n##lang.resource.department## : ##resource.department##\n##lang.resource.location## : ##resource.location##\n##lang.resource.users## : ##resource.users##\n##lang.resource.usersrecipient## : ##resource.usersrecipient##\n##lang.resource.datedeclaration## : ##resource.datedeclaration##\n##lang.resource.datebegin## : ##resource.datebegin##\n\n##lang.resource.creation##\n\n##lang.resource.datecreation## : ##resource.datecreation##\n##lang.resource.login## : ##resource.login##\n##lang.resource.email## : ##resource.email##\n\n##lang.resource.informationtitle##\n\n##IFresource.commentaires####lang.resource.commentaires## : ##resource.commentaires####ENDIFresource.commentaires##\n\n##IFresource.informations####lang.resource.informations## : ##resource.informations####ENDIFresource.informations##',\n '<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.creationtitle##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" colspan=\"2\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.entity##</span></td>\n<td style=\"text-align: left;\" colspan=\"2\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.entity##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.firstname##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.firstname##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.location##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.location##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.users##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.users##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.usersrecipient##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.usersrecipient##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datedeclaration##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.datedeclaration##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datebegin##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.datebegin##</span></td>\n</tr>\n</tbody>\n</table>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.creation##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datecreation##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.datecreation##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.login##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.login##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.email##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.email##</span></td>\n</tr>\n</tbody>\n</table>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.informationtitle##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n##IFresource.commentaires##\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.commentaires##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.commentaires##</span></td>\n</tr>\n##ENDIFresource.commentaires## ##IFresource.informations##\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.informations##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.informations##</span></td>\n</tr>\n##ENDIFresource.informations##\n</tbody>\n</table>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Resource Report Creation', 0, 'PluginResourcesResource', 'report',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-11-16 11:36:46');"; $result = $DB->query($query); } if ($update80) { $restrict = "`plugin_resources_resources_id` ='-1'"; $checklists = getAllDatasFromTable("glpi_plugin_resources_checklists", $restrict); $PluginResourcesChecklistconfig = new PluginResourcesChecklistconfig(); if (!empty($checklists)) { foreach ($checklists as $checklist) { $values["name"] = addslashes($checklist["name"]); $values["address"] = addslashes($checklist["address"]); $values["comment"] = addslashes($checklist["comment"]); $values["tag"] = $checklist["tag"]; $values["entities_id"] = $checklist["entities_id"]; $PluginResourcesChecklistconfig->add($values); } } $query = "DELETE FROM `glpi_plugin_resources_checklists`\n WHERE `plugin_resources_resources_id` ='-1'\n OR `plugin_resources_resources_id` ='0';"; $DB->query($query); // Put realtime in seconds if (FieldExists('glpi_plugin_resources_tasks', 'realtime')) { $query = "ALTER TABLE `glpi_plugin_resources_tasks`\n ADD `actiontime` INT( 11 ) NOT NULL DEFAULT 0 ;"; $DB->queryOrDie($query, $this->version . " 0.80 Add actiontime in glpi_plugin_resources_tasks"); $query = "UPDATE `glpi_plugin_resources_tasks`\n SET `actiontime` = ROUND(realtime * 3600)"; $DB->queryOrDie($query, $this->version . " 0.80 Compute actiontime value in glpi_plugin_resources_tasks"); $query = "ALTER TABLE `glpi_plugin_resources_tasks`\n DROP `realtime` ;"; $DB->queryOrDie($query, $this->version . " 0.80 DROP realtime in glpi_plugin_resources_tasks"); } // ADD plannings for tasks $tasks = getAllDatasFromTable("glpi_plugin_resources_tasks"); if (!empty($tasks)) { foreach ($tasks as $task) { $query = "INSERT INTO `glpi_plugin_resources_taskplannings`\n ( `id` , `plugin_resources_tasks_id` , `begin` , `end` )\n VALUES (NULL , '" . $task["id"] . "', '" . $task["date_begin"] . "', '" . $task["date_end"] . "') ;"; $DB->query($query); } } unset($input); $query = "ALTER TABLE `glpi_plugin_resources_tasks`\n DROP `date_begin`, DROP `date_end` ;"; $DB->queryOrDie($query, $this->version . " 0.80 Drop date_begin and date_end in glpi_plugin_resources_tasks"); // ADD tasks $PluginResourcesResource = new PluginResourcesResource(); $taches = getAllDatasFromTable("glpi_plugin_resources_tasks"); if (!empty($taches)) { foreach ($taches as $tache) { $PluginResourcesResource->getFromDB($tache["plugin_resources_resources_id"]); $input["entities_id"] = $PluginResourcesResource->fields["entities_id"]; $query = "UPDATE `glpi_plugin_resources_tasks`\n SET `entities_id` = '" . $PluginResourcesResource->fields["entities_id"] . "' WHERE `id` = '" . $tache["id"] . "' ;"; $DB->query($query); } } } if ($install || $update80) { $restrict = "`itemtype` = 'PluginResourcesResource'"; $unicities = getAllDatasFromTable("glpi_fieldunicities", $restrict); if (empty($unicities)) { $query = "INSERT INTO `glpi_fieldunicities`\n VALUES (NULL, 'Resources creation', 1, 'PluginResourcesResource', '0',\n 'name,firstname','1',\n '1', '1', '');"; $DB->queryOrDie($query, " 0.80 Create fieldunicities check"); } $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Resource Resting'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.resource.title## - ##resource.firstname## ##resource.name##',\n '##lang.resource.restingtitle##\n##lang.resource.openby## : ##resource.openby##\n##lang.resource.entity## : ##resource.entity##\n\n##lang.resource.name## : ##resource.name##\n##lang.resource.firstname## : ##resource.firstname##\n\n##lang.resource.department## : ##resource.department##\n##lang.resource.users## : ##resource.users##\n\n##lang.resource.resting##\n\n##lang.resource.location## : ##resource.location##\n##lang.resource.home## : ##resource.home##\n##lang.resource.datebegin## : ##resource.datebegin##\n##lang.resource.dateend## : ##resource.dateend##\n\n##lang.resource.commentaires## : ##resource.commentaires##\n\n##FOREACHupdates##\n##lang.update.title##\n\n##IFupdate.datebegin####lang.resource.datebegin## : ##update.datebegin####ENDIFupdate.datebegin##\n##IFupdate.dateend####lang.resource.dateend## : ##update.dateend####ENDIFupdate.dateend##\n##IFupdate.location####lang.resource.location## : ##update.location###ENDIFupdate.location##\n##IFupdate.home####lang.resource.home## : ##update.home####ENDIFupdate.home##\n##IFupdate.comment####lang.resource.comment## : ##update.comment####ENDIFupdate.comment##\n##ENDFOREACHupdates##',\n '<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.restingtitle##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.entity##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.entity##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.openby##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.openby##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.firstname##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.firstname##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.users##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.users##</span></td>\n</tr>\n</tbody>\n</table>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.resting##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.location##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.location##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.home##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.home##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datebegin##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.datebegin##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.dateend##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.dateend##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.commentaires##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.commentaires##</span></td>\n</tr>\n</tbody>\n</table>\n<p>##FOREACHupdates##</p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.update.title##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n##IFupdate.datebegin##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datebegin## : ##update.datebegin##\n</span></span></td>\n</tr>\n##ENDIFupdate.datebegin## ##IFupdate.dateend##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.dateend## : ##update.dateend##\n</span></span></td>\n</tr>\n##ENDIFupdate.dateend## ##IFupdate.location##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.location## : ##update.location##\n</span></span></td>\n</tr>\n##ENDIFupdate.location## ##IFupdate.home##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.home## : ##update.home##\n</span></span></td>\n</tr>\n##ENDIFupdate.home## ##IFupdate.comment##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.comment## : ##update.comment##\n</span></span></td>\n</tr>\n##ENDIFupdate.comment##\n</tbody>\n</table>\n<p>##ENDFOREACHupdates##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Resource Resting', 0, 'PluginResourcesResource', 'newresting',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Resource Resting', 0, 'PluginResourcesResource', 'updateresting',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Resource Resting', 0, 'PluginResourcesResource', 'deleteresting',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Resource Holiday'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.resource.title## - ##resource.firstname## ##resource.name##',\n '##lang.resource.holidaytitle##\n##lang.resource.openby## : ##resource.openby##\n##lang.resource.entity## : ##resource.entity##\n\n##lang.resource.name## : ##resource.name##\n##lang.resource.firstname## : ##resource.firstname##\n\n##lang.resource.department## : ##resource.department##\n##lang.resource.users## : ##resource.users##\n\n##lang.resource.holiday##\n\n##lang.resource.datebegin## : ##resource.datebegin##\n##lang.resource.dateend## : ##resource.dateend##\n\n##lang.resource.commentaires## : ##resource.commentaires##\n\n##FOREACHupdates##\n##lang.update.title##\n\n##IFupdate.datebegin####lang.resource.datebegin## : ##update.datebegin####ENDIFupdate.datebegin##\n##IFupdate.dateend####lang.resource.dateend## : ##update.dateend####ENDIFupdate.dateend##\n##IFupdate.comment####lang.resource.comment## : ##update.comment####ENDIFupdate.comment##\n##ENDFOREACHupdates##',\n '<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.holidaytitle##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.entity##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.entity##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.openby##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.openby##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.firstname##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.firstname##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.users##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.users##</span></td>\n</tr>\n</tbody>\n</table>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.holiday##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datebegin##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.datebegin##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.dateend##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.dateend##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.commentaires##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.commentaires##</span></td>\n</tr>\n</tbody>\n</table>\n<p>##FOREACHupdates##</p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.update.title##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n##IFupdate.datebegin##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datebegin## : ##update.datebegin##\n</span></span></td>\n</tr>\n##ENDIFupdate.datebegin## ##IFupdate.dateend##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.dateend## : ##update.dateend##\n</span></span></td>\n</tr>\n##ENDIFupdate.dateend## ##IFupdate.comment##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.comment## : ##update.comment##\n</span></span></td>\n</tr>\n##ENDIFupdate.comment##\n</tbody>\n</table>\n<p>##ENDFOREACHupdates##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Resource Holiday', 0, 'PluginResourcesResource', 'newholiday',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Resource Holiday', 0, 'PluginResourcesResource', 'updateholiday',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Resource Holiday', 0, 'PluginResourcesResource', 'deleteholiday',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); } if ($update804) { $query = "SELECT * FROM `glpi_plugin_resources_choices`\n WHERE `itemtype`!= ''\n GROUP BY `comment`,`itemtype`"; $result = $DB->query($query); $number = $DB->numrows($result); $affectedchoices = array(); if (!empty($number)) { while ($data = $DB->fetch_assoc($result)) { $restrictaffected = "`itemtype` = '" . $data["itemtype"] . "'\n AND `comment` = '" . addslashes($data["comment"]) . "'"; $affected = getAllDatasFromTable("glpi_plugin_resources_choices", $restrictaffected); if (!empty($affected)) { foreach ($affected as $affect) { if ($affect["itemtype"] == $data["itemtype"] && $affect["comment"] == $data["comment"]) { $affectedchoices[$data["id"]][] = $affect["plugin_resources_resources_id"]; } } } } } $i = 0; if (!empty($affectedchoices)) { foreach ($affectedchoices as $key => $ressources) { $i++; $choice = new PluginResourcesChoice(); $choice_item = new PluginResourcesChoiceItem(); $types = array(__('Computer') => 'Computer', __('Monitor') => 'Monitor', __('Software') => 'Software', __('Network device') => 'NetworkEquipment', __('Printer') => 'Printer', __('Peripheral') => 'Peripheral', __('Phone') => 'Phone', __('Consumable model') => 'ConsumableItem', __('Specific network rights', 'resources') => '4303', __('Access to the applications', 'resources') => '4304', __('Specific securities groups', 'resources') => '4305', __('Specific distribution lists', 'resources') => '4306', __('Others needs', 'resources') => '4307', 'PluginBadgesBadge' => 'PluginBadgesBadge'); if ($choice->getFromDB($key)) { $key = array_search($choice->fields["itemtype"], $types); if ($key) { $name = $key; } else { $name = $choice->fields["itemtype"]; } $valuesparent["name"] = $i . "." . $name; $valuesparent["entities_id"] = 0; $valuesparent["is_recursive"] = 1; $newidparent = $choice_item->add($valuesparent); $comment = "N/A"; if (!empty($choice->fields["comment"])) { $comment = $choice->fields["comment"]; } $valueschild["name"] = addslashes(Html::resume_text($comment, 50)); $valueschild["comment"] = addslashes($comment); $valueschild["entities_id"] = 0; $valueschild["is_recursive"] = 1; $valueschild["plugin_resources_choiceitems_id"] = $newidparent; $newidchild = $choice_item->add($valueschild); foreach ($ressources as $id => $val) { $query = "UPDATE `glpi_plugin_resources_choices`\n SET `plugin_resources_choiceitems_id` = '" . $newidchild . "'\n WHERE `plugin_resources_resources_id` = '" . $val . "'\n AND `itemtype` = '" . $choice->fields["itemtype"] . "'\n AND `comment` = '" . addslashes($choice->fields["comment"]) . "';"; $result = $DB->query($query); } } } } $query = "ALTER TABLE `glpi_plugin_resources_choices`\n DROP `itemtype`,\n DROP `comment`,\n ADD UNIQUE KEY `unicity` (`plugin_resources_resources_id`,`plugin_resources_choiceitems_id`);"; $result = $DB->query($query); $query = "ALTER TABLE `glpi_plugin_resources_choices`\n ADD `comment` text collate utf8_unicode_ci;"; $result = $DB->query($query); } //0.83 - Drop Matricule if (TableExists("glpi_plugin_resources_employees") && FieldExists("glpi_plugin_resources_employees", "matricule")) { $query = "SELECT * FROM `glpi_users`"; $result = $DB->query($query); $number = $DB->numrows($result); if (!empty($number)) { while ($data = $DB->fetch_assoc($result)) { $restrict = "`items_id` = '" . $data["id"] . "'\n AND `itemtype` = 'User'"; $links = getAllDatasFromTable("glpi_plugin_resources_resources_items", $restrict); if (!empty($links)) { foreach ($links as $link) { $employee = new PluginResourcesEmployee(); if ($employee->getFromDBbyResources($link["plugin_resources_resources_id"])) { $matricule = $employee->fields["matricule"]; if (isset($matricule) && !empty($matricule)) { $query = "UPDATE `glpi_users`\n SET `registration_number` = '" . $matricule . "'\n WHERE `id` ='" . $link["items_id"] . "'"; $DB->query($query); } } } } } } $query = "ALTER TABLE `glpi_plugin_resources_employees`\n DROP `matricule` ;"; $result = $DB->query($query); } $rep_files_resources = GLPI_PLUGIN_DOC_DIR . "/resources"; if (!is_dir($rep_files_resources)) { mkdir($rep_files_resources); } CronTask::Register('PluginResourcesResource', 'Resources', DAY_TIMESTAMP); CronTask::Register('PluginResourcesTask', 'ResourcesTask', DAY_TIMESTAMP); CronTask::Register('PluginResourcesChecklist', 'ResourcesChecklist', DAY_TIMESTAMP); CronTask::Register('PluginResourcesEmployment', 'ResourcesLeaving', DAY_TIMESTAMP, array('state' => CronTask::STATE_DISABLE)); PluginResourcesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }