本文整理汇总了PHP中Notepad::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Notepad::getTable方法的具体用法?PHP Notepad::getTable怎么用?PHP Notepad::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notepad
的用法示例。
在下文中一共展示了Notepad::getTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$query = "CREATE TABLE `{$table}` (\n `id` INT( 11 ) NOT NULL AUTO_INCREMENT,\n `entities_id` INT( 11 ) NOT NULL DEFAULT 0,\n `itemtype` varchar(255) collate utf8_unicode_ci default NULL,\n `is_active` tinyint(1) NOT NULL default '0',\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `comment` text NULL,\n `date_mod` datetime DEFAULT NULL,\n `date_creation` datetime DEFAULT NULL,\n `use_global_search` tinyint(1) NOT NULL default '0',\n `use_unicity` tinyint(1) NOT NULL default '0',\n `use_history` tinyint(1) NOT NULL default '0',\n `use_infocoms` tinyint(1) NOT NULL default '0',\n `use_contracts` tinyint(1) NOT NULL default '0',\n `use_documents` tinyint(1) NOT NULL default '0',\n `use_tickets` tinyint(1) NOT NULL default '0',\n `use_links` tinyint(1) NOT NULL default '0',\n `use_loans` tinyint(1) NOT NULL default '0',\n `use_network_ports` tinyint(1) NOT NULL default '0',\n `use_direct_connections` tinyint(1) NOT NULL default '0',\n `use_plugin_datainjection` tinyint(1) NOT NULL default '0',\n `use_plugin_pdf` tinyint(1) NOT NULL default '0',\n `use_plugin_order` tinyint(1) NOT NULL default '0',\n `use_plugin_uninstall` tinyint(1) NOT NULL default '0',\n `use_plugin_geninventorynumber` tinyint(1) NOT NULL default '0',\n `use_menu_entry` tinyint(1) NOT NULL default '0',\n `use_projects` tinyint(1) NOT NULL default '0',\n `linked_itemtypes` text NULL,\n `plugin_genericobject_typefamilies_id` INT( 11 ) NOT NULL DEFAULT 0,\n PRIMARY KEY ( `id` )\n ) ENGINE = MYISAM COMMENT = 'Object types definition table' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
$migration->addField($table, "use_network_ports", "bool");
$migration->addField($table, "use_direct_connections", "bool");
$migration->addField($table, "use_plugin_geninventorynumber", "bool");
$migration->addField($table, "use_contracts", "bool");
$migration->addField($table, "use_menu_entry", "bool");
$migration->addField($table, "use_global_search", "bool");
$migration->addField($table, "use_projects", "bool");
$migration->addField($table, "use_notepad", "bool");
$migration->addField($table, "comment", "text");
if (!$migration->addField($table, "date_mod", "datetime")) {
$migration->changeField($table, "date_mod", "date_mod", "datetime");
}
$migration->addField($table, "date_creation", "datetime");
$migration->addField($table, "linked_itemtypes", "text");
$migration->addField($table, "plugin_genericobject_typefamilies_id", "integer");
$migration->addField($table, "use_plugin_simcard", "bool");
$migration->migrationOneTable($table);
// Migrate notepad data
$allGenericObjectTypes = PluginGenericobjectType::getTypes(true);
$notepad = new Notepad();
foreach ($allGenericObjectTypes as $genericObjectType => $genericObjectData) {
$genericObjectTypeInstance = new $genericObjectType();
if (FieldExists($genericObjectTypeInstance->getTable(), "notepad")) {
$query = "INSERT INTO `" . $notepad->getTable() . "`\n (`items_id`,\n `itemtype`,\n `date`,\n `date_mod`,\n `content`\n )\n SELECT\n `id` as `items_id`,\n '" . $genericObjectType . "' as `itemtype`,\n now() as `date`,\n now() as `date_mod`,\n `notepad` as `content`\n FROM `" . $genericObjectTypeInstance->getTable() . "`\n WHERE notepad IS NOT NULL\n AND notepad <> ''";
$DB->query($query) or die($DB->error());
}
$query = "UPDATE`" . $notepad->getTable() . "`";
$migration->dropField($genericObjectTypeInstance->getTable(), "notepad");
$migration->migrationOneTable($genericObjectTypeInstance->getTable());
}
//Displayprefs
$prefs = array(10 => 6, 9 => 5, 8 => 4, 7 => 3, 6 => 2, 2 => 1, 4 => 1, 11 => 7, 12 => 8, 14 => 10, 15 => 11);
foreach ($prefs as $num => $rank) {
if (!countElementsInTable("glpi_displaypreferences", "`itemtype`='" . __CLASS__ . "' AND `num`='{$num}'\n AND `users_id`='0'")) {
$preference = new DisplayPreference();
$tmp['itemtype'] = __CLASS__;
$tmp['num'] = $num;
$tmp['rank'] = $rank;
$tmp['users_id'] = 0;
$preference->add($tmp);
}
}
//If files are missing, recreate them!
self::checkClassAndFilesForItemType();
}