本文整理汇总了PHP中Plugin::migrateItemType方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::migrateItemType方法的具体用法?PHP Plugin::migrateItemType怎么用?PHP Plugin::migrateItemType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin
的用法示例。
在下文中一共展示了Plugin::migrateItemType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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: 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);
}
}
}
示例4: plugin_addressing_install
function plugin_addressing_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/addressing/inc/profile.class.php";
$update = false;
if (!TableExists("glpi_plugin_addressing_display") && !TableExists("glpi_plugin_addressing") && !TableExists("glpi_plugin_addressing_configs")) {
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/empty-2.0.0.sql");
} else {
if (!TableExists("glpi_plugin_addressing_profiles") && TableExists("glpi_plugin_addressing_display") && !FieldExists("glpi_plugin_addressing_display", "ipconf1")) {
//1.4
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.4.sql");
}
if (!TableExists("glpi_plugin_addressing") && TableExists("glpi_plugin_addressing_display") && FieldExists("glpi_plugin_addressing_display", "ipconf1")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.5.sql");
}
if (TableExists("glpi_plugin_addressing_display") && !FieldExists("glpi_plugin_addressing", "ipdeb")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.6.sql");
}
if (TableExists("glpi_plugin_addressing_profiles") && FieldExists("glpi_plugin_addressing_profiles", "interface")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.7.0.sql");
}
if (!TableExists("glpi_plugin_addressing_configs")) {
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.8.0.sql");
$update = true;
}
if (TableExists("glpi_plugin_addressing_profiles") && !FieldExists("glpi_plugin_addressing_profiles", "use_ping_in_equipment")) {
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.9.0.sql");
$update = true;
}
}
if ($update) {
$query_ = "SELECT *\n FROM `glpi_plugin_addressing_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_addressing_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "'";
$result = $DB->query($query);
}
}
if (FieldExists("glpi_plugin_addressing_profiles", "name")) {
$query = "ALTER TABLE `glpi_plugin_addressing_profiles`\n DROP `name` ";
$result = $DB->query($query);
}
Plugin::migrateItemType(array(5000 => 'PluginAddressingAddressing', 5001 => 'PluginAddressingReport'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"));
}
//0.85 : new profile system
PluginAddressingProfile::migrateProfiles();
//Add all rights for current user profile
PluginAddressingProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
//Drop old profile table : not used anymore
$migration = new Migration("2.2.0");
$migration->dropTable('glpi_plugin_addressing_profiles');
return true;
}
示例5: plugin_webapplications_install
function plugin_webapplications_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/webapplications/inc/profile.class.php";
$update = false;
if (!TableExists("glpi_application") && !TableExists("glpi_plugin_appweb") && !TableExists("glpi_plugin_webapplications_webapplications")) {
$DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/empty-1.8.0.sql");
} else {
if (TableExists("glpi_application") && !TableExists("glpi_plugin_appweb")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.1.sql");
}
//from 1.1 version
if (TableExists("glpi_plugin_appweb") && !FieldExists("glpi_plugin_appweb", "location")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.3.sql");
}
//from 1.3 version
if (TableExists("glpi_plugin_appweb") && !FieldExists("glpi_plugin_appweb", "recursive")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.4.sql");
}
if (TableExists("glpi_plugin_appweb_profiles") && FieldExists("glpi_plugin_appweb_profiles", "interface")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.5.0.sql");
}
if (TableExists("glpi_plugin_appweb") && !FieldExists("glpi_plugin_appweb", "helpdesk_visible")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.5.1.sql");
}
if (!TableExists("glpi_plugin_webapplications_webapplications")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.6.0.sql");
}
//from 1.6 version
if (TableExists("glpi_plugin_webapplications_webapplications") && !FieldExists("glpi_plugin_webapplications_webapplications", "users_id_tech")) {
$DB->runFile(GLPI_ROOT . "/plugins/webapplications/sql/update-1.8.0.sql");
}
}
if ($update) {
$query_ = "SELECT *\n FROM `glpi_plugin_webapplications_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_webapplications_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$query = "ALTER TABLE `glpi_plugin_webapplications_profiles`\n DROP `name` ;";
$result = $DB->query($query);
Plugin::migrateItemType(array(1300 => 'PluginWebapplicationsWebapplication'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_webapplications_webapplications_items"));
Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance"), array("glpi_plugin_webapplications_webapplications_items"));
}
PluginWebapplicationsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
return true;
}
示例6: plugin_manufacturersimports_install
function plugin_manufacturersimports_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/manufacturersimports/inc/profile.class.php";
$update = false;
if (!TableExists("glpi_plugin_suppliertag_profiles") && !TableExists("glpi_plugin_manufacturersimports_profiles")) {
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/empty-1.5.0.sql");
} else {
if (TableExists("glpi_plugin_suppliertag_config") && !FieldExists("glpi_plugin_suppliertag_config", "FK_entities")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.2.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.3.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.4.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.5.0.sql");
} else {
if (TableExists("glpi_plugin_suppliertag_profiles") && FieldExists("glpi_plugin_suppliertag_profiles", "interface")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.2.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.3.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.4.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.5.0.sql");
} else {
if (!TableExists("glpi_plugin_manufacturersimports_profiles")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.3.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.4.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/manufacturersimports/sql/update-1.5.0.sql");
}
}
}
}
$query = "UPDATE `glpi_plugin_manufacturersimports_configs` \n SET `Supplier_url` = 'http://www.dell.com/support/troubleshooting/us/en/04/Index?c=us&l=en&s=bsd&cs=04&t=system&ServiceTag=' \n WHERE `name` ='Dell'";
$DB->query($query);
if ($update) {
$query_ = "SELECT *\n FROM `glpi_plugin_manufacturersimports_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_manufacturersimports_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$query = "ALTER TABLE `glpi_plugin_manufacturersimports_profiles`\n DROP `name` ;";
$result = $DB->query($query);
Plugin::migrateItemType(array(2150 => 'PluginManufacturersimportsModel', 2151 => 'PluginManufacturersimportsConfig'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_manufacturersimports_models", "glpi_plugin_manufacturersimports_logs"));
}
PluginManufacturersimportsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
return true;
}
示例7: plugin_racks_install
function plugin_racks_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/racks/inc/profile.class.php";
$update = false;
if (!TableExists("glpi_plugin_rack_profiles") && !TableExists("glpi_plugin_racks_profiles")) {
$DB->runFile(GLPI_ROOT . "/plugins/racks/sql/empty-1.4.1.sql");
} else {
if (TableExists("glpi_plugin_rack_content") && !FieldExists("glpi_plugin_rack_content", "first_powersupply")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.0.2.sql");
$DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql");
} else {
if (!TableExists("glpi_plugin_racks_profiles")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql");
}
}
}
//from 1.1 version
if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "otherserial")) {
$DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.2.1.sql");
}
if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "users_id_tech")) {
$DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.0.sql");
}
if (!TableExists("glpi_plugin_racks_racktypes")) {
$DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.2.sql");
}
if (TableExists("glpi_plugin_racks_racktypes") && !FieldExists("glpi_plugin_racks_racktypes", "is_recursive")) {
$DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.4.1.sql");
}
if ($update) {
$query_ = "SELECT *\n FROM `glpi_plugin_racks_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_racks_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$query = "ALTER TABLE `glpi_plugin_racks_profiles`\n DROP `name` ;";
$result = $DB->query($query);
Plugin::migrateItemType(array(4450 => 'PluginRacksRack', 4451 => 'PluginRacksOther'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_racks_racks_items", "glpi_plugin_racks_itemspecifications"));
}
PluginRacksProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
return true;
}
示例8: plugin_financialreports_install
function plugin_financialreports_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/financialreports/inc/profile.class.php";
$update = false;
if (!TableExists("glpi_plugin_state_profiles") && !TableExists("glpi_plugin_financialreports_configs")) {
$DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/empty-2.1.0.sql");
} else {
if (TableExists("glpi_plugin_state_parameters") && !FieldExists("glpi_plugin_state_parameters", "monitor")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.5.sql");
$DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.6.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.7.0.sql");
} else {
if (TableExists("glpi_plugin_state_profiles") && FieldExists("glpi_plugin_state_profiles", "interface")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.6.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.7.0.sql");
} else {
if (!TableExists("glpi_plugin_financialreports_configs")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.7.0.sql");
}
}
}
}
if ($update) {
//Do One time on 0.78
$query_ = "SELECT *\n FROM `glpi_plugin_financialreports_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_financialreports_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$query = "ALTER TABLE `glpi_plugin_financialreports_profiles`\n DROP `name` ;";
$result = $DB->query($query);
Plugin::migrateItemType(array(3450 => 'PluginFinancialreportsDisposalItem'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_financialreports_disposalitems"));
}
//Migrate profiles to the new system
PluginFinancialreportsProfile::initProfile();
PluginFinancialreportsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
$migration = new Migration("2.0.0");
$migration->dropTable('glpi_plugin_financialreports_profiles');
return true;
}
示例9: plugin_connections_install
function plugin_connections_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/connections/inc/profile.class.php";
$update = false;
//TODO: Use "Migration" class instead (available since GLPI v0.80)
// Go for 1.7.0
if (!TableExists('glpi_plugin_connection') && !TableExists('glpi_plugin_connections_connections')) {
// Fresh install
$DB->runFile(GLPI_ROOT . '/plugins/connections/sql/empty-1.7.0.sql');
// We're 1.6.0 update to 1.6.4
} elseif (TableExists('glpi_plugin_connections_connectionratesguaranteed') && !TableExists('glpi_plugin_connectiond_device')) {
$DB->runFile(GLPI_ROOT . '/plugins/connections/sql/update-1.6.0-to-1.6.4.sql');
} elseif (TableExists("glpi_plugin_connection") && !FieldExists("glpi_plugin_connection", "recursive")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.3.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.4.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.5.0.sql");
} elseif (TableExists("glpi_plugin_connection_profiles") && FieldExists("glpi_plugin_connection_profiles", "interface")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.4.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.3.0.sql");
} elseif (TableExists("glpi_plugin_connection") && !FieldExists("glpi_plugin_connection", "helpdesk_visible")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/connections/sql/update-1.3.0.sql");
}
if ($update) {
$query_ = "SELECT * FROM `glpi_plugin_connections_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_connections_profiles`\r\n SET `profiles_id` = '" . $data["id"] . "'\r\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$DB->query("ALTER TABLE `glpi_plugin_connections_profiles` DROP `name`;");
Plugin::migrateItemType(array(4400 => 'PluginConnectionsConnection'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_connections_connections_items"));
Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance", 1300 => "PluginWebapplicationsWebapplication"), array("glpi_plugin_connections_connections_items"));
}
if (TableExists("glpi_plugin_connections_profiles")) {
PluginConnectionsProfile::migrateProfiles();
}
PluginConnectionsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
return true;
}
示例10: plugin_routetables_install
function plugin_routetables_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/routetables/inc/profile.class.php";
$update = false;
if (!TableExists("glpi_plugin_routetable_profiles") && !TableExists("glpi_plugin_routetables_profiles")) {
$DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/empty-1.2.0.sql");
} else {
if (TableExists("glpi_plugin_routetable_profiles") && FieldExists("glpi_plugin_routetable_profiles", "interface")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.1.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.1.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.2.0.sql");
} else {
if (TableExists("glpi_plugin_routetable") && !FieldExists("glpi_plugin_routetable", "helpdesk_visible")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.1.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.2.0.sql");
} else {
if (!TableExists("glpi_plugin_routetables_profiles")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/routetables/sql/update-1.2.0.sql");
}
}
}
}
if ($update) {
$query_ = "SELECT *\n FROM `glpi_plugin_routetables_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_routetables_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$query = "ALTER TABLE `glpi_plugin_routetables_profiles`\n DROP `name` ;";
$result = $DB->query($query);
Plugin::migrateItemType(array(5100 => 'PluginRoutetablesRoutetable'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_routetables_routetables_items"));
}
PluginRoutetablesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
return true;
}
示例11: install
public static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
//Install
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_references` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `manufacturers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_manufacturers (id)',\n `manufacturers_reference` varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT '',\n `types_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtypes tables (id)',\n `models_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemmodels tables (id)',\n `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file',\n `templates_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)',\n `comment` text collate utf8_unicode_ci,\n `is_deleted` tinyint(1) NOT NULL default '0',\n `is_active` tinyint(1) NOT NULL default '1',\n `notepad` longtext collate utf8_unicode_ci,\n `date_mod` datetime default NULL,\n PRIMARY KEY (`id`),\n KEY `name` (`name`),\n KEY `entities_id` (`entities_id`),\n KEY `manufacturers_id` (`manufacturers_id`),\n KEY `types_id` (`types_id`),\n KEY `models_id` (`models_id`),\n KEY `templates_id` (`templates_id`),\n KEY `is_active` (`is_active`),\n KEY `is_deleted` (`is_deleted`),\n KEY date_mod (date_mod)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
} else {
//Upgrade
$migration->displayMessage("Upgrading {$table}");
//1.1.0
$migration->changeField($table, "FK_manufacturer", "FK_glpi_enterprise", "int(11) NOT NULL DEFAULT '0'");
///1.2.0
$migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
$migration->changeField($table, "FK_entities", "entities_id", "int(11) NOT NULL default '0'");
$migration->changeField($table, "recursive", "is_recursive", "tinyint(1) NOT NULL default '0'");
$migration->changeField($table, "name", "name", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->changeField($table, "FK_glpi_enterprise", "manufacturers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_manufacturers (id)'");
$migration->changeField($table, "FK_type", "types_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtypes tables (id)'");
$migration->changeField($table, "FK_model", "models_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemmodels tables (id)'");
$migration->changeField($table, "type", "itemtype", "varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file'");
$migration->changeField($table, "template", "templates_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)'");
$migration->changeField($table, "comments", "comment", "text collate utf8_unicode_ci");
$migration->changeField($table, "deleted", "is_deleted", "tinyint(1) NOT NULL default '0'");
$migration->addField($table, "notepad", "longtext collate utf8_unicode_ci");
$migration->addField($table, "is_active", "TINYINT(1) NOT NULL DEFAULT '1'");
$migration->addField($table, "date_mod", "datetime");
$migration->addKey($table, "name");
$migration->addKey($table, "entities_id");
$migration->addKey($table, "manufacturers_id");
$migration->addKey($table, "types_id");
$migration->addKey($table, "models_id");
$migration->addKey($table, "templates_id");
$migration->addKey($table, "is_deleted");
$migration->addKey($table, "is_active");
$migration->addKey($table, "date_mod");
$migration->migrationOneTable($table);
Plugin::migrateItemType(array(3151 => 'PluginOrderReference'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs"));
if (FieldExists('glpi_tickets', 'itemtype')) {
Plugin::migrateItemType(array(3151 => 'PluginOrderReference'), array("glpi_tickets"));
}
Plugin::migrateItemType(array(), array(), array($table));
//1.3.0
$DB->query("UPDATE `glpi_plugin_order_references` SET\n `itemtype`='ConsumableItem'\n WHERE `itemtype` ='Consumable'") or die($DB->error());
$DB->query("UPDATE `glpi_plugin_order_references` SET\n `itemtype`='CartridgeItem'\n WHERE `itemtype` ='Cartridge'") or die($DB->error());
//1.7.0
$migration->addField($table, "date_mod", "DATETIME NULL");
$migration->addKey($table, "date_mod");
//Displayprefs
$prefs = array(1 => 1, 2 => 4, 4 => 5, 5 => 9, 6 => 6, 7 => 7);
foreach ($prefs as $num => $rank) {
if (!countElementsInTable("glpi_displaypreferences", "`itemtype`='PluginOrderReference' AND `num`='{$num}'\n AND `users_id`='0'")) {
$DB->query("INSERT INTO glpi_displaypreferences\n VALUES (NULL,'PluginOrderReference','{$num}','{$rank}','0');");
}
}
//Fix error naming field
if (FieldExists($table, 'manufacturer_reference')) {
$migration->changeField($table, "manufacturer_reference", "manufacturers_reference", "varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT ''");
$migration->migrationOneTable($table);
}
//2.0.1
if (!FieldExists($table, 'manufacturers_reference')) {
$migration->addField($table, "manufacturers_reference", "varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT ''");
$migration->migrationOneTable($table);
}
}
}
示例12: 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());
}
}
}
}
示例13: plugin_customfields_upgradeto12
/**
* Upgrade => 1.2
*/
function plugin_customfields_upgradeto12()
{
global $DB;
$glpi_tables = array('glpi_plugin_customfields_software' => 'glpi_plugin_customfields_softwares', 'glpi_plugin_customfields_networking' => 'glpi_plugin_customfields_networkequipments', 'glpi_plugin_customfields_enterprises' => 'glpi_plugin_customfields_suppliers', 'glpi_plugin_customfields_docs' => 'glpi_plugin_customfields_documents', 'glpi_plugin_customfields_tracking' => 'glpi_plugin_customfields_tickets', 'glpi_plugin_customfields_user' => 'glpi_plugin_customfields_users', 'glpi_plugin_customfields_networking_ports' => 'glpi_plugin_customfields_networkports');
foreach ($glpi_tables as $oldtable => $newtable) {
if (!TableExists("{$newtable}") && TableExists("{$oldtable}")) {
$query = "RENAME TABLE `{$oldtable}` TO `{$newtable}`";
$DB->query($query) or die($DB->error());
}
}
if (TableExists("glpi_plugin_customfields")) {
$query = "RENAME TABLE `glpi_plugin_customfields`\n TO `glpi_plugin_customfields_itemtypes`";
$DB->query($query) or die($DB->error());
$query = "ALTER TABLE `glpi_plugin_customfields_itemtypes`\n CHANGE `ID` `id` int(11) NOT NULL auto_increment,\n CHANGE `device_type` `itemtype` VARCHAR(100) NOT NULL\n default ''";
$DB->query($query) or die($DB->error());
$tables = array('glpi_plugin_customfields_itemtypes');
Plugin::migrateItemType(array(-1 => 'Version'), array(), $tables);
$query = "SELECT `itemtype`\n FROM `glpi_plugin_customfields_itemtypes`\n WHERE `itemtype` <> 'Version' ";
$result = $DB->query($query);
$enabled = array();
while ($data = $DB->fetch_array($result)) {
$enabled[] = $data['itemtype'];
$table = plugin_customfields_table($data['itemtype']);
if (TableExists($table)) {
$query = "ALTER TABLE `{$table}`\n CHANGE `ID` `id` int(11) NOT NULL auto_increment";
$DB->query($query) or die($DB->error());
}
}
foreach ($enabled as $itemtype) {
$sql = "UPDATE `glpi_plugin_customfields_itemtypes`\n SET `enabled` = 1\n WHERE `itemtype` = '{$itemtype}';";
$DB->query($sql) or die($DB->error());
}
}
if (TableExists("glpi_plugin_customfields_dropdowns")) {
$query = "ALTER TABLE `glpi_plugin_customfields_dropdowns`\n CHANGE `ID` `id` int(11) NOT NULL auto_increment";
$DB->query($query) or die($DB->error());
}
if (TableExists("glpi_plugin_customfields_fields")) {
$query = "ALTER TABLE `glpi_plugin_customfields_fields`\n CHANGE `ID` `id` int(11) NOT NULL auto_increment,\n CHANGE `device_type` `itemtype` VARCHAR(100) NOT NULL\n default ''";
$DB->query($query) or die($DB->error());
$tables = array('glpi_plugin_customfields_fields');
Plugin::migrateItemType(array(-1 => 'Version'), array(), $tables);
}
if (TableExists("glpi_plugin_customfields_profiledata")) {
$query = "RENAME TABLE `glpi_plugin_customfields_profiledata` \n TO `glpi_plugin_customfields_profiles`";
$DB->query($query) or die($DB->error());
$query = "ALTER TABLE `glpi_plugin_customfields_profiles`\n CHANGE `ID` `id` int(11) NOT NULL auto_increment";
$DB->query($query) or die($DB->error());
}
}
示例14: plugin_archires_install
function plugin_archires_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/archires/inc/profile.class.php";
$update = false;
if (!TableExists("glpi_plugin_archires_config") && !TableExists("glpi_plugin_archires_views")) {
$DB->runFile(GLPI_ROOT . "/plugins/archires/sql/empty-2.1.0.sql");
} else {
$update = true;
// update to 1.3
if (TableExists("glpi_plugin_archires_display") && !FieldExists("glpi_plugin_archires_display", "display_ports")) {
$migration = new Migration(13);
$migration->addField("glpi_plugin_archires_display", "display_ports", "ENUM('1', '0') NOT NULL DEFAULT '0'");
$migration->executeMigration();
}
// update to 1.4
if (TableExists("glpi_plugin_archires_display") && !TableExists("glpi_plugin_archires_profiles")) {
plugin_archires_updateTo14();
}
// update to 1.5
if (TableExists("glpi_plugin_archires_display") && !TableExists("glpi_plugin_archires_image_device")) {
plugin_archires_updateTo15();
}
// update to 1.7.0
if (TableExists("glpi_plugin_archires_profiles") && FieldExists("glpi_plugin_archires_profiles", "interface")) {
plugin_archires_updateTo170();
}
// update to 1.7.2
if (TableExists("glpi_plugin_archires_config") && FieldExists("glpi_plugin_archires_config", "system")) {
$migration = new Migration(172);
$migration->dropField("glpi_plugin_archires_config", "system");
$migration->executeMigration();
}
// update to 1.8.0
if (!TableExists("glpi_plugin_archires_views")) {
plugin_archires_updateTo180();
}
// update to 2.1.0
if (TableExists("glpi_plugin_archires_appliancequeries") && !FieldExists("glpi_plugin_archires_appliancequeries", "plugin_appliances_appliances_id")) {
plugin_archires_updateTo210();
}
}
if ($update) {
$table = "glpi_plugin_archires_statecolors";
$index = "state";
if (isIndex($table, $index)) {
$query = "ALTER TABLE `{$table}` DROP INDEX `{$index}`;";
$result = $DB->query($query);
}
$query_ = "SELECT *\n FROM `glpi_plugin_archires_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_archires_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
if (FieldExists("glpi_plugin_archires_profiles", "name")) {
$query = "ALTER TABLE `glpi_plugin_archires_profiles`\n DROP `name`";
}
$result = $DB->query($query);
Plugin::migrateItemType(array(3000 => 'PluginArchiresLocationQuery', 3001 => 'PluginArchiresNetworkEquipmentQuery', 3002 => 'PluginArchiresApplianceQuery', 3003 => 'PluginArchiresView'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_archires_querytypes", "glpi_plugin_archires_imageitems"));
}
$rep_files_archires = realpath(GLPI_PLUGIN_DOC_DIR) . "/archires";
if (!is_dir($rep_files_archires) && !mkdir($rep_files_archires)) {
die(sprintf(__('Failed to create the directory %s. Verify that you have the correct permission'), $rep_files_archires));
}
PluginArchiresProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
return true;
}
示例15: plugin_domains_install
function plugin_domains_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/domains/inc/profile.class.php";
$install = false;
$update78 = false;
$update80 = false;
if (!TableExists("glpi_plugin_domain") && !TableExists("glpi_plugin_domains_domains")) {
$install = true;
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/empty-1.4.0.sql");
} else {
if (TableExists("glpi_plugin_domain") && !FieldExists("glpi_plugin_domain", "recursive")) {
$update78 = true;
$update80 = true;
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql");
} else {
if (TableExists("glpi_plugin_domain_profiles") && FieldExists("glpi_plugin_domain_profiles", "interface")) {
$update78 = true;
$update80 = true;
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql");
} else {
if (TableExists("glpi_plugin_domain") && !FieldExists("glpi_plugin_domain", "helpdesk_visible")) {
$update78 = true;
$update80 = true;
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.2.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql");
} else {
if (!TableExists("glpi_plugin_domains_domains")) {
$update78 = true;
$update80 = true;
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.3.0.sql");
}
}
}
}
}
//from 1.3 version
if (TableExists("glpi_plugin_domains_domains") && !FieldExists("glpi_plugin_domains_domains", "users_id_tech")) {
$DB->runFile(GLPI_ROOT . "/plugins/domains/sql/update-1.5.0.sql");
}
if ($install || $update78) {
//Do One time on 0.78
$query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginDomainsDomain' AND `name` = 'Alert Domains'";
$result = $DB->query($query_id) or die($DB->error());
$itemtype = $DB->result($result, 0, 'id');
$query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##domain.action## : ##domain.entity##',\n '##lang.domain.entity## :##domain.entity##\n ##FOREACHdomains##\n ##lang.domain.name## : ##domain.name## - ##lang.domain.dateexpiration## : ##domain.dateexpiration##\n ##ENDFOREACHdomains##',\n '<p>##lang.domain.entity## :##domain.entity##<br /> <br />\n ##FOREACHdomains##<br />\n ##lang.domain.name## : ##domain.name## - ##lang.domain.dateexpiration## : ##domain.dateexpiration##<br /> \n ##ENDFOREACHdomains##</p>');";
$result = $DB->query($query);
$query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Expired Domains', 0, 'PluginDomainsDomain', 'ExpiredDomains',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');";
$result = $DB->query($query);
$query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Domains Which Expire', 0, 'PluginDomainsDomain', 'DomainsWhichExpire',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');";
$result = $DB->query($query);
}
if ($update78) {
$query_ = "SELECT *\n FROM `glpi_plugin_domains_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_domains_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$query = "ALTER TABLE `glpi_plugin_domains_profiles`\n DROP `name` ;";
$result = $DB->query($query);
Plugin::migrateItemType(array(4400 => 'PluginDomainsDomain'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_domains_domains_items"));
Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance", 1300 => "PluginWebapplicationsWebapplication"), array("glpi_plugin_domains_domains_items"));
}
CronTask::Register('PluginDomainsDomain', 'DomainsAlert', DAY_TIMESTAMP);
PluginDomainsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
return true;
}