本文整理汇总了PHP中Migration::dropField方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::dropField方法的具体用法?PHP Migration::dropField怎么用?PHP Migration::dropField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::dropField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
static function install(Migration $mig)
{
global $DB;
$table = 'glpi_plugin_behaviors_configs';
if (!TableExists($table)) {
//not installed
$query = "CREATE TABLE `" . $table . "`(\n `id` int(11) NOT NULL,\n `use_requester_item_group` tinyint(1) NOT NULL default '0',\n `use_requester_user_group` tinyint(1) NOT NULL default '0',\n `is_ticketsolutiontype_mandatory` tinyint(1) NOT NULL default '0',\n `is_ticketrealtime_mandatory` tinyint(1) NOT NULL default '0',\n `is_requester_mandatory` tinyint(1) NOT NULL default '0',\n `is_ticketdate_locked` tinyint(1) NOT NULL default '0',\n `use_assign_user_group` tinyint(1) NOT NULL default '0',\n `tickets_id_format` VARCHAR(15) NULL,\n `remove_from_ocs` tinyint(1) NOT NULL default '0',\n `add_notif` tinyint(1) NOT NULL default '0',\n `use_lock` tinyint(1) NOT NULL default '0',\n `single_tech_mode` int(11) NOT NULL default '0',\n `date_mod` datetime default NULL,\n `comment` text,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->queryOrDie($query, __('Error in creating glpi_plugin_behaviors_configs', 'behaviors') . "<br>" . $DB->error());
$query = "INSERT INTO " . `{$table}` . "\n (id, date_mod)\n VALUES (1, NOW())";
$DB->queryOrDie($query, __('Error during update glpi_plugin_behaviors_configs', 'behaviors') . "<br>" . $DB->error());
} else {
// Upgrade
$mig->addField($table, 'tickets_id_format', 'string');
$mig->addField($table, 'remove_from_ocs', 'bool');
$mig->addField($table, 'is_requester_mandatory', 'bool');
// version 0.78.0 - feature #2801 Forbid change of ticket's creation date
$mig->addField($table, 'is_ticketdate_locked', 'bool');
// Version 0.80.0 - set_use_date_on_state now handle in GLPI
$mig->dropField($table, 'set_use_date_on_state');
// Version 0.80.4 - feature #3171 additional notifications
$mig->addField($table, 'add_notif', 'bool');
// Version 0.83.0 - groups now have is_requester and is_assign attribute
$mig->dropField($table, 'sql_user_group_filter');
$mig->dropField($table, 'sql_tech_group_filter');
// Version 0.83.1 - prevent update on ticket updated by another user
$mig->addField($table, 'use_lock', 'bool');
// Version 0.83.4 - single tech/group #3857
$mig->addField($table, 'single_tech_mode', 'integer');
}
return true;
}
示例2: plugin_manufacturersimports_install
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;
}
示例3: plugin_racks_install
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;
}
示例4: install
static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` INT(11) NOT NULL AUTO_INCREMENT,\n `plugin_itilcategorygroups_categories_id` INT(11) NOT NULL DEFAULT '0',\n `level` TINYINT(1) NOT NULL DEFAULT '0',\n `itilcategories_id` INT(11) NOT NULL DEFAULT '0',\n `groups_id` INT(11) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n UNIQUE KEY `group_lvl_unicity` (plugin_itilcategorygroups_categories_id, level, groups_id),\n KEY `plugin_itilcategorygroups_categories_id` (`plugin_itilcategorygroups_categories_id`),\n KEY `level` (`level`),\n KEY `itilcategories_id` (`itilcategories_id`),\n KEY `groups_id` (`groups_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;";
$DB->query($query);
}
$parent_table = "glpi_plugin_itilcategorygroups_categories";
//we must migrate groups datas in sub table
if (FieldExists($parent_table, 'groups_id_levelone')) {
$all_lvl = $cat_groups = array();
//foreach old levels
foreach (array(1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four') as $lvl_num => $lvl_str) {
$query = "SELECT id, itilcategories_id, groups_id_level{$lvl_str} FROM {$parent_table}";
$res = $DB->query($query);
while ($data = $DB->fetch_assoc($res)) {
//specific case (all group of this lvl), store it for further treatment
if ($data["groups_id_level{$lvl_str}"] == -1) {
$all_lvl[$data['itilcategories_id']][$lvl_num] = $lvl_str;
}
if ($data["groups_id_level{$lvl_str}"] > 0) {
$cat_groups[] = array('plugin_itilcategorygroups_categories_id' => $data['id'], 'level' => $lvl_num, 'itilcategories_id' => $data['itilcategories_id'], 'groups_id' => $data["groups_id_level{$lvl_str}"]);
}
}
//insert "all groups for this lvl'
foreach ($all_lvl as $itilcategories_id => $lvl) {
foreach ($lvl as $lvl_num => $lvl_str) {
$DB->query("UPDATE {$parent_table} SET view_all_lvl{$lvl_num} = 1\n WHERE itilcategories_id = {$itilcategories_id}");
}
}
//insert groups in sub table
foreach ($cat_groups as $cat_groups_data) {
$DB->query("REPLACE INTO glpi_plugin_itilcategorygroups_categories_groups\n (plugin_itilcategorygroups_categories_id,\n level,\n itilcategories_id,\n groups_id)\n VALUES (\n " . $cat_groups_data['plugin_itilcategorygroups_categories_id'] . ",\n " . $cat_groups_data['level'] . ",\n " . $cat_groups_data['itilcategories_id'] . ",\n " . $cat_groups_data['groups_id'] . "\n )");
}
}
//drop migrated fields
$migration->dropField($parent_table, "groups_id_levelone");
$migration->dropField($parent_table, "groups_id_leveltwo");
$migration->dropField($parent_table, "groups_id_levelthree");
$migration->dropField($parent_table, "groups_id_levelfour");
$migration->migrationOneTable($parent_table);
}
return true;
}
示例5: install
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) {
//.........这里部分代码省略.........
示例6: install
public static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
$config = new self();
//This class is available since version 1.3.0
if (!TableExists($table) && !TableExists("glpi_plugin_order_config")) {
$migration->displayMessage("Installing {$table}");
//Install
$query = "CREATE TABLE `{$table}` (\n `id` int(11) NOT NULL auto_increment,\n `use_validation` tinyint(1) NOT NULL default '0',\n `use_supplier_satisfaction` tinyint(1) NOT NULL default '0',\n `use_supplier_informations` tinyint(1) NOT NULL default '0',\n `use_supplier_infos` tinyint(1) NOT NULL default '1',\n `generate_order_pdf` tinyint(1) NOT NULL default '0',\n `copy_documents` tinyint(1) NOT NULL default '0',\n `default_taxes` int(11) NOT NULL default '0',\n `generate_assets` int(11) NOT NULL default '0',\n `generated_name` varchar(255) collate utf8_unicode_ci default NULL,\n `generated_serial` varchar(255) collate utf8_unicode_ci default NULL,\n `generated_otherserial` varchar(255) collate utf8_unicode_ci default NULL,\n `default_asset_states_id` int(11) NOT NULL default '0',\n `tickettemplates_id_delivery` int(11) NOT NULL default '0',\n `order_status_draft` int(11) NOT NULL default '0',\n `order_status_waiting_approval` int(11) NOT NULL default '0',\n `order_status_approved` int(11) NOT NULL default '0',\n `order_status_partially_delivred` int(11) NOT NULL default '0',\n `order_status_completly_delivered` int(11) NOT NULL default '0',\n `order_status_canceled` int(11) NOT NULL default '0',\n `order_status_paid` int(11) NOT NULL default '0',\n `shoudbedelivered_color` char(20) collate utf8_unicode_ci default '#ff5555',\n `documentcategories_id` int(11) NOT NULL default '0',\n `groups_id_author` int(11) NOT NULL default '0',\n `groups_id_recipient` int(11) NOT NULL default '0',\n `users_id_recipient` int(11) NOT NULL default '0',\n `add_location` tinyint(1) NOT NULL default '0',\n `add_bill_details` tinyint(1) NOT NULL default '0',\n `hide_inactive_budgets` tinyint(1) NOT NULL default '0',\n `rename_documents` tinyint(1) NOT NULL default '0',\n `transmit_budget_change` tinyint(1) NOT NULL default '0',\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
$tobefilled = "TOBEFILLED";
$tmp = array('id' => 1, 'use_validation' => 0, 'default_taxes' => 0, 'generate_assets' => 0, 'generated_name' => $tobefilled, 'generated_serial' => $tobefilled, 'generated_otherserial' => $tobefilled, 'default_asset_states_id' => 0, 'generated_title' => $tobefilled, 'generated_content' => $tobefilled, 'default_ticketcategories_id' => 0, 'shoudbedelivered_color' => '#ff5555');
$config->add($tmp);
} else {
//Upgrade
$migration->displayMessage("Upgrading {$table}");
//1.2.0
$migration->renameTable("glpi_plugin_order_config", $table);
if (!countElementsInTable("glpi_plugin_order_configs")) {
$query = "INSERT INTO `glpi_plugin_order_configs`(`id`,`use_validation`,`default_taxes`) VALUES (1,0,0);";
$DB->query($query) or die($DB->error());
}
$migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
//1.3.0
$migration->addField($table, "generate_assets", "tinyint(1) NOT NULL default '0'");
$migration->addField($table, "generated_name", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->addField($table, "generated_serial", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->addField($table, "generated_otherserial", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->addField($table, "default_asset_entities_id", "int(11) NOT NULL default '0'");
$migration->addField($table, "default_asset_states_id", "int(11) NOT NULL default '0'");
$migration->addField($table, "generated_title", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->addField($table, "generated_content", "text collate utf8_unicode_ci");
$migration->addField($table, "default_ticketcategories_id", "int(11) NOT NULL default '0'");
$migration->addField($table, "use_supplier_satisfaction", "tinyint(1) NOT NULL default '0'");
$migration->addField($table, "generate_order_pdf", "tinyint(1) NOT NULL default '0'");
$migration->addField($table, "use_supplier_informations", "tinyint(1) NOT NULL default '1'");
$migration->addField($table, "shoudbedelivered_color", "char(20) collate utf8_unicode_ci default '#ff5555'");
$migration->addField($table, "copy_documents", "tinyint(1) NOT NULL DEFAULT '0'");
$migration->addField($table, "documentcategories_id", "integer");
$migration->addField($table, "groups_id_author", "integer");
$migration->addField($table, "groups_id_recipient", "integer");
$migration->addField($table, "users_id_recipient", "integer");
$migration->changeField($table, "default_ticketcategories_id", "default_itilcategories_id", "integer");
//1.9.0
$migration->addField($table, "add_location", "TINYINT(1) NOT NULL DEFAULT '0'");
$migration->addField($table, "add_bill_details", "TINYINT(1) NOT NULL DEFAULT '0'");
$config = new self();
$config->getFromDB(1);
$templateID = false;
$migration->addField($table, "tickettemplates_id_delivery", 'integer');
$migration->migrationOneTable($table);
$migration->dropField($table, "generated_title");
$migration->dropField($table, "generated_content");
$migration->dropField($table, "default_itilcategories_id");
$migration->addField($table, "hide_inactive_budgets", "bool");
$migration->addField($table, "rename_documents", "bool");
//0.85+1.2
$migration->addField($table, "transmit_budget_change", "bool");
$migration->migrationOneTable($table);
if ($templateID) {
$config->update(array('id' => 1, 'tickettemplates_id_delivery' => $templateID));
}
}
$migration->displayMessage("Add default order state workflow");
$new_states = array('order_status_draft' => 1, 'order_status_waiting_approval' => 2, 'order_status_approved' => 3, 'order_status_partially_delivred' => 4, 'order_status_completly_delivered' => 5, 'order_status_canceled' => 6, 'order_status_paid' => 7);
foreach ($new_states as $field => $value) {
$migration->addField($table, $field, "int(11) NOT NULL default '0'");
}
$migration->migrationOneTable($table);
$new_states['id'] = 1;
$config->update($new_states);
}
示例7: plugin_archires_updateTo180
function plugin_archires_updateTo180()
{
$migration = new Migration(180);
$migration->renameTable("glpi_plugin_archires_query_location", "glpi_plugin_archires_locationqueries");
$migration->renameTable("glpi_plugin_archires_query_switch", "glpi_plugin_archires_networkequipmentqueries");
$migration->renameTable("glpi_plugin_archires_query_applicatifs", "glpi_plugin_archires_appliancequeries");
$migration->renameTable("glpi_plugin_archires_image_device", "glpi_plugin_archires_imageitems");
$migration->renameTable("glpi_plugin_archires_query_type", "glpi_plugin_archires_querytypes");
$migration->renameTable("glpi_plugin_archires_color_iface", "glpi_plugin_archires_networkinterfacecolors");
$migration->renameTable("glpi_plugin_archires_color_state", "glpi_plugin_archires_statecolors");
$migration->renameTable("glpi_plugin_archires_color_vlan", "glpi_plugin_archires_vlancolors");
$migration->renameTable("glpi_plugin_archires_config", "glpi_plugin_archires_views");
$migration->dropKey("glpi_plugin_archires_locationqueries", "deleted");
$migration->changeField("glpi_plugin_archires_locationqueries", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_archires_locationqueries", "name", "name", 'string');
$migration->changeField("glpi_plugin_archires_locationqueries", "FK_entities", "entities_id", 'integer');
$migration->changeField("glpi_plugin_archires_locationqueries", "location", "locations_id", 'integer', array('comment' => 'RELATION to glpi_locations (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "network", "networks_id", 'integer', array('comment' => 'RELATION to glpi_networks (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "state", "states_id", 'integer', array('comment' => 'RELATION to glpi_states (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "FK_group", "groups_id", 'integer', array('comment' => 'RELATION to glpi_groups (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "FK_config", "plugin_archires_views_id", 'integer', array('comment' => 'RELATION to glpi_plugin_archires_views (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "FK_vlan", "vlans_id", 'integer', array('comment' => 'RELATION to glpi_vlans (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "deleted", "is_deleted", 'bool');
$migration->changeField("glpi_plugin_archires_locationqueries", "notes", "notepad", 'longtext');
$migration->dropField("glpi_plugin_archires_locationqueries", "link");
$migration->addKey("glpi_plugin_archires_locationqueries", "name");
$migration->addKey("glpi_plugin_archires_locationqueries", "entities_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "locations_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "networks_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "groups_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "plugin_archires_views_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "states_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "vlans_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "is_deleted");
$migration->dropKey("glpi_plugin_archires_networkequipmentqueries", "deleted");
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "name", "name", 'string');
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "FK_entities", "entities_id", 'integer');
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "switch", "networkequipments_id", 'integer', array('comment' => 'RELATION to glpi_networkequipments (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "network", "networks_id", 'integer', array('comment' => 'RELATION to glpi_networks (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "state", "states_id", 'integer', array('comment' => 'RELATION to glpi_states (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "FK_group", "groups_id", 'integer', array('comment' => 'RELATION to glpi_groups (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "FK_config", "plugin_archires_views_id", 'integer', array('comment' => 'RELATION to glpi_plugin_archires_views (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "FK_vlan", "vlans_id", 'integer', array('comment' => 'RELATION to glpi_vlans (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "deleted", "is_deleted", 'bool');
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "notes", "notepad", 'longtext');
$migration->dropField("glpi_plugin_archires_networkequipmentqueries", "link");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "name");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "entities_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "networkequipments_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "networks_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "groups_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "plugin_archires_views_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "states_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "vlans_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "is_deleted");
$migration->dropKey("glpi_plugin_archires_appliancequeries", "deleted");
$migration->changeField("glpi_plugin_archires_appliancequeries", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_archires_appliancequeries", "name", "name", 'string');
$migration->changeField("glpi_plugin_archires_appliancequeries", "FK_entities", "entities_id", 'integer');
$migration->changeField("glpi_plugin_archires_appliancequeries", "applicatifs", "appliances_id", 'integer', array('comment' => 'RELATION to glpi_plugin_appliances (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "network", "networks_id", 'integer', array('comment' => 'RELATION to glpi_networks (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "state", "states_id", 'integer', array('comment' => 'RELATION to glpi_states (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "FK_group", "groups_id", 'integer', array('comment' => 'RELATION to glpi_groups (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "FK_config", "plugin_archires_views_id", 'integer', array('comment' => 'RELATION to glpi_plugin_archires_views (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "FK_vlan", "vlans_id", 'integer', array('comment' => 'RELATION to glpi_vlans (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "deleted", "is_deleted", 'bool');
$migration->changeField("glpi_plugin_archires_appliancequeries", "notes", "notepad", 'longtext');
$migration->dropField("glpi_plugin_archires_appliancequeries", "link");
$migration->addKey("glpi_plugin_archires_appliancequeries", "name");
$migration->addKey("glpi_plugin_archires_appliancequeries", "entities_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "appliances_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "networks_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "groups_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "plugin_archires_views_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "states_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "vlans_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "is_deleted");
$migration->dropKey("glpi_plugin_archires_imageitems", "device_type");
$migration->changeField("glpi_plugin_archires_imageitems", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_archires_imageitems", "type", "type", 'integer');
$migration->changeField("glpi_plugin_archires_imageitems", "device_type", "itemtype", "varchar(100) collate utf8_unicode_ci NOT NULL", array('comment' => 'see .class.php file'));
$migration->dropKey("glpi_plugin_archires_querytypes", "FK_query");
$migration->dropKey("glpi_plugin_archires_querytypes", "type");
$migration->dropKey("glpi_plugin_archires_querytypes", "type_query");
$migration->dropKey("glpi_plugin_archires_querytypes", "device_type");
$migration->changeField("glpi_plugin_archires_querytypes", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_archires_querytypes", "type_query", "querytype", "varchar(100) collate utf8_unicode_ci NOT NULL", array('comment' => 'RELATION to the 3 type of archires (type)'));
$migration->changeField("glpi_plugin_archires_querytypes", "type", "type", 'integer');
$migration->changeField("glpi_plugin_archires_querytypes", "device_type", "itemtype", "varchar(100) collate utf8_unicode_ci NOT NULL", array('comment' => 'see .class.php file'));
$migration->changeField("glpi_plugin_archires_querytypes", "FK_query", "plugin_archires_queries_id", 'integer', array('comment' => 'RELATION to the 3 queries tables (id)'));
$migration->addKey("glpi_plugin_archires_querytypes", "querytype");
$migration->addKey("glpi_plugin_archires_querytypes", "type");
$migration->addKey("glpi_plugin_archires_querytypes", "itemtype");
$migration->addKey("glpi_plugin_archires_querytypes", "plugin_archires_queries_id");
$migration->migrationOneTable("glpi_plugin_archires_querytypes");
$query = "UPDATE `glpi_plugin_archires_querytypes`\n SET `querytype` = 'PluginArchiresLocationQuery'\n WHERE `querytype` = 0";
$DB->queryOrDie($query, __('1.8.0 update glpi_plugin_archires_querytypes (querytype) ', 'archires') . $DB->error());
$query = "UPDATE `glpi_plugin_archires_querytypes`\n SET `querytype` = 'PluginArchiresNetworkEquipmentQuery'\n WHERE `querytype` = 1";
$DB->queryOrDie($query, __('1.8.0 update glpi_plugin_archires_querytypes (querytype) ', 'archires') . $DB->error());
//.........这里部分代码省略.........
示例8: install
public static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_bills` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',\n `number` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',\n `billdate` datetime DEFAULT NULL,\n `validationdate` datetime DEFAULT NULL,\n `comment` text COLLATE utf8_unicode_ci,\n `plugin_order_billstates_id` int(11) NOT NULL DEFAULT '0',\n `value` decimal(20,4) NOT NULL DEFAULT '0.0000',\n `plugin_order_billtypes_id` int(11) NOT NULL DEFAULT '0',\n `suppliers_id` int(11) NOT NULL DEFAULT '0',\n `plugin_order_orders_id` int(11) NOT NULL DEFAULT '0',\n `users_id_validation` int(11) NOT NULL DEFAULT '0',\n `entities_id` int(11) NOT NULL DEFAULT '0',\n `is_recursive` int(11) NOT NULL DEFAULT '0',\n `notepad` text COLLATE utf8_unicode_ci,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;";
$DB->query($query) or die($DB->error());
} else {
if (FieldExists("glpi_plugin_order_orders_suppliers", "num_bill")) {
//Migrate bills
$bill = new PluginOrderBill();
$query = "SELECT * FROM `glpi_plugin_order_orders_suppliers`";
foreach (getAllDatasFromTable('glpi_plugin_order_orders_suppliers') as $data) {
if (!is_null($data['num_bill']) && $data['num_bill'] != '' && !countElementsInTable('glpi_plugin_order_bills', "`number`='" . $data['num_bill'] . "'")) {
//create new bill and link it to the order
$tmp['name'] = $tmp['number'] = $data['num_bill'];
//Get supplier from the order
$tmp['suppliers_id'] = $data['suppliers_id'];
//Bill has the same entities_id and is_recrusive
$tmp['entities_id'] = $data['entities_id'];
$tmp['is_recursive'] = $data['is_recursive'];
//Link bill to order
$tmp['plugin_order_orders_id'] = $data['plugin_order_orders_id'];
//Create bill
$bills_id = $bill->add($tmp);
//All order items are now linked to this bill
$query = "UPDATE `glpi_plugin_order_orders_items`\n SET `plugin_order_bills_id` = '{$bills_id}'\n WHERE `plugin_order_orders_id` = '" . $data['plugin_order_orders_id'] . "'";
$DB->query($query);
}
}
}
$migration->changeField($table, "value", "value", "decimal(20,4) NOT NULL DEFAULT '0.0000'");
$migration->migrationOneTable($table);
}
$migration->dropField("glpi_plugin_order_orders_suppliers", "num_bill");
$migration->migrationOneTable("glpi_plugin_order_orders_suppliers");
}
示例9: install
static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$query = "CREATE TABLE `{$table}` (\n `id` INT( 11 ) NOT NULL AUTO_INCREMENT,\n `entities_id` INT( 11 ) NOT NULL DEFAULT 0,\n `itemtype` varchar(255) collate utf8_unicode_ci default NULL,\n `is_active` tinyint(1) NOT NULL default '0',\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `comment` text NULL,\n `date_mod` datetime DEFAULT NULL,\n `date_creation` datetime DEFAULT NULL,\n `use_global_search` tinyint(1) NOT NULL default '0',\n `use_unicity` tinyint(1) NOT NULL default '0',\n `use_history` tinyint(1) NOT NULL default '0',\n `use_infocoms` tinyint(1) NOT NULL default '0',\n `use_contracts` tinyint(1) NOT NULL default '0',\n `use_documents` tinyint(1) NOT NULL default '0',\n `use_tickets` tinyint(1) NOT NULL default '0',\n `use_links` tinyint(1) NOT NULL default '0',\n `use_loans` tinyint(1) NOT NULL default '0',\n `use_network_ports` tinyint(1) NOT NULL default '0',\n `use_direct_connections` tinyint(1) NOT NULL default '0',\n `use_plugin_datainjection` tinyint(1) NOT NULL default '0',\n `use_plugin_pdf` tinyint(1) NOT NULL default '0',\n `use_plugin_order` tinyint(1) NOT NULL default '0',\n `use_plugin_uninstall` tinyint(1) NOT NULL default '0',\n `use_plugin_geninventorynumber` tinyint(1) NOT NULL default '0',\n `use_menu_entry` tinyint(1) NOT NULL default '0',\n `use_projects` tinyint(1) NOT NULL default '0',\n `linked_itemtypes` text NULL,\n `plugin_genericobject_typefamilies_id` INT( 11 ) NOT NULL DEFAULT 0,\n PRIMARY KEY ( `id` )\n ) ENGINE = MYISAM COMMENT = 'Object types definition table' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
$migration->addField($table, "use_network_ports", "bool");
$migration->addField($table, "use_direct_connections", "bool");
$migration->addField($table, "use_plugin_geninventorynumber", "bool");
$migration->addField($table, "use_contracts", "bool");
$migration->addField($table, "use_menu_entry", "bool");
$migration->addField($table, "use_global_search", "bool");
$migration->addField($table, "use_projects", "bool");
$migration->addField($table, "use_notepad", "bool");
$migration->addField($table, "comment", "text");
if (!$migration->addField($table, "date_mod", "datetime")) {
$migration->changeField($table, "date_mod", "date_mod", "datetime");
}
$migration->addField($table, "date_creation", "datetime");
$migration->addField($table, "linked_itemtypes", "text");
$migration->addField($table, "plugin_genericobject_typefamilies_id", "integer");
$migration->addField($table, "use_plugin_simcard", "bool");
$migration->migrationOneTable($table);
// Migrate notepad data
$allGenericObjectTypes = PluginGenericobjectType::getTypes(true);
$notepad = new Notepad();
foreach ($allGenericObjectTypes as $genericObjectType => $genericObjectData) {
$genericObjectTypeInstance = new $genericObjectType();
if (FieldExists($genericObjectTypeInstance->getTable(), "notepad")) {
$query = "INSERT INTO `" . $notepad->getTable() . "`\n (`items_id`,\n `itemtype`,\n `date`,\n `date_mod`,\n `content`\n )\n SELECT\n `id` as `items_id`,\n '" . $genericObjectType . "' as `itemtype`,\n now() as `date`,\n now() as `date_mod`,\n `notepad` as `content`\n FROM `" . $genericObjectTypeInstance->getTable() . "`\n WHERE notepad IS NOT NULL\n AND notepad <> ''";
$DB->query($query) or die($DB->error());
}
$query = "UPDATE`" . $notepad->getTable() . "`";
$migration->dropField($genericObjectTypeInstance->getTable(), "notepad");
$migration->migrationOneTable($genericObjectTypeInstance->getTable());
}
//Displayprefs
$prefs = array(10 => 6, 9 => 5, 8 => 4, 7 => 3, 6 => 2, 2 => 1, 4 => 1, 11 => 7, 12 => 8, 14 => 10, 15 => 11);
foreach ($prefs as $num => $rank) {
if (!countElementsInTable("glpi_displaypreferences", "`itemtype`='" . __CLASS__ . "' AND `num`='{$num}'\n AND `users_id`='0'")) {
$preference = new DisplayPreference();
$tmp['itemtype'] = __CLASS__;
$tmp['num'] = $num;
$tmp['rank'] = $rank;
$tmp['users_id'] = 0;
$preference->add($tmp);
}
}
//If files are missing, recreate them!
self::checkClassAndFilesForItemType();
}
示例10: install
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();
}
}
示例11: plugin_ocsinventoryng_migrateComputerLocks
/**
* Move locks from ocslink.import_* to is_dynamic in related tables
*
* @param $migration
**/
function plugin_ocsinventoryng_migrateComputerLocks(Migration $migration)
{
global $DB;
$import = array('import_printer' => 'Printer', 'import_monitor' => 'Monitor', 'import_peripheral' => 'Peripheral');
foreach ($import as $field => $itemtype) {
foreach ($DB->request('ocs_glpi_ocslinks', '', array('computers_id', $field)) as $data) {
if (FieldExists('ocs_glpi_ocslinks', $field)) {
$import_field = importArrayFromDB($data[$field]);
//If array is not empty
if (!empty($import_field)) {
$query_update = "UPDATE `glpi_computers_items`\n SET `is_dynamic`='1'\n WHERE `id` IN (" . implode(',', array_keys($import_field)) . ")\n AND `itemtype`='{$itemtype}'";
$DB->query($query_update);
}
}
}
$migration->dropField('ocs_glpi_ocslinks', $field);
}
//Migration disks and vms
$import = array('import_disk' => 'glpi_computerdisks', 'import_vm' => 'glpi_computervirtualmachines', 'import_software' => 'glpi_computers_softwareversions', 'import_ip' => 'glpi_networkports');
foreach ($import as $field => $table) {
if (FieldExists('ocs_glpi_ocslinks', $field)) {
foreach ($DB->request('ocs_glpi_ocslinks', '', array('computers_id', $field)) as $data) {
$import_field = importArrayFromDB($data[$field]);
//If array is not empty
if (!empty($import_field)) {
$in_where = "(" . implode(',', array_keys($import_field)) . ")";
$query_update = "UPDATE `{$table}`\n SET `is_dynamic`='1'\n WHERE `id` IN {$in_where}";
$DB->query($query_update);
if ($table == 'glpi_networkports') {
$query_update = "UPDATE `glpi_networkports` AS PORT,\n `glpi_networknames` AS NAME\n SET NAME.`is_dynamic` = 1\n WHERE PORT.`id` IN {$in_where}\n AND NAME.`itemtype` = 'NetworkPort'\n AND NAME.`items_id` = PORT.`id`";
$DB->query($query_update);
$query_update = "UPDATE `glpi_networkports` AS PORT,\n `glpi_networknames` AS NAME,\n `glpi_ipaddresses` AS ADDR\n SET ADDR.`is_dynamic` = 1\n WHERE PORT.`id` IN {$in_where}\n AND NAME.`itemtype` = 'NetworkPort'\n AND NAME.`items_id` = PORT.`id`\n AND ADDR.`itemtype` = 'NetworkName'\n AND ADDR.`items_id` = NAME.`id`";
$DB->query($query_update);
}
}
}
$migration->dropField('ocs_glpi_ocslinks', $field);
}
}
if (FieldExists('ocs_glpi_ocslinks', 'import_device')) {
foreach ($DB->request('ocs_glpi_ocslinks', '', array('computers_id', 'import_device')) as $data) {
$import_device = importArrayFromDB($data['import_device']);
if (!in_array('_version_078_', $import_device)) {
$import_device = plugin_ocsinventoryng_migrateImportDevice($import_device);
}
$devices = array();
$types = Item_Devices::getDeviceTypes();
foreach ($import_device as $key => $val) {
if (!$key) {
// OcsServer::IMPORT_TAG_078
continue;
}
list($type, $nomdev) = explode('$$$$$', $val);
list($type, $iddev) = explode('$$$$$', $key);
if (!isset($types[$type])) {
// should never happen
continue;
}
$devices[$types[$type]][] = $iddev;
}
foreach ($devices as $type => $data) {
//If array is not empty
$query_update = "UPDATE `" . getTableForItemType($type) . "`\n SET `is_dynamic`='1'\n WHERE `id` IN (" . implode(',', $data) . ")";
$DB->query($query_update);
}
}
$migration->dropField('ocs_glpi_ocslinks', 'import_device');
}
$migration->migrationOneTable('ocs_glpi_ocslinks');
}
示例12: plugin_ocsinventoryng_upgrademassocsimport13to14
function plugin_ocsinventoryng_upgrademassocsimport13to14()
{
$migration = new Migration(14);
$migration->renameTable("glpi_plugin_massocsimport", "glpi_plugin_massocsimport_threads");
$migration->changeField("glpi_plugin_massocsimport_threads", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_massocsimport_threads", "thread_id", "threadid", 'integer');
$migration->changeField("glpi_plugin_massocsimport_threads", "status", "status", 'integer');
$migration->changeField("glpi_plugin_massocsimport_threads", "ocs_server_id", "ocsservers_id", 'integer', array('value' => 1));
$migration->changeField("glpi_plugin_massocsimport_threads", "process_id", "processid", 'integer');
$migration->changeField("glpi_plugin_massocsimport_threads", "noupdate_machines_number", "notupdated_machines_number", 'integer');
$migration->migrationOneTable("glpi_plugin_massocsimport_threads");
$migration->addKey("glpi_plugin_massocsimport_threads", array("processid", "threadid"), "process_thread");
$migration->renameTable("glpi_plugin_massocsimport_config", "glpi_plugin_massocsimport_configs");
$migration->dropField("glpi_plugin_massocsimport_configs", "delete_frequency");
$migration->dropField("glpi_plugin_massocsimport_configs", "enable_logging");
$migration->dropField("glpi_plugin_massocsimport_configs", "delete_empty_frequency");
$migration->dropField("glpi_plugin_massocsimport_configs", "warn_if_not_imported");
$migration->dropField("glpi_plugin_massocsimport_configs", "not_imported_threshold");
$migration->changeField("glpi_plugin_massocsimport_configs", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_massocsimport_configs", "thread_log_frequency", "thread_log_frequency", 'integer', array('value' => 10));
$migration->changeField("glpi_plugin_massocsimport_configs", "display_empty", "is_displayempty", 'int(1) NOT NULL default 1');
$migration->changeField("glpi_plugin_massocsimport_configs", "default_ocs_server", "ocsservers_id", 'integer', array('value' => -1));
$migration->changeField("glpi_plugin_massocsimport_configs", "delay_refresh", "delay_refresh", 'integer');
$migration->changeField("glpi_plugin_massocsimport_configs", "comments", "comment", 'text');
$migration->changeField("glpi_plugin_massocsimport_details", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_massocsimport_details", "process_id", "plugin_massocsimport_threads_id", 'integer');
$migration->changeField("glpi_plugin_massocsimport_details", "thread_id", "threadid", 'integer');
$migration->changeField("glpi_plugin_massocsimport_details", "ocs_id", "ocsid", 'integer');
$migration->changeField("glpi_plugin_massocsimport_details", "glpi_id", "computers_id", 'integer');
$migration->changeField("glpi_plugin_massocsimport_details", "ocs_server_id", "ocsservers_id", 'integer', array('value' => 1));
$migration->migrationOneTable('glpi_plugin_massocsimport_details');
$migration->addKey("glpi_plugin_massocsimport_details", array("plugin_massocsimport_threads_id", "threadid"), "process_thread");
$migration->renameTable("glpi_plugin_massocsimport_not_imported", "glpi_plugin_massocsimport_notimported");
$migration->changeField("glpi_plugin_massocsimport_notimported", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_massocsimport_notimported", "ocs_id", "ocsid", 'integer');
$migration->changeField("glpi_plugin_massocsimport_notimported", "ocs_server_id", "ocsservers_id", 'integer');
$migration->changeField("glpi_plugin_massocsimport_notimported", "deviceid", "ocs_deviceid", 'string');
$migration->changeField("glpi_plugin_massocsimport_servers", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_massocsimport_servers", "ocs_server_id", "ocsservers_id", 'integer');
$migration->changeField("glpi_plugin_massocsimport_servers", "max_ocs_id", "max_ocsid", 'int(11) DEFAULT NULL');
$migration->changeField("glpi_plugin_massocsimport_servers", "max_glpi_date", "max_glpidate", 'datetime DEFAULT NULL');
$migration->executeMigration();
}
示例13: install
static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE `glpi_plugin_order_profiles` (\n `id` int(11) NOT NULL auto_increment,\n `profiles_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n `order` char(1) collate utf8_unicode_ci default NULL,\n `reference` char(1) collate utf8_unicode_ci default NULL,\n `validation` char(1) collate utf8_unicode_ci default NULL,\n `cancel` char(1) collate utf8_unicode_ci default NULL,\n `undo_validation` char(1) collate utf8_unicode_ci default NULL,\n `bill` char(1) collate utf8_unicode_ci default NULL,\n `delivery` char(1) collate utf8_unicode_ci default NULL,\n `generate_order_odt` char(1) collate utf8_unicode_ci default NULL,\n `open_ticket` char(1) default NULL,\n PRIMARY KEY (`id`),\n KEY `profiles_id` (`profiles_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
PluginOrderProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
} else {
$migration->displayMessage("Upgrading {$table}");
//1.2.0
$migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
foreach (array('order', 'reference', 'budget', 'validation', 'cancel', 'undo_validation') as $right) {
$migration->changeField($table, $right, $right, "char(1) collate utf8_unicode_ci default NULL");
}
$migration->migrationOneTable($table);
if ($migration->addField($table, "profiles_id", "int(11) NOT NULL default '0'")) {
$migration->addKey($table, "profiles_id");
$migration->migrationOneTable($table);
//Migration profiles
$DB->query("UPDATE `{$table}` SET `profiles_id`=`id`");
}
//1.4.0
$migration->dropField($table, "budget");
$migration->dropField($table, "name");
$migration->migrationOneTable($table);
//1.5.0
$migration->addField($table, "bill", "char");
$migration->migrationOneTable($table);
self::addRightToProfile($_SESSION['glpiactiveprofile']['id'], "bill", "w");
//1.5.3
//Add delivery right
if ($migration->addField($table, "delivery", "char")) {
$migration->migrationOneTable($table);
//Update profiles : copy order right not to change current behavior
$update = "UPDATE `{$table}` SET `delivery`=`order`";
$DB->query($update);
self::addRightToProfile($_SESSION['glpiactiveprofile']['id'], "delivery", "w");
}
if ($migration->addField($table, "generate_order_odt", "char")) {
$migration->migrationOneTable($table);
//Update profiles : copy order right not to change current behavior
$update = "UPDATE `{$table}` SET `generate_order_odt`=`order`";
$DB->query($update);
self::addRightToProfile($_SESSION['glpiactiveprofile']['id'], "generate_order_odt", "w");
}
}
//1.7.2
$migration->addField($table, "open_ticket", "char");
$migration->migrationOneTable($table);
self::addRightToProfile($_SESSION['glpiactiveprofile']['id'], "open_ticket", "w");
self::changeProfile();
}
示例14: plugin_escalade_install
function plugin_escalade_install()
{
global $DB;
//get version
$plugin = new Plugin();
$found = $plugin->find("name = 'escalade'");
$plugin_escalade = array_shift($found);
//init migration
$migration = new Migration($plugin_escalade['version']);
// == Tables creation (initial installation) ==
if (!TableExists('glpi_plugin_escalade_histories')) {
$query = "CREATE TABLE `glpi_plugin_escalade_histories` (\n `id` INT(11) NOT NULL AUTO_INCREMENT,\n `tickets_id` INT(11) NOT NULL,\n `groups_id` INT(11) NOT NULL,\n `date_mod` DATETIME NOT NULL,\n PRIMARY KEY (`id`),\n KEY `tickets_id` (`tickets_id`),\n KEY `groups_id` (`groups_id`)\n ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
}
if (!TableExists('glpi_plugin_escalade_configs')) {
$query = "CREATE TABLE `glpi_plugin_escalade_configs` (\n `id` INT(11) NOT NULL AUTO_INCREMENT,\n `remove_group` INT(11) NOT NULL,\n `remove_delete_group_btn` INT(11) NOT NULL,\n `remove_delete_user_btn` INT(11) NOT NULL,\n `show_history` INT(11) NOT NULL,\n `task_history` INT(11) NOT NULL,\n `remove_tech` INT(11) NOT NULL,\n `solve_return_group` INT(11) NOT NULL,\n `reassign_group_from_cat` INT(11) NOT NULL,\n `reassign_tech_from_cat` INT(11) NOT NULL,\n `cloneandlink_ticket` INT(11) NOT NULL,\n `close_linkedtickets` INT(11) NOT NULL,\n `use_assign_user_group` INT(11) NOT NULL,\n `use_assign_user_group_creation` INT(11) NOT NULL,\n `use_assign_user_group_modification` INT(11) NOT NULL,\n `use_filter_assign_group` INT(11) NOT NULL,\n `ticket_last_status` INT(11) NOT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
$query = "INSERT INTO glpi_plugin_escalade_configs\n VALUES (NULL, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, '" . Ticket::WAITING . "')";
$DB->query($query);
}
// == Update to 1.2 ==
if (!FieldExists('glpi_plugin_escalade_configs', 'cloneandlink_ticket')) {
$migration->addField('glpi_plugin_escalade_configs', 'cloneandlink_ticket', 'INT(11) NOT NULL', array('after' => 'reassign_tech_from_cat'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'close_linkedtickets')) {
$migration->addField('glpi_plugin_escalade_configs', 'close_linkedtickets', 'INT(11) NOT NULL', array('after' => 'cloneandlink_ticket'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'use_assign_user_group')) {
$migration->addField('glpi_plugin_escalade_configs', 'use_assign_user_group', 'INT(11) NOT NULL', array('after' => 'close_linkedtickets'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'use_assign_user_group_creation')) {
$migration->addField('glpi_plugin_escalade_configs', 'use_assign_user_group_creation', 'INT(11) NOT NULL', array('after' => 'use_assign_user_group'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'use_assign_user_group_modification')) {
$migration->addField('glpi_plugin_escalade_configs', 'use_assign_user_group_modification', 'INT(11) NOT NULL', array('after' => 'use_assign_user_group_creation'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'remove_delete_group_btn')) {
$migration->addField('glpi_plugin_escalade_configs', 'remove_delete_group_btn', 'INT(11) NOT NULL', array('after' => 'remove_group'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!isIndex("glpi_plugin_escalade_histories", 'tickets_id') || !isIndex("glpi_plugin_escalade_histories", 'groups_id')) {
$migration->addKey("glpi_plugin_escalade_histories", 'tickets_id', 'tickets_id');
$migration->addKey("glpi_plugin_escalade_histories", 'groups_id', 'groups_id');
$migration->migrationOneTable('glpi_plugin_escalade_histories');
}
// == Update to 1.3 ==
if (!FieldExists('glpi_plugin_escalade_configs', 'remove_delete_user_btn')) {
$migration->addField('glpi_plugin_escalade_configs', 'remove_delete_user_btn', 'INT(11) NOT NULL DEFAULT 1', array('after' => 'remove_delete_group_btn'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'use_filter_assign_group')) {
$migration->addField('glpi_plugin_escalade_configs', 'use_filter_assign_group', 'INT(11) NOT NULL', array('after' => 'use_assign_user_group_modification'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!TableExists('glpi_plugin_escalade_groups_groups')) {
$query = "CREATE TABLE `glpi_plugin_escalade_groups_groups` (\n `id` INT(11) NOT NULL AUTO_INCREMENT,\n `groups_id_source` int(11) NOT NULL DEFAULT '0',\n `groups_id_destination` int(11) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`)\n ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
}
// Update for 0.84 status
if (TableExists('glpi_plugin_escalade_configs')) {
foreach ($DB->request("glpi_plugin_escalade_configs") as $data) {
switch ($data['ticket_last_status']) {
case 'solved':
$status = Ticket::SOLVED;
break;
case 'waiting':
$status = Ticket::WAITING;
break;
case 'closed':
$status = Ticket::CLOSED;
break;
case 'assign':
$status = Ticket::ASSIGNED;
break;
case 'new':
$status = Ticket::INCOMING;
break;
case 'plan':
$status = Ticket::PLANNED;
break;
default:
$status = -1;
break;
}
$query = "UPDATE `glpi_plugin_escalade_configs`\n SET `ticket_last_status` = '" . $status . "'\n WHERE `id` = '" . $data['id'] . "'";
$DB->query($query);
}
$query = "ALTER TABLE `glpi_plugin_escalade_configs` MODIFY `ticket_last_status` INT(11);";
$DB->query($query);
}
// update to 0.85-1.0
if (FieldExists("glpi_plugin_escalade_configs", "assign_me_ticket")) {
// assign me ticket feature native in glpi 0.85
$migration->dropField("glpi_plugin_escalade_configs", "assign_me_ticket");
$migration->migrationOneTable('glpi_plugin_escalade_configs');
//.........这里部分代码省略.........
示例15: plugin_datainjection_update131_14
function plugin_datainjection_update131_14()
{
global $DB;
$migration = new Migration('1.4');
$migration->addField('glpi_plugin_data_injection_models', 'float_format', 'bool');
//Template recursivity : need standardize names in order to use privatePublicSwitch
$migration->changeField('glpi_plugin_data_injection_models', 'user_id', 'FK_users', 'integer');
$migration->changeField('glpi_plugin_data_injection_models', 'public', 'private', 'bool');
$migration->migrationOneTable('glpi_plugin_data_injection_models');
$sql = "UPDATE `glpi_plugin_data_injection_models`\n SET `FK_entities` = '-1',\n `private` = '1'\n WHERE `private` = '0'";
$DB->query($sql);
$sql = "UPDATE `glpi_plugin_data_injection_models`\n SET `private` = '0'\n WHERE `private` = '1'\n AND `FK_entities` > '0'";
$DB->query($sql);
$migration->addField('glpi_plugin_data_injection_models', 'recursive', 'bool');
$sql = "UPDATE `glpi_plugin_data_injection_profiles`\n SET `create_model` = `use_model`\n WHERE `create_model` IS NULL";
$DB->query($sql);
$migration->dropField('glpi_plugin_data_injection_profiles', 'use_model');
$migration->changeField('glpi_plugin_data_injection_profiles', 'create_model', 'model', 'char');
$migration->executeMigration();
}