当前位置: 首页>>代码示例>>PHP>>正文


PHP Migration::renameTable方法代码示例

本文整理汇总了PHP中Migration::renameTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::renameTable方法的具体用法?PHP Migration::renameTable怎么用?PHP Migration::renameTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Migration的用法示例。


在下文中一共展示了Migration::renameTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: plugin_barcode_install

function plugin_barcode_install()
{
    global $DB;
    $migration = new Migration(PLUGIN_BARCODE_VERSION);
    if (!file_exists(GLPI_PLUGIN_DOC_DIR . "/barcode")) {
        mkdir(GLPI_PLUGIN_DOC_DIR . "/barcode");
    }
    $migration->renameTable("glpi_plugin_barcode_config", "glpi_plugin_barcode_configs");
    if (!TableExists("glpi_plugin_barcode_configs")) {
        $query = "CREATE TABLE `glpi_plugin_barcode_configs` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `type` varchar(20) collate utf8_unicode_ci default NULL,\n                  PRIMARY KEY  (`ID`)\n               ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die("error creating glpi_plugin_barcode_configs " . $DB->error());
        $query = "INSERT INTO `glpi_plugin_barcode_configs` \n                     (`id`, `type`)\n                VALUES\n                     ('1', 'code128')";
        $DB->query($query) or die("error populate glpi_plugin_barcode_configs " . $DB->error());
    }
    $migration->renameTable("glpi_plugin_barcode_config_type", "glpi_plugin_barcode_configs_types");
    if (!TableExists("glpi_plugin_barcode_configs_types")) {
        $query = "CREATE TABLE `glpi_plugin_barcode_configs_types` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `type` varchar(20) collate utf8_unicode_ci default NULL,\n                  `size` varchar(20) collate utf8_unicode_ci default NULL,\n                  `orientation` varchar(9) collate utf8_unicode_ci default NULL,\n                  `marginTop` int(11) NULL,\n                  `marginBottom` int(11) NULL,\n                  `marginLeft` int(11) NULL,\n                  `marginRight` int(11) NULL,\n                  `marginHorizontal` int(11) NULL,\n                  `marginVertical` int(11) NULL,\n                  `maxCodeWidth` int(11) NULL,\n                  `maxCodeHeight` int(11) NULL,\n                  PRIMARY KEY  (`ID`),\n                  UNIQUE  (`type`)\n               ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query) or die("error creating glpi_plugin_barcode_configs_types " . $DB->error());
        $query = "INSERT INTO `glpi_plugin_barcode_configs_types`\n                     (`type`, `size`, `orientation`,\n                     `marginTop`, `marginBottom`, `marginLeft`, `marginRight`,\n                     `marginHorizontal`, `marginVertical`, `maxCodeWidth`, `maxCodeHeight`)\n                VALUES\n                     ('Code39', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '128', '50'),\n                     ('code128', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '70'),\n                     ('ean13', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '70'),\n                     ('int25', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '70'),\n                     ('postnet', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '70'),\n                     ('upca', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '70'),\n                     ('QRcode', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '100')";
        $DB->query($query) or die("error populate glpi_plugin_barcode_configs_types " . $DB->error());
    }
    if (countElementsInTable("glpi_plugin_barcode_configs_types", "`type`='QRcode'") == 0) {
        $query = "INSERT INTO `glpi_plugin_barcode_configs_types`\n                     (`type`, `size`, `orientation`,\n                     `marginTop`, `marginBottom`, `marginLeft`, `marginRight`,\n                     `marginHorizontal`, `marginVertical`, `maxCodeWidth`, `maxCodeHeight`)\n                VALUES\n                     ('QRcode', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '100')";
        $DB->query($query) or die("error populate glpi_plugin_barcode_configs_types " . $DB->error());
    }
    include_once GLPI_ROOT . '/plugins/barcode/inc/profile.class.php';
    include_once GLPI_ROOT . '/plugins/barcode/inc/config.class.php';
    PluginBarcodeProfile::initProfile();
    if (TableExists("glpi_plugin_barcode_profiles")) {
        $query = "DROP TABLE `glpi_plugin_barcode_profiles`";
        $DB->query($query) or die("error deleting glpi_plugin_barcode_profiles");
    }
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:34,代码来源:hook.php

示例2: install

 public static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (!TableExists($table) && !TableExists("glpi_dropdown_plugin_order_taxes")) {
         $migration->displayMessage("Installing {$table}");
         //Install
         $query = "CREATE TABLE `glpi_plugin_order_ordertaxes` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `name` varchar(255) collate utf8_unicode_ci default NULL,\n                  `comment` text collate utf8_unicode_ci,\n                  PRIMARY KEY  (`id`),\n                  KEY `name` (`name`)\n               ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
         $taxes = new self();
         foreach (array('20', '5.5', '19.6') as $tax) {
             $taxes->add(array('name' => $tax));
         }
     } else {
         //Update
         $migration->displayMessage("Migrating {$table}");
         //1.2.0
         $migration->renameTable("glpi_dropdown_plugin_order_taxes", $table);
         $migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
         $migration->changeField($table, "name", "name", "varchar(255) collate utf8_unicode_ci default NULL");
         $migration->changeField($table, "comments", "comment", "text collate utf8_unicode_ci");
         $migration->migrationOneTable($table);
         //Remplace , by . in taxes
         foreach ($DB->request("SELECT `name` FROM `{$table}`") as $data) {
             if (strpos($data["name"], ',')) {
                 $name = str_replace(',', '.', $data["name"]);
                 $query = "UPDATE `{$table}`\n                         SET `name` = '" . $name . "'\n                         WHERE `name`= '" . $data["name"] . "'";
                 $DB->query($query) or die($DB->error());
             }
         }
     }
 }
开发者ID:equinoxefr,项目名称:order,代码行数:32,代码来源:ordertax.class.php

示例3: install

 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);
         }
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:34,代码来源:configfield.class.php

示例4: install

 static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (!TableExists($table) && !TableExists("glpi_dropdown_plugin_order_payment")) {
         $migration->displayMessage("Installing {$table}");
         $query = "CREATE TABLE `glpi_plugin_order_orderpayments` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `name` varchar(255) collate utf8_unicode_ci default NULL,\n                  `comment` text collate utf8_unicode_ci,\n                  PRIMARY KEY  (`id`),\n                  KEY `name` (`name`)\n               ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
     } else {
         $migration->displayMessage("Upgrading {$table}");
         //1.2.0
         $migration->renameTable("glpi_dropdown_plugin_order_payment", $table);
         $migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
         $migration->changeField($table, "name", "name", "varchar(255) collate utf8_unicode_ci default NULL");
         $migration->changeField($table, "comments", "comment", "text collate utf8_unicode_ci");
         $migration->migrationOneTable($table);
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:18,代码来源:orderpayment.class.php

示例5: 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);
 }
开发者ID:pluginsGLPI,项目名称:order,代码行数:73,代码来源:config.class.php

示例6: install

 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());
             }
         }
     }
 }
开发者ID:equinoxefr,项目名称:order,代码行数:38,代码来源:order_supplier.class.php

示例7: install

 static function install(Migration $migration)
 {
     global $DB;
     $table = 'glpi_plugin_webservices_clients';
     $migration->renameTable('glpi_plugin_webservices', $table);
     if (TableExists('glpi_plugin_webservices_clients')) {
         $migration->changeField($table, 'ID', 'id', 'autoincrement');
         $migration->changeField($table, 'FK_entities', 'entities_id', 'integer');
         $migration->changeField($table, 'recursive', 'is_recursive', 'bool');
         $migration->changeField($table, 'active', 'is_active', 'bool');
         $migration->changeField($table, 'comments', 'comment', 'text');
         $migration->changeField($table, 'FK_entities', 'entities_id', 'integer');
         $migration->addField($table, 'deflate', 'bool', array('after' => 'is_active'));
         $migration->addField($table, 'debug', 'bool', array('after' => 'do_log'));
         $migration->addKey($table, 'entities_id');
         // Version 1.3.0
         $opt = array('after' => 'ip_end', 'update' => "'::1'", 'condition' => "WHERE `ip_start`=INET_ATON('127.0.0.1')");
         $migration->addField($table, 'ipv6', 'string', $opt);
     } else {
         $sql = "CREATE TABLE `glpi_plugin_webservices_clients` (\n                  `id` INT NOT NULL AUTO_INCREMENT,\n                  `entities_id` INT NOT NULL DEFAULT '0',\n                  `is_recursive` TINYINT( 1 ) NOT NULL DEFAULT '0',\n                  `name` VARCHAR( 255 ) NOT NULL ,\n                  `pattern` VARCHAR( 255 ) NOT NULL ,\n                  `ip_start` BIGINT NULL ,\n                  `ip_end` BIGINT NULL ,\n                  `ipv6`  VARCHAR( 255 ) NULL,\n                  `username` VARCHAR( 255 ) NULL ,\n                  `password` VARCHAR( 255 ) NULL ,\n                  `do_log` TINYINT NOT NULL DEFAULT '0',\n                  `debug` TINYINT NOT NULL DEFAULT '0',\n                  `is_active` TINYINT NOT NULL DEFAULT '0',\n                  `deflate` TINYINT NOT NULL DEFAULT '0',\n                  `comment` TEXT NULL ,\n                  PRIMARY KEY (`id`),\n                  KEY `entities_id` (`entities_id`)\n                ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci ";
         $DB->queryOrDie($sql, "SQL Error");
         $sql = "INSERT INTO\n                 `glpi_plugin_webservices_clients` (`id`, `entities_id`, `is_recursive`, `name`,\n                                                    `pattern`, `ip_start`, `ip_end` , `ipv6`,\n                                                    `do_log`, `is_active`, `comment`)\n                 VALUES (NULL, 0, 1, '" . __('Local', 'webservices') . "',\n                         '.*', INET_ATON('127.0.0.1'), INET_ATON('127.0.0.1'), '::1',\n                         1, 1, '" . __('Allow all from local', 'webservices') . "')";
         $DB->query($sql);
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:25,代码来源:client.class.php

示例8: array

Session::checkRight("profile", UPDATE);
Html::header(__('Duplicate computers', 'reports'), $_SERVER['PHP_SELF'], "config", "plugins");
$types = array(1 => __('MAC'), 2 => __('IP'), 3 => __('Serial number'));
if (isset($_POST["delete"]) && isset($_POST['id'])) {
    $query = "DELETE\n             FROM `glpi_plugin_reports_doublons_backlists`\n             WHERE `id` = '" . $_POST['id'] . "'";
    $DB->query($query);
} else {
    if (isset($_POST["add"]) && isset($_POST["type"]) && isset($_POST["addr"]) && strlen($_POST["addr"])) {
        $query = "INSERT INTO `glpi_plugin_reports_doublons_backlists`\n             SET `type` = '" . $_POST["type"] . "',\n                 `addr` = '" . trim($_POST["addr"]) . "',\n                 `comment` = '" . trim($_POST["comment"]) . "'";
        $DB->query($query);
    }
}
// Initial creation
if (TableExists("glpi_plugin_reports_doublons_backlist")) {
    $migration = new Migration(160);
    $migration->renameTable("glpi_plugin_reports_doublons_backlist", "glpi_plugin_reports_doublons_backlists");
    $migration->changeField("glpi_plugin_reports_doublons_backlists", "ID", "id", 'autoincrement');
    $migration->executeMigration();
} else {
    if (!TableExists("glpi_plugin_reports_doublons_backlists")) {
        $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_reports_doublons_backlists` (\n               `id` int(11) NOT NULL AUTO_INCREMENT,\n               `type` int(11) NOT NULL DEFAULT '0',\n               `addr` varchar(255) DEFAULT NULL,\n               `comment` varchar(255) DEFAULT NULL,\n               PRIMARY KEY (`id`)\n             ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
        $query = "INSERT INTO`glpi_plugin_reports_doublons_backlists`\n                    (`type`, `addr`, `comment`)\n             VALUES (1, '44:45:53:54:42:00', 'Nortel IPSECSHM Adapter'),\n                    (1, 'BA:D0:BE:EF:FA:CE', 'GlobeTrotter Module 3G+ Network Card'),\n                    (1, '00:53:45:00:00:00', 'WAN (PPP/SLIP) Interface'),\n                    (1, '80:00:60:0F:E8:00', 'Windows Mobile-based'),\n                    (2, '127.0.0.1', 'loopback'),\n                    (3, 'INVALID', 'from OCSNG'),\n                    (3, 'XxXxXxX', 'from IBM')";
        $DB->query($query);
    }
}
// ---------- Form ------------
echo "<div class='center'><table class='tab_cadre' cellpadding='5'>\n";
echo "<tr class='tab_bg_1 center'><th><a href='" . GLPI_ROOT . "/plugins/reports/front/config.form.php'>" . __('Reports plugin configuration', 'reports') . "</a><br />&nbsp;<br />" . sprintf(__('%1$s: %2$s'), __('Report configuration', 'reports'), __('Duplicate computers', 'reports')) . "</th></tr>\n";
$plug = new Plugin();
if ($plug->isActivated('reports')) {
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:doublons.config.php

示例9: 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());
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:hook.php

示例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();
     }
 }
开发者ID:equinoxefr,项目名称:order,代码行数:73,代码来源:order_item.class.php

示例11: install

 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());
         }
     }
 }
开发者ID:korial29,项目名称:order,代码行数:39,代码来源:reference_supplier.class.php

示例12: plugin_pdf_install

function plugin_pdf_install()
{
    global $DB;
    $migration = new Migration('0.84');
    if (!TableExists('glpi_plugin_pdf_profiles')) {
        $query = "CREATE TABLE IF NOT EXISTS\n               `glpi_plugin_pdf_profiles` (\n                  `id` int(11) NOT NULL,\n                  `profile` varchar(255) default NULL,\n                  `use` tinyint(1) default 0,\n                  PRIMARY KEY (`id`)\n               ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDir($query, $DB->error());
    } else {
        if (FieldExists('glpi_plugin_pdf_profiles', 'ID')) {
            //< 0.7.0
            $migration->changeField('glpi_plugin_pdf_profiles', 'ID', 'id', 'autoincrement');
        }
    }
    if (!TableExists('glpi_plugin_pdf_preference')) {
        $query = "CREATE TABLE IF NOT EXISTS\n               `glpi_plugin_pdf_preferences` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `users_id` int(11) NOT NULL COMMENT 'RELATION to glpi_users (id)',\n                  `itemtype` VARCHAR(100) NOT NULL COMMENT 'see define.php *_TYPE constant',\n                  `tabref` varchar(255) NOT NULL COMMENT 'ref of tab to display, or plugname_#, or option name',\n                  PRIMARY KEY (`id`)\n               ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
    } else {
        $migration->renameTable('glpi_plugin_pdf_preference', 'glpi_plugin_pdf_preferences');
        // 0.6.0
        if (FieldExists('glpi_plugin_pdf_preferences', 'user_id')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'user_id', 'users_id', 'integer', array('comment' => 'RELATION to glpi_users (id)'));
        }
        // 0.6.1
        if (FieldExists('glpi_plugin_pdf_preferences', 'FK_users')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'FK_users', 'users_id', 'integer', array('comment' => 'RELATION to glpi_users (id)'));
        }
        // 0.6.0
        if (FieldExists('glpi_plugin_pdf_preferences', 'cat')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'cat', 'itemtype', 'VARCHAR(100) NOT NULL', array('comment' => 'see define.php *_TYPE constant'));
        }
        // 0.6.1
        if (FieldExists('glpi_plugin_pdf_preferences', 'device_type')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'device_type', 'itemtype', 'VARCHAR(100) NOT NULL', array('comment' => 'see define.php *_TYPE constant'));
        }
        // 0.6.0
        if (FieldExists('glpi_plugin_pdf_preferences', 'table_num')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'table_num', 'tabref', 'string', array('comment' => 'ref of tab to display, or plugname_#, or option name'));
        }
        $migration->executeMigration();
    }
    // Give right to current Profile
    include_once GLPI_ROOT . '/plugins/pdf/inc/profile.class.php';
    $prof = new PluginPdfProfile();
    if (!$prof->getFromDB($_SESSION['glpiactiveprofile']['id'])) {
        $prof->add(array('id' => $_SESSION['glpiactiveprofile']['id'], 'profile' => $_SESSION['glpiactiveprofile']['name'], 'use' => 1));
    }
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:48,代码来源:hook.php

示例13: install

 static function install(Migration $migration)
 {
     global $DB;
     // From 0.2 to 1.0.0
     $table = 'glpi_plugin_uninstallcomputer_preference';
     if (TableExists($table)) {
         $migration->changeField($table, 'user_id', 'FK_users', "integer");
         $migration->addField($table, 'FK_template', 'integer');
         $migration->renameTable($table, getTableForItemType(__CLASS__));
     }
     $table = getTableForItemType(__CLASS__);
     // plugin already installed
     if (TableExists($table)) {
         // from 1.0.0 to 1.3.0
         if (FieldExists($table, 'ID')) {
             $migration->changeField($table, 'ID', 'id', 'autoincrement');
             $migration->changeField($table, 'FK_users', 'users_id', 'integer');
             $migration->changeField($table, 'FK_entities', 'entities_id', 'integer');
             $migration->changeField($table, 'FK_template', 'templates_id', 'integer');
             $migration->changeField($table, 'location', 'locations_id', "integer");
         }
         // plugin nevers installed
     } else {
         $query = "CREATE TABLE `" . $table . "` (\n                     `id` int(11) NOT NULL AUTO_INCREMENT,\n                     `users_id` int(11) NOT NULL,\n                     `entities_id` int(11) DEFAULT '0',\n                     `templates_id` int(11) DEFAULT '0',\n                     `locations_id` int(11) DEFAULT '0',\n                     PRIMARY KEY (`id`)\n                     ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->queryOrDie($query, $DB->error());
     }
     return true;
 }
开发者ID:pluginsGLPI,项目名称:uninstall,代码行数:28,代码来源:preference.class.php

示例14: install

 static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (TableExists("glpi_plugin_itilcategorygroups_categories_groups") && FieldExists("glpi_plugin_itilcategorygroups_categories_groups", 'is_active')) {
         $migration->renameTable("glpi_plugin_itilcategorygroups_categories_groups", $table);
     }
     if (!TableExists($table)) {
         $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n         `id` INT(11) NOT NULL AUTO_INCREMENT,\n         `is_active` TINYINT(1) NOT NULL DEFAULT '0',\n         `name` VARCHAR(255) COLLATE utf8_unicode_ci DEFAULT '',\n         `comment` TEXT COLLATE utf8_unicode_ci,\n         `date_mod` DATE default NULL,\n         `itilcategories_id` INT(11) NOT NULL DEFAULT '0',\n         `view_all_lvl1` TINYINT(1) NOT NULL DEFAULT '0',\n         `view_all_lvl2` TINYINT(1) NOT NULL DEFAULT '0',\n         `view_all_lvl3` TINYINT(1) NOT NULL DEFAULT '0',\n         `view_all_lvl4` TINYINT(1) NOT NULL DEFAULT '0',\n         `entities_id` INT(11) NOT NULL DEFAULT '0',\n         `is_recursive` TINYINT(1) NOT NULL DEFAULT '1',\n         `is_incident` TINYINT(1) NOT NULL DEFAULT '1',\n         `is_request` TINYINT(1) NOT NULL DEFAULT '1',\n         PRIMARY KEY (`id`),\n         KEY `entities_id` (`entities_id`),\n         KEY `itilcategories_id` (`itilcategories_id`),\n         KEY `is_incident` (`is_incident`),\n         KEY `is_request` (`is_request`),\n         KEY `is_recursive` (`is_recursive`),\n         KEY date_mod (date_mod)\n         ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;";
         $DB->query($query);
     }
     if (!FieldExists($table, 'view_all_lvl1')) {
         $migration->addField($table, 'view_all_lvl1', "TINYINT(1) NOT NULL DEFAULT '0'", array('after' => 'itilcategories_id'));
         $migration->addField($table, 'view_all_lvl2', "TINYINT(1) NOT NULL DEFAULT '0'", array('after' => 'itilcategories_id'));
         $migration->addField($table, 'view_all_lvl3', "TINYINT(1) NOT NULL DEFAULT '0'", array('after' => 'itilcategories_id'));
         $migration->addField($table, 'view_all_lvl4', "TINYINT(1) NOT NULL DEFAULT '0'", array('after' => 'itilcategories_id'));
         $migration->migrationOneTable($table);
     }
     return true;
 }
开发者ID:erchbox,项目名称:itilcategorygroups,代码行数:20,代码来源:category.class.php

示例15: plugin_ocsinventoryng_upgrademassocsimport13to14

function plugin_ocsinventoryng_upgrademassocsimport13to14()
{
    global $DB;
    $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();
}
开发者ID:geldarr,项目名称:hack-space,代码行数:44,代码来源:hook.php


注:本文中的Migration::renameTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。