本文整理汇总了PHP中Migration::dropTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::dropTable方法的具体用法?PHP Migration::dropTable怎么用?PHP Migration::dropTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::dropTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plugin_moreticket_install
function plugin_moreticket_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/moreticket/inc/profile.class.php";
if (!TableExists("glpi_plugin_moreticket_configs")) {
// table sql creation
$DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/empty-1.2.0.sql");
}
PluginMoreticketProfile::initProfile();
PluginMoreticketProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
$migration = new Migration("1.1.0");
$migration->dropTable('glpi_plugin_moreticket_profiles');
if (!FieldExists("glpi_plugin_moreticket_configs", "solution_status")) {
$DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.1.sql");
}
if (FieldExists("glpi_plugin_moreticket_waitingtypes", "is_helpdeskvisible")) {
$DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.2.sql");
}
if (!FieldExists("glpi_plugin_moreticket_closetickets", "documents_id")) {
$DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.3.sql");
}
if (!FieldExists("glpi_plugin_moreticket_configs", "date_report_mandatory")) {
$DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.2.0.sql");
}
return true;
}
示例2: install
static function install(Migration $migration)
{
global $DB;
// Table no longer needed in GLPI 0.85+; drop it. Needed for upgrades
$migration->dropTable(getTableForItemType(__CLASS__));
PluginSimcardProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
}
示例3: plugin_environment_install
function plugin_environment_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/environment/inc/profile.class.php";
$update = false;
if (TableExists("glpi_plugin_environment_profiles") && FieldExists("glpi_plugin_environment_profiles", "interface")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.3.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.4.0.sql");
} else {
if (TableExists("glpi_plugin_environment_profiles") && FieldExists("glpi_plugin_environment_profiles", "connections")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.4.0.sql");
}
}
if ($update) {
//Do One time on 0.78
$query_ = "SELECT *\n FROM `glpi_plugin_environment_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_environment_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$query = "ALTER TABLE `glpi_plugin_environment_profiles`\n DROP `name` ;";
$result = $DB->query($query);
}
PluginEnvironmentProfile::initProfile();
PluginEnvironmentProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
$migration = new Migration("1.8.0");
$migration->dropTable('glpi_plugin_environment_profiles');
$_SESSION["glpi_plugin_environment_installed"] = 1;
return true;
}
示例4: 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;
}
示例5: plugin_timelineticket_install
function plugin_timelineticket_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/timelineticket/inc/profile.class.php";
include_once GLPI_ROOT . "/plugins/timelineticket/inc/config.class.php";
$migration = new Migration(160);
// installation
if (!TableExists("glpi_plugin_timelineticket_states")) {
$query = "CREATE TABLE `glpi_plugin_timelineticket_states` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `tickets_id` int(11) NOT NULL DEFAULT '0',\n `date` datetime DEFAULT NULL,\n `old_status` varchar(255) DEFAULT NULL,\n `new_status` varchar(255) DEFAULT NULL,\n `delay` INT( 11 ) NULL,\n PRIMARY KEY (`id`),\n KEY `tickets_id` (`tickets_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->query($query) or die($DB->error());
}
if (!TableExists("glpi_plugin_timelineticket_assigngroups")) {
$query = "CREATE TABLE `glpi_plugin_timelineticket_assigngroups` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `tickets_id` int(11) NOT NULL DEFAULT '0',\n `date` datetime DEFAULT NULL,\n `groups_id` varchar(255) DEFAULT NULL,\n `begin` INT( 11 ) NULL,\n `delay` INT( 11 ) NULL,\n PRIMARY KEY (`id`),\n KEY `tickets_id` (`tickets_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->query($query) or die($DB->error());
}
if (!TableExists("glpi_plugin_timelineticket_assignusers")) {
$query = "CREATE TABLE `glpi_plugin_timelineticket_assignusers` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `tickets_id` int(11) NOT NULL DEFAULT '0',\n `date` datetime DEFAULT NULL,\n `users_id` varchar(255) DEFAULT NULL,\n `begin` INT(11) NULL,\n `delay` INT(11) NULL,\n PRIMARY KEY (`id`),\n KEY `tickets_id` (`tickets_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->query($query) or die($DB->error());
}
if (!TableExists("glpi_plugin_timelineticket_grouplevels")) {
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_timelineticket_grouplevels` (\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 `groups` longtext collate utf8_unicode_ci,\n `rank` smallint(6) NOT NULL default '0',\n `comment` text collate utf8_unicode_ci,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
if (!TableExists("glpi_plugin_timelineticket_configs")) {
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_timelineticket_configs` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `add_waiting` int(11) NOT NULL DEFAULT '1',\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
$status = array('new' => Ticket::INCOMING, 'assign' => Ticket::ASSIGNED, 'plan' => Ticket::PLANNED, 'waiting' => Ticket::WAITING, 'solved' => Ticket::SOLVED, 'closed' => Ticket::CLOSED);
// Update field in tables
foreach (array('glpi_plugin_timelineticket_states') as $table) {
// Migrate datas
foreach ($status as $old => $new) {
$query = "UPDATE `{$table}`\n SET `old_status` = '{$new}'\n WHERE `old_status` = '{$old}'";
$DB->queryOrDie($query, "0.84 status in {$table} {$old} to {$new}");
$query = "UPDATE `{$table}`\n SET `new_status` = '{$new}'\n WHERE `new_status` = '{$old}'";
$DB->queryOrDie($query, "0.84 status in {$table} {$old} to {$new}");
}
}
PluginTimelineticketConfig::createFirstConfig();
if (isset($_SESSION['glpiactiveprofile']) && isset($_SESSION['glpiactiveprofile']['id'])) {
PluginTimelineticketProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
}
$migration = new Migration("0.90+1.0");
$migration->dropTable('glpi_plugin_timelineticket_profiles');
return true;
}
示例6: plugin_racks_uninstall
function plugin_racks_uninstall()
{
global $DB;
include_once GLPI_ROOT . "/plugins/racks/inc/profile.class.php";
include_once GLPI_ROOT . "/plugins/racks/inc/menu.class.php";
$migration = new Migration("1.6.1");
$tables = array("glpi_plugin_racks_racks", "glpi_plugin_racks_racks_items", "glpi_plugin_racks_itemspecifications", "glpi_plugin_racks_rackmodels", "glpi_plugin_racks_roomlocations", "glpi_plugin_racks_connections", "glpi_plugin_racks_configs", "glpi_plugin_racks_others", "glpi_plugin_racks_othermodels", "glpi_plugin_racks_racktypes", "glpi_plugin_racks_rackstates");
foreach ($tables as $table) {
$migration->dropTable($table);
}
//old versions
$tables = array("glpi_plugin_rack", "glpi_plugin_rack_content", "glpi_plugin_rack_device_spec", "glpi_plugin_rack_profiles", "glpi_plugin_racks_profiles", "glpi_plugin_rack_config", "glpi_dropdown_plugin_rack_room_locations", "glpi_dropdown_plugin_rack_ways", "glpi_plugin_rack_others", "glpi_dropdown_plugin_rack_others_type");
foreach ($tables as $table) {
$migration->dropTable($table);
}
$tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_items_tickets", "glpi_dropdowntranslations");
foreach ($tables_glpi as $table_glpi) {
$DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` LIKE 'PluginRacks%';");
}
//Delete rights associated with the plugin
$profileRight = new ProfileRight();
foreach (PluginRacksProfile::getAllRights() as $right) {
$profileRight->deleteByCriteria(array('name' => $right['field']));
}
PluginRacksProfile::removeRightsFromSession();
PluginRacksProfile::removeRightsFromDB();
PluginRacksMenu::removeRightsFromSession();
return true;
}
示例7: plugin_pdf_uninstall
function plugin_pdf_uninstall()
{
global $DB;
$tables = array("glpi_plugin_pdf_preference", "glpi_plugin_pdf_preferences", "glpi_plugin_pdf_profiles");
$migration = new Migration('0.84');
foreach ($tables as $table) {
$migration->dropTable($table);
}
return true;
}
示例8: plugin_positions_install
function plugin_positions_install()
{
global $DB, $CFG_GLPI;
include_once GLPI_ROOT . "/plugins/positions/inc/profile.class.php";
if (!TableExists("glpi_plugin_positions_positions")) {
$DB->runFile(GLPI_ROOT . "/plugins/positions/sql/empty-4.2.2.sql");
}
//v1.0.0 to V2.0.0
if (TableExists("glpi_plugin_positions_positions_items") && !FieldExists("glpi_plugin_positions_positions_items", "items_id")) {
$query = "ALTER TABLE `glpi_plugin_positions_positions` \r\n ADD `items_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)';";
$result = $DB->query($query);
$query = "ALTER TABLE `glpi_plugin_positions_positions` \r\n ADD `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file';";
$result = $DB->query($query);
$query_ = "SELECT *\r\n FROM `glpi_plugin_positions_positions_items` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_positions_positions`\r\n SET `items_id` = '" . $data["items_id"] . "',\r\n `itemtype` = '" . $data["itemtype"] . "'\r\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$query = "DROP TABLE `glpi_plugin_positions_positions_items`;";
$result = $DB->query($query);
}
//v1.0.0 to V2.0.0
if (!TableExists("glpi_plugin_positions_infos")) {
$query = "CREATE TABLE `glpi_plugin_positions_infos` (\r\n `id` int(11) NOT NULL auto_increment,\r\n `name` varchar(255) collate utf8_unicode_ci default NULL,\r\n `entities_id` int(11) NOT NULL default '0',\r\n `is_recursive` tinyint(1) NOT NULL default '0',\r\n `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file',\r\n `fields` text collate utf8_unicode_ci,\r\n `comment` text collate utf8_unicode_ci,\r\n `notepad` longtext collate utf8_unicode_ci,\r\n `date_mod` datetime NULL default NULL,\r\n `is_active` tinyint(1) NOT NULL DEFAULT '0',\r\n `is_deleted` tinyint(1) NOT NULL default '0',\r\n PRIMARY KEY (`id`)\r\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$result = $DB->query($query);
}
//to V3.0.0
if (TableExists("glpi_plugin_positions_positions") && FieldExists("glpi_plugin_positions_positions", "documents_id")) {
$query = "ALTER TABLE `glpi_plugin_positions_positions` DROP `documents_id`;";
$result = $DB->query($query);
}
// Update to 4.0.1
if (!FieldExists("glpi_plugin_positions_positions", "width") && !FieldExists("glpi_plugin_positions_positions", "height")) {
$DB->runFile(GLPI_ROOT . "/plugins/positions/sql/update-4.0.1.sql");
}
//to v4.2.2
if (!TableExists("glpi_plugin_positions_configs")) {
//add table config
$query = "CREATE TABLE `glpi_plugin_positions_configs` (\r\n `id` int(11) NOT NULL auto_increment,\r\n `use_view_all_object` tinyint(1) NOT NULL default '0',\r\n PRIMARY KEY (`id`)\r\n )ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$result = $DB->query($query);
$query = "INSERT INTO `glpi_plugin_positions_configs` (`id`,`use_view_all_object`) VALUES ('1', '0');";
$DB->query($query);
//add fields locations_id
$query = "ALTER TABLE `glpi_plugin_positions_positions` \r\n ADD `locations_id` int(11) NOT NULL default '0' COMMENT 'RELATION to table glpi_locations';";
$result = $DB->query($query);
include GLPI_ROOT . "/plugins/positions/sql/update_421_422.php";
update421to422();
}
if (TableExists("glpi_plugin_positions_profiles")) {
$notepad_tables = array('glpi_plugin_positions_positions');
foreach ($notepad_tables as $t) {
// Migrate data
if (FieldExists($t, 'notepad')) {
$query = "SELECT id, notepad\r\n FROM `{$t}`\r\n WHERE notepad IS NOT NULL\r\n AND notepad <>'';";
foreach ($DB->request($query) as $data) {
$iq = "INSERT INTO `glpi_notepads`\r\n (`itemtype`, `items_id`, `content`, `date`, `date_mod`)\r\n VALUES ('PluginPositionsPosition', '" . $data['id'] . "',\r\n '" . addslashes($data['notepad']) . "', NOW(), NOW())";
$DB->queryOrDie($iq, "0.85 migrate notepad data");
}
$query = "ALTER TABLE `glpi_plugin_positions_positions` DROP COLUMN `notepad`;";
$DB->query($query);
}
}
}
$rep_files_positions = GLPI_PLUGIN_DOC_DIR . "/positions";
if (!is_dir($rep_files_positions)) {
mkdir($rep_files_positions);
}
$rep_files_positions_pics = GLPI_PLUGIN_DOC_DIR . "/positions/pics";
if (!is_dir($rep_files_positions_pics)) {
mkdir($rep_files_positions_pics);
}
PluginPositionsProfile::initProfile();
PluginPositionsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
$migration = new Migration("4.2.2");
$migration->dropTable('glpi_plugin_positions_profiles');
return true;
}
示例9: plugin_databases_install
function plugin_databases_install()
{
global $DB;
include_once GLPI_ROOT . "/plugins/databases/inc/profile.class.php";
$update = false;
if (!TableExists("glpi_plugin_sgbd") && !TableExists("glpi_plugin_databases_databases")) {
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/empty-1.7.0.sql");
} else {
if (TableExists("glpi_plugin_sgbd") && !TableExists("glpi_plugin_sgbd_instances")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql");
} else {
if (TableExists("glpi_plugin_sgbd") && !TableExists("glpi_dropdown_plugin_sgbd_category")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.0.sql");
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql");
} else {
if (TableExists("glpi_plugin_sgbd") && !FieldExists("glpi_plugin_sgbd", "helpdesk_visible")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.2.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql");
} else {
if (!TableExists("glpi_plugin_databases_databases")) {
$update = true;
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.3.0.sql");
}
}
}
}
}
//from 1.3 version
if (TableExists("glpi_plugin_databases_databases") && !FieldExists("glpi_plugin_databases_databases", "users_id_tech")) {
$DB->runFile(GLPI_ROOT . "/plugins/databases/sql/update-1.5.0.sql");
}
if (TableExists("glpi_plugin_databases_profiles")) {
$notepad_tables = array('glpi_plugin_databases_databases');
foreach ($notepad_tables as $t) {
// Migrate data
if (FieldExists($t, 'notepad')) {
$query = "SELECT id, notepad\n FROM `{$t}`\n WHERE notepad IS NOT NULL\n AND notepad <>'';";
foreach ($DB->request($query) as $data) {
$iq = "INSERT INTO `glpi_notepads`\n (`itemtype`, `items_id`, `content`, `date`, `date_mod`)\n VALUES ('" . getItemTypeForTable($t) . "', '" . $data['id'] . "',\n '" . addslashes($data['notepad']) . "', NOW(), NOW())";
$DB->queryOrDie($iq, "0.85 migrate notepad data");
}
$query = "ALTER TABLE `glpi_plugin_databases_databases` DROP COLUMN `notepad`;";
$DB->query($query);
}
}
}
if ($update) {
$query_ = "SELECT *\n FROM `glpi_plugin_databases_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_databases_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$query = "ALTER TABLE `glpi_plugin_databases_profiles`\n DROP `name` ;";
$result = $DB->query($query);
$query = "SELECT `entities_id`,`is_recursive`,`id` FROM `glpi_plugin_databases_databases` ";
$result = $DB->query($query);
$number = $DB->numrows($result);
if ($number) {
while ($data = $DB->fetch_array($result)) {
$query = "UPDATE `glpi_plugin_databases_instances`\n SET `entities_id` = '" . $data["entities_id"] . "'\n AND `is_recursive` = '" . $data["is_recursive"] . "'\n WHERE `plugin_databases_databases_id` = '" . $data["id"] . "' ";
$DB->query($query) or die($DB->error());
$query = "UPDATE `glpi_plugin_databases_scripts`\n SET `entities_id` = '" . $data["entities_id"] . "'\n AND `is_recursive` = '" . $data["is_recursive"] . "'\n WHERE `plugin_databases_databases_id` = '" . $data["id"] . "' ";
$DB->query($query) or die($DB->error());
}
}
Plugin::migrateItemType(array(2400 => 'PluginDatabasesDatabase'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"), array("glpi_plugin_databases_databases_items"));
Plugin::migrateItemType(array(1200 => "PluginAppliancesAppliance", 1300 => "PluginWebapplicationsWebapplication"), array("glpi_plugin_databases_databases_items"));
}
PluginDatabasesProfile::initProfile();
PluginDatabasesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
$migration = new Migration("1.7.0");
$migration->dropTable('glpi_plugin_databases_profiles');
return true;
}
示例10: plugin_badges_install
//.........这里部分代码省略.........
plugin_badges_configure15();
$DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
} else {
if (TableExists("glpi_plugin_badges_profiles") && FieldExists("glpi_plugin_badges_profiles", "interface")) {
$update78 = true;
$DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.0.sql");
plugin_badges_configure15();
$DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
} else {
if (TableExists("glpi_plugin_badges") && !FieldExists("glpi_plugin_badges", "date_mod")) {
$update78 = true;
$DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql");
$DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
} else {
if (!TableExists("glpi_plugin_badges_badgetypes")) {
$update78 = true;
$DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
} else {
if (TableExists("glpi_plugin_badges_profiles")) {
$update85 = true;
}
}
}
}
}
}
if (!TableExists("glpi_plugin_badges_requests")) {
$update201 = true;
$DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-2.0.1.sql");
}
if ($install || $update201) {
// Badge request notification
$query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Request'";
$result = $DB->query($query_id) or die($DB->error());
$itemtype = $DB->result($result, 0, 'id');
if (empty($itemtype)) {
$query_id = "INSERT INTO `glpi_notificationtemplates`(`id`, `name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('','Access Badges Request','PluginBadgesBadge', NOW(),'','');";
$result = $DB->query($query_id) or die($DB->error());
$query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Request'";
$result = $DB->query($query_id) or die($DB->error());
$itemtype = $DB->result($result, 0, 'id');
}
$query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\n VALUES(NULL, '" . $itemtype . "', '','##badge.action## : ##badge.entity##',\r\n '##lang.badge.entity## :##badge.entity##\r\n ##FOREACHbadgerequest## \r\n ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##\t\r\n ##lang.badgerequest.requester## : ##badgerequest.requester##\t\r\n ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##\t\r\n ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##\r\n ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##\r\n ##ENDFOREACHbadgerequest##',\r\n '<p>##lang.badge.entity## :##badge.entity##<br /> <br />\r\n ##FOREACHbadgerequest##<br />\r\n ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##<br />\t\r\n ##lang.badgerequest.requester## : ##badgerequest.requester##<br />\r\n ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##<br />\r\n ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##<br />\r\n ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##<br />\r\n ##ENDFOREACHbadgerequest##</p>');";
$result = $DB->query($query);
$query = "INSERT INTO `glpi_notifications`\r\n VALUES (NULL, 'Access badge request', 0, 'PluginBadgesBadge', 'AccessBadgeRequest',\r\n 'mail','" . $itemtype . "',\r\n '', 1, 1, '" . date('Y-m-d H:i:s') . "');";
$result = $DB->query($query);
}
// Badge expiration alert notification
$query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Return'";
$result = $DB->query($query_id) or die($DB->error());
$itemtype = $DB->result($result, 0, 'id');
if (empty($itemtype)) {
$query_id = "INSERT INTO `glpi_notificationtemplates`(`id`, `name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('','Access Badges Return','PluginBadgesBadge', NOW(),'','');";
$result = $DB->query($query_id) or die($DB->error());
$query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Access Badges Return'";
$result = $DB->query($query_id) or die($DB->error());
$itemtype = $DB->result($result, 0, 'id');
}
$query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\n VALUES(NULL, '" . $itemtype . "', '','##badge.action## : ##badge.entity##',\r\n '##lang.badge.entity## :##badge.entity##\r\n ##FOREACHbadgerequest## \r\n ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##\t\r\n ##lang.badgerequest.requester## : ##badgerequest.requester##\t\r\n ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##\t\r\n ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##\r\n ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##\r\n ##ENDFOREACHbadgerequest##',\r\n '<p>##lang.badge.entity## :##badge.entity##<br /> <br />\r\n ##FOREACHbadgerequest##<br />\r\n ##lang.badgerequest.arrivaldate## : ##badgerequest.arrivaldate##<br />\t\r\n ##lang.badgerequest.requester## : ##badgerequest.requester##<br />\r\n ##lang.badgerequest.visitorfirstname## : ##badgerequest.visitorfirstname##<br />\r\n ##lang.badgerequest.visitorrealname## : ##badgerequest.visitorrealname##<br />\r\n ##lang.badgerequest.visitorsociety## : ##badgerequest.visitorsociety##<br />\r\n ##ENDFOREACHbadgerequest##</p>');";
$result = $DB->query($query);
$query = "INSERT INTO `glpi_notifications`\r\n VALUES (NULL, 'Access badge return', 0, 'PluginBadgesBadge', 'BadgesReturn',\r\n 'mail','" . $itemtype . "',\r\n '', 1, 1, '" . date('Y-m-d H:i:s') . "');";
$result = $DB->query($query);
if ($update78) {
$query_ = "SELECT *\r\n FROM `glpi_plugin_badges_profiles` ";
$result_ = $DB->query($query_);
if ($DB->numrows($result_) > 0) {
while ($data = $DB->fetch_array($result_)) {
$query = "UPDATE `glpi_plugin_badges_profiles`\r\n SET `profiles_id` = '" . $data["id"] . "'\r\n WHERE `id` = '" . $data["id"] . "';";
$result = $DB->query($query);
}
}
$query = "ALTER TABLE `glpi_plugin_badges_profiles`\r\n DROP `name` ;";
$result = $DB->query($query);
Plugin::migrateItemType(array(1600 => 'PluginBadgesBadge'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"));
}
if ($update85) {
$notepad_tables = array('glpi_plugin_badges_badges');
foreach ($notepad_tables as $t) {
// Migrate data
if (FieldExists($t, 'notepad')) {
$query = "SELECT id, notepad\r\n FROM `{$t}`\r\n WHERE notepad IS NOT NULL\r\n AND notepad <>'';";
foreach ($DB->request($query) as $data) {
$iq = "INSERT INTO `glpi_notepads`\r\n (`itemtype`, `items_id`, `content`, `date`, `date_mod`)\r\n VALUES ('" . getItemTypeForTable($t) . "', '" . $data['id'] . "',\r\n '" . addslashes($data['notepad']) . "', NOW(), NOW())";
$DB->queryOrDie($iq, "0.85 migrate notepad data");
}
$query = "ALTER TABLE `glpi_plugin_badges_badges` DROP COLUMN `notepad`;";
$DB->query($query);
}
}
}
CronTask::Register('PluginBadgesBadge', 'BadgesAlert', DAY_TIMESTAMP);
CronTask::Register('PluginBadgesReturn', 'BadgesReturnAlert', DAY_TIMESTAMP);
PluginBadgesProfile::initProfile();
PluginBadgesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
$migration = new Migration("2.0.0");
$migration->dropTable('glpi_plugin_badges_profiles');
return true;
}
示例11: plugin_archires_updateTo15
function plugin_archires_updateTo15()
{
$migration = new Migration(15);
$migration->changeField("glpi_plugin_archires_profiles", "is_default", "is_default", "smallint(6) NOT NULL default '0'");
$query = "UPDATE `glpi_plugin_archires_profiles`\n SET `is_default` = '0'\n WHERE `is_default` = '1'";
$DB->queryOrDie($query, __('1.5 insert into glpi_plugin_archires_profiles ', 'archires') . $DB->error());
$query = "UPDATE `glpi_plugin_archires_profiles`\n SET `is_default` = '1'\n WHERE `is_default` = '2'";
$DB->queryOrDie($query, __('1.5 insert into glpi_plugin_archires_profiles ', 'archires') . $DB->error());
$migration->renameTable("glpi_plugin_archires_color", "glpi_plugin_archires_color_iface");
$migration->renameTable("glpi_plugin_archires_config", "glpi_plugin_archires_image_device");
$migration->dropTable("glpi_plugin_archires_display");
if (!TableExists("glpi_plugin_archires_color_state")) {
$query = "CREATE TABLE `glpi_plugin_archires_color_state` (\n `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `state` INT( 11 ) NOT NULL ,\n `color` VARCHAR( 50 ) collate utf8_unicode_ci NOT NULL\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->queryOrDie($query, __('1.5 create glpi_plugin_archires_color_state ', 'archires') . $DB->error());
}
if (!TableExists("glpi_plugin_archires_query_location")) {
$query = "CREATE TABLE `glpi_plugin_archires_query_location` (\n `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `FK_entities` int(11) NOT NULL default '0',\n `name` VARCHAR( 50 ) collate utf8_unicode_ci NOT NULL,\n `location` VARCHAR( 50 ) collate utf8_unicode_ci NOT NULL DEFAULT '0',\n `child` smallint(6) NOT NULL default '0',\n `network` INT( 11 ) NOT NULL DEFAULT '0',\n `status` INT( 11 ) NOT NULL DEFAULT '0',\n `FK_group` INT( 11 ) NOT NULL DEFAULT '0',\n `FK_config` INT( 11 ) NOT NULL DEFAULT '0',\n `FK_vlan` INT( 11 ) NOT NULL DEFAULT '0',\n `link` smallint(6) NOT NULL default '1',\n `notes` LONGTEXT,\n `deleted` smallint(6) NOT NULL default '0'\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->queryOrDie($query, __('1.5 create glpi_plugin_archires_query_location ', 'archires') . $DB->error());
}
if (!TableExists("glpi_plugin_archires_query_switch")) {
$query = "CREATE TABLE `glpi_plugin_archires_query_switch` (\n `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `FK_entities` int(11) NOT NULL default '0',\n `name` VARCHAR( 50 ) collate utf8_unicode_ci NOT NULL,\n `switch` INT( 11 ) NOT NULL DEFAULT '0',\n `network` INT( 11 ) NOT NULL DEFAULT '0',\n `status` INT( 11 ) NOT NULL DEFAULT '0',\n `FK_group` INT( 11 ) NOT NULL DEFAULT '0',\n `FK_config` INT( 11 ) NOT NULL DEFAULT '0',\n `FK_vlan` INT( 11 ) NOT NULL DEFAULT '0',\n `link` smallint(6) NOT NULL default '1',\n `notes` LONGTEXT,\n `deleted` smallint(6) NOT NULL default '0'\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->queryOrDie($query, __('1.5 create glpi_plugin_archires_query_switch ', 'archires') . $DB->error());
}
if (!TableExists("glpi_plugin_archires_query_applicatifs")) {
$query = "CREATE TABLE `glpi_plugin_archires_query_applicatifs` (\n `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `FK_entities` int(11) NOT NULL default '0',\n `name` VARCHAR( 50 ) collate utf8_unicode_ci NOT NULL,\n `applicatifs` INT( 11 ) NOT NULL DEFAULT '0',\n `network` INT( 11 ) NOT NULL DEFAULT '0',\n `status` INT( 11 ) NOT NULL DEFAULT '0',\n `FK_group` INT( 11 ) NOT NULL DEFAULT '0',\n `FK_config` INT( 11 ) NOT NULL DEFAULT '0',\n `FK_vlan` INT( 11 ) NOT NULL DEFAULT '0',\n `link` smallint(6) NOT NULL default '1',\n `notes` LONGTEXT,\n `deleted` smallint(6) NOT NULL default '0'\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->queryOrDie($query, __('1.5 create glpi_plugin_archires_query_applicatifs ', 'archires') . $DB->error());
}
if (!TableExists("glpi_plugin_archires_query_type")) {
$query = "CREATE TABLE `glpi_plugin_archires_query_type` (\n `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `type_query` INT( 11 ) NOT NULL ,\n `type` INT( 11 ) NOT NULL ,\n `device_type` INT( 11 ) NOT NULL,\n `FK_query` INT( 11 ) NOT NULL\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->queryOrDie($query, __('1.5 create glpi_plugin_archires_query_type ', 'archires') . $DB->error());
}
if (!TableExists("glpi_plugin_archires_config")) {
$query = "CREATE TABLE `glpi_plugin_archires_config` (\n `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `FK_entities` int(11) NOT NULL default '0',\n `name` VARCHAR( 250 ) collate utf8_unicode_ci NOT NULL,\n `computer` smallint(6) NOT NULL default '0',\n `networking` smallint(6) NOT NULL default '0',\n `printer` smallint(6) NOT NULL default '0',\n `peripheral` smallint(6) NOT NULL default '0',\n `phone` smallint(6) NOT NULL default '0',\n `display_ports` smallint(6) NOT NULL default '0',\n `display_ip` smallint(6) NOT NULL default '0',\n `display_type` smallint(6) NOT NULL default '0',\n `display_state` smallint(6) NOT NULL default '0',\n `display_location` smallint(6) NOT NULL default '0',\n `display_entity` smallint(6) NOT NULL default '0',\n `system` smallint(6) NOT NULL default '0',\n `engine` smallint(6) NOT NULL default '0',\n `format` smallint(6) NOT NULL default '0',\n `deleted` smallint(6) NOT NULL default '0'\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->queryOrDie($query, __('1.5 create glpi_plugin_archires_config ', 'archires') . $DB->error());
}
$query = "INSERT INTO `glpi_plugin_archires_config`\n (`ID`,`FK_entities`,`name`, `computer` , `networking`, `printer`, `peripheral`,\n `phone`, `display_ports`, `display_ip`, `display_type`, `display_state`,\n `display_location`, `display_entity`, `system`,`engine`, `format`)\n VALUES ('1', '0', 'default', '1', '1', '1', '1', '1', '0', '0', '0', '0', '0', '0',\n '0', '0', '1')";
$DB->queryOrDie($query, __('1.5 insert into glpi_plugin_archires_config ', 'archires') . $DB->error());
$query = "INSERT INTO `glpi_displaypreferences`\n (`ID` , `type` , `num` , `rank` , `FK_users` )\n VALUES (NULL, '3000', '2', '1', '0'),\n (NULL, '3000', '3', '2', '0'),\n (NULL, '3000', '4', '3', '0'),\n (NULL, '3000', '5', '4', '0'),\n (NULL, '3000', '6', '5', '0'),\n (NULL, '3000', '7', '6', '0'),\n (NULL, '3000', '8', '7', '0'),\n (NULL, '3000', '9', '8', '0'),\n (NULL, '3001', '2', '1', '0'),\n (NULL, '3001', '3', '2', '0'),\n (NULL, '3001', '4', '3', '0'),\n (NULL, '3001', '5', '4', '0'),\n (NULL, '3001', '6', '5', '0'),\n (NULL, '3001', '7', '6', '0'),\n (NULL, '3001', '8', '7', '0'),\n (NULL, '3002', '2', '1', '0'),\n (NULL, '3002', '3', '2', '0'),\n (NULL, '3002', '4', '3', '0'),\n (NULL, '3002', '5', '4', '0'),\n (NULL, '3002', '6', '5', '0'),\n (NULL, '3002', '7', '6', '0'),\n (NULL, '3002', '8', '7', '0')";
$DB->queryOrDie($query, __('1.5 insert into glpi_displaypreferences ', 'archires') . $DB->error());
$migration->executeMigration();
}
示例12: install
public static function install(Migration $migration)
{
global $DB;
if (TableExists("glpi_plugin_order_profiles") && !FieldExists("glpi_plugin_order_profiles", "plugin_order_generate_order_without_validation")) {
$DB->query("ALTER TABLE `glpi_plugin_order_profiles` ADD `plugin_order_generate_order_without_validation` char(1) default NULL;");
}
self::initProfile();
self::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
$migration->dropTable('glpi_plugin_order_profiles');
//if (TableExists("glpi_plugin_order_profiles")){
// $DB->query("DROP TABLE `glpi_plugin_order_profiles`;");
//}
}
示例13: addAllModelsFromFile
/**
* Add and save all models from specified file
*
* @param $inputFile
*/
public function addAllModelsFromFile($inputFile)
{
$oldModelFile = array();
// Get the cached model definitions file to compare against
if (\File::exists($this->getModelCacheFile())) {
$cachedFile = file($this->getModelCacheFile());
$oldModelFile = $this->getCachedModels($cachedFile, false);
}
// Loop through the file and create all associated files
foreach ($inputFile as $line_num => $modelAndProperties) {
$modelAndProperties = trim($modelAndProperties);
if (!empty($modelAndProperties)) {
if (preg_match("/^resource =/", $modelAndProperties)) {
$this->isResource = trim(substr($modelAndProperties, strpos($modelAndProperties, "=") + 1));
continue;
}
if (preg_match("/^namespace =/", $modelAndProperties)) {
$this->namespaceGlobal = true;
$this->namespace = trim(substr($modelAndProperties, strpos($modelAndProperties, "=") + 1));
$this->fileCreator->namespace = $this->namespace;
continue;
}
$this->saveModelAndProperties($modelAndProperties, $oldModelFile);
$this->createFiles();
}
}
// If any models existed in the cached file,
// and not in the current file, drop that table
foreach ($oldModelFile as $tableName => $modelData) {
if (!array_key_exists($tableName, $this->models)) {
$migration = new Migration($this->configSettings['pathTo']['migrations'], $modelData['model'], $this->fileCreator);
$migration->dropTable($this->lastTimeStamp);
}
}
copy($this->configSettings['modelDefinitionsFile'], $this->getModelCacheFile());
}
示例14: uninstall
static function uninstall(Migration $migration)
{
$migration->dropTable(getTableForItemType(__CLASS__));
}
示例15: plugin_racks_uninstall
function plugin_racks_uninstall()
{
include_once GLPI_ROOT . "/plugins/racks/inc/profile.class.php";
include_once GLPI_ROOT . "/plugins/racks/inc/menu.class.php";
$migration = new Migration("1.5.0");
$tables = array("glpi_plugin_racks_racks", "glpi_plugin_racks_racks_items", "glpi_plugin_racks_itemspecifications", "glpi_plugin_racks_rackmodels", "glpi_plugin_racks_roomlocations", "glpi_plugin_racks_connections", "glpi_plugin_racks_configs", "glpi_plugin_racks_others", "glpi_plugin_racks_othermodels", "glpi_plugin_racks_racktypes", "glpi_plugin_racks_rackstates");
foreach ($tables as $table) {
$migration->dropTable($table);
}
//old versions
$tables = array("glpi_plugin_rack", "glpi_plugin_rack_content", "glpi_plugin_rack_device_spec", "glpi_plugin_rack_profiles", "glpi_plugin_racks_profiles", "glpi_plugin_rack_config", "glpi_dropdown_plugin_rack_room_locations", "glpi_dropdown_plugin_rack_ways", "glpi_plugin_rack_others", "glpi_dropdown_plugin_rack_others_type");
foreach ($tables as $table) {
$migration->dropTable($table);
}
$itemtypes = array("DisplayPreference", "Document_Item", "Bookmark", "Log", "Ticket");
foreach ($itemtypes as $itemtype) {
$item = new $itemtype();
$item->deleteByCriteria(array('itemtype' => 'PluginRacksRack'));
}
//Delete rights associated with the plugin
$profileRight = new ProfileRight();
foreach (PluginRacksProfile::getAllRights() as $right) {
$profileRight->deleteByCriteria(array('name' => $right['field']));
}
PluginRacksProfile::removeRightsFromSession();
PluginRacksProfile::removeRightsFromDB();
PluginRacksMenu::removeRightsFromSession();
return true;
}