本文整理汇总了PHP中Migration::displayMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::displayMessage方法的具体用法?PHP Migration::displayMessage怎么用?PHP Migration::displayMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::displayMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
}
}
}
示例2: install
static function install(Migration $migration)
{
global $DB;
$obj = new self();
$table = $obj->getTable();
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` INT(11) NOT NULL auto_increment,\n `name` VARCHAR(255) DEFAULT NULL,\n `label` VARCHAR(255) DEFAULT NULL,\n `type` VARCHAR(25) DEFAULT NULL,\n `plugin_fields_containers_id` INT(11) NOT NULL DEFAULT '0',\n `ranking` INT(11) NOT NULL DEFAULT '0',\n `default_value` VARCHAR(255) DEFAULT NULL,\n `is_active` TINYINT(1) NOT NULL DEFAULT '1',\n `is_readonly` TINYINT(1) NOT NULL DEFAULT '1',\n `mandatory` TINYINT(1) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `plugin_fields_containers_id` (`plugin_fields_containers_id`),\n KEY `is_active` (`is_active`),\n KEY `is_readonly` (`is_readonly`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
$migration->displayMessage("Updating {$table}");
if (!FieldExists($table, 'is_active')) {
$migration->addField($table, 'is_active', 'bool', array('value' => 1));
$migration->addKey($table, 'is_active', 'is_active');
}
if (!FieldExists($table, 'is_readonly')) {
$migration->addField($table, 'is_readonly', 'bool', array('default' => false));
$migration->addKey($table, 'is_readonly', 'is_readonly');
}
if (!FieldExists($table, 'mandatory')) {
$migration->addField($table, 'mandatory', 'bool', array('value' => 0));
}
$migration->executeMigration();
return true;
}
示例3: install
/**
* Install or update containers
*
* @param Migration $migration Migration instance
* @param string $version Plugin current version
*
* @return boolean
*/
static function install(Migration $migration, $version)
{
global $DB;
$obj = new self();
$table = $obj->getTable();
if (!TableExists($table)) {
$migration->displayMessage(sprintf(__("Installing %s"), $table));
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` INT(11) NOT NULL auto_increment,\n `name` VARCHAR(255) DEFAULT NULL,\n `label` VARCHAR(255) DEFAULT NULL,\n `itemtypes` LONGTEXT DEFAULT NULL,\n `type` VARCHAR(255) DEFAULT NULL,\n `subtype` VARCHAR(255) DEFAULT NULL,\n `entities_id` INT(11) NOT NULL DEFAULT '0',\n `is_recursive` TINYINT(1) NOT NULL DEFAULT '0',\n `is_active` TINYINT(1) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `entities_id` (`entities_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
// multiple itemtype for one container
if (!FieldExists($table, "itemtypes")) {
$migration->changeField($table, 'itemtype', 'itemtypes', 'longtext');
$migration->migrationOneTable($table);
$query = "UPDATE `{$table}` SET `itemtypes` = CONCAT('[\"', `itemtypes`, '\"]')";
$DB->query($query) or die($DB->error());
}
//add display preferences for this class
$d_pref = new DisplayPreference();
$found = $d_pref->find("itemtype = '" . __CLASS__ . "'");
if (count($found) == 0) {
for ($i = 2; $i <= 5; $i++) {
$DB->query("REPLACE INTO glpi_displaypreferences VALUES\n (NULL, '" . __CLASS__ . "', {$i}, " . ($i - 1) . ", 0)");
}
}
if (!FieldExists($table, "subtype")) {
$migration->addField($table, 'subtype', 'VARCHAR(255) DEFAULT NULL', array('after' => 'type'));
$migration->migrationOneTable($table);
}
$migration->displayMessage(__("Updating generated containers files", "fields"));
// -> 0.90-1.3: generated class moved
// OLD path: GLPI_ROOT."/plugins/fields/inc/$class_filename"
// NEW path: PLUGINFIELDS_CLASS_PATH . "/$class_filename"
$obj = new self();
$containers = $obj->find();
foreach ($containers as $container) {
//First, drop old fields from plugin directories
$itemtypes = count($container['itemtypes']) > 0 ? json_decode($container['itemtypes'], true) : array();
foreach ($itemtypes as $itemtype) {
$class_filename = strtolower($itemtype . preg_replace('/s$/', '', $container['name']) . ".class.php");
if (file_exists(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}")) {
unlink(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}");
}
$injclass_filename = strtolower($itemtype . preg_replace('/s$/', '', $container['name']) . "injection.class.php");
if (file_exists(GLPI_ROOT . "/plugins/fields/inc/{$injclass_filename}")) {
unlink(GLPI_ROOT . "/plugins/fields/inc/{$injclass_filename}");
}
}
//Second, create new files
self::generateTemplate($container);
}
return true;
}
示例4: install
/**
* Install or update fields
*
* @param Migration $migration Migration instance
* @param string $version Plugin current version
*
* @return boolean
*/
static function install(Migration $migration, $version)
{
global $DB;
$obj = new self();
$table = $obj->getTable();
if (!TableExists($table)) {
$migration->displayMessage(sprintf(__("Installing %s"), $table));
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` INT(11) NOT NULL auto_increment,\n `plugin_fields_itemtype` VARCHAR(30) NOT NULL,\n `plugin_fields_items_id` INT(11) NOT NULL,\n `language` VARCHAR(5) NOT NULL,\n `label` VARCHAR(255) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `plugin_fields_itemtype` (`plugin_fields_itemtype`),\n KEY `plugin_fields_items_id` (`plugin_fields_items_id`),\n KEY `language` (`language`),\n UNIQUE KEY `unicity` (`plugin_fields_itemtype`, `plugin_fields_items_id`, `language`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
$migration->displayMessage("Updating {$table}");
$migration->executeMigration();
return true;
}
示例5: install
/**
* Install or update dropdowns
*
* @param Migration $migration Migration instance
* @param string $version Plugin current version
*
* @return void
*/
static function install(Migration $migration, $version)
{
$migration->displayMessage(__("Updating generated dropdown files", "fields"));
// -> 0.90-1.3: generated class moved
// OLD path: GLPI_ROOT."/plugins/fields/inc/$class_filename"
// NEW path: PLUGINFIELDS_CLASS_PATH . "/$class_filename"
// OLD path: GLPI_ROOT."/plugins/fields/front/$class_filename"
// NEW path: PLUGINFIELDS_FRONT_PATH . "/$class_filename"
$obj = new PluginFieldsField();
$fields = $obj->find('type = "dropdown"');
foreach ($fields as $field) {
//First, drop old fields from plugin directories
$class_filename = $field['name'] . "dropdown.class.php";
if (file_exists(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}")) {
unlink(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}");
}
$front_filename = $field['name'] . "dropdown.php";
if (file_exists(GLPI_ROOT . "/plugins/fields/front/{$front_filename}")) {
unlink(GLPI_ROOT . "/plugins/fields/front/{$front_filename}");
}
$form_filename = $field['name'] . "dropdown.form.php";
if (file_exists(GLPI_ROOT . "/plugins/fields/front/{$form_filename}")) {
unlink(GLPI_ROOT . "/plugins/fields/front/{$form_filename}");
}
//Second, create new files
self::create($field);
}
return true;
}
示例6: install
public static function install(Migration $migration)
{
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` int(11) NOT NULL auto_increment,\n `name` varchar(255) NOT NULL DEFAULT '',\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";
$GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
}
// Migration from previous version
if (TableExists('glpi_plugin_formcreator_cats')) {
$query = "INSERT IGNORE INTO `{$table}` (`id`, `name`)\n SELECT `id`,`name` FROM glpi_plugin_formcreator_cats";
$GLOBALS['DB']->query($query);
$GLOBALS['DB']->query("DROP TABLE glpi_plugin_formcreator_cats");
}
/**
* Migration of special chars from previous versions
*
* @since 0.85-1.2.3
*/
$query = "SELECT `id`, `name`, `comment`\n FROM `{$table}`";
$result = $GLOBALS['DB']->query($query);
while ($line = $GLOBALS['DB']->fetch_array($result)) {
$query_update = 'UPDATE `' . $table . '` SET
`name` = "' . plugin_formcreator_encode($line['name']) . '",
`comment` = "' . plugin_formcreator_encode($line['comment']) . '"
WHERE `id` = ' . $line['id'];
$GLOBALS['DB']->query($query_update) or die($GLOBALS['DB']->error());
}
return true;
}
示例7: 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);
}
}
示例8: install
static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_billtypes` (\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());
}
}
示例9: install
static function install(Migration $migration)
{
$table = getTableForItemType(__CLASS__);
$migration->displayMessage("Installing {$table}");
if (!TableExists($table)) {
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `plugin_formcreator_forms_id` INT NOT NULL ,\n `plugin_formcreator_profiles_id` INT NOT NULL ,\n PRIMARY KEY (`plugin_formcreator_forms_id`, `plugin_formcreator_profiles_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
}
return true;
}
示例10: install
public static function install(Migration $migration)
{
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n\t\t\t\t\t `id` int(11) NOT NULL auto_increment,\n\t\t\t\t\t `plugin_formcreator_forms_id` int(11) NOT NULL default '0',\n\t\t\t\t\t `items_id` int(11) NOT NULL default '0',\n\t\t\t\t\t `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL default '',\n\t\t\t\t\t PRIMARY KEY (`id`),\n\t\t\t\t\t UNIQUE KEY `unicity` (`plugin_formcreator_forms_id`,`items_id`,`itemtype`),\n\t\t\t\t\t KEY `plugin_formcreator_forms_id` (`plugin_formcreator_forms_id`),\n\t\t\t\t\t KEY `item` (`itemtype`,`items_id`)\n\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
}
return true;
}
示例11: install
static function install(Migration $migration)
{
global $DB;
$obj = new self();
$table = $obj->getTable();
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` INT(11) NOT NULL auto_increment,\n `profiles_id` INT(11) NOT NULL DEFAULT '0',\n `plugin_fields_containers_id` INT(11) NOT NULL DEFAULT '0',\n `right` CHAR(1) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `profiles_id` (`profiles_id`),\n KEY `plugin_fields_containers_id` (`plugin_fields_containers_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
return true;
}
示例12: install
/**
* Database table installation for the item type
*
* @param Migration $migration
* @return boolean True on success
*/
public static function install(Migration $migration)
{
$obj = new self();
$table = $obj->getTable();
// Create new table
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
// Create questions table
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n `plugin_formcreator_forms_id` int(11) NOT NULL,\n `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n `order` int(11) NOT NULL DEFAULT '0'\n )\n ENGINE = MyISAM\n DEFAULT CHARACTER SET = utf8\n COLLATE = utf8_unicode_ci;";
$GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
} else {
/**
* Migration of special chars from previous versions
*
* @since 0.85-1.2.3
*/
$query = "SELECT `id`, `name`\n FROM `{$table}`";
$result = $GLOBALS['DB']->query($query);
while ($line = $GLOBALS['DB']->fetch_array($result)) {
$query_update = 'UPDATE `' . $table . '` SET
`name` = "' . plugin_formcreator_encode($line['name']) . '"
WHERE `id` = ' . $line['id'];
$GLOBALS['DB']->query($query_update) or die($GLOBALS['DB']->error());
}
}
// Migration from previous version => Remove useless target field
if (FieldExists($table, 'plugin_formcreator_targets_id', false)) {
$GLOBALS['DB']->query("ALTER TABLE `{$table}` DROP `plugin_formcreator_targets_id`;");
}
// Migration from previous version => Rename "position" into "order" and start order from 1 instead of 0
if (FieldExists($table, 'position', false)) {
$GLOBALS['DB']->query("ALTER TABLE `{$table}` CHANGE `position` `order` INT(11) NOT NULL DEFAULT '0';");
$GLOBALS['DB']->query("UPDATE `{$table}` SET `order` = `order` + 1;");
}
// Migration from previous version => Update Question table, then create a "description" question from content
if (FieldExists($table, 'content', false)) {
$version = plugin_version_formcreator();
$migration = new Migration($version['version']);
PluginFormcreatorQuestion::install($migration);
$table_questions = getTableForItemType('PluginFormcreatorQuestion');
// Increment the order of questions which are in a section with a description
$query = "UPDATE `{$table_questions}`\n SET `order` = `order` + 1\n WHERE `plugin_formcreator_sections_id` IN (\n SELECT `id`\n FROM {$table}\n WHERE `content` != ''\n );";
$GLOBALS['DB']->query($query);
// Create description from content
$query = "INSERT INTO `{$table_questions}` (`plugin_formcreator_sections_id`, `fieldtype`, `name`, `description`, `order`)\n SELECT `id`, 'description' AS fieldtype, CONCAT('Description ', `id`) AS name, `content`, 1 AS `order`\n FROM {$table}\n WHERE `content` != ''";
$GLOBALS['DB']->query($query);
// Delete content column
$GLOBALS['DB']->query("ALTER TABLE `{$table}` DROP `content`;");
}
return true;
}
示例13: install
static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_billstates` (\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());
}
if (countElementsInTable($table) < 2) {
$state = new self();
foreach (array(self::PAID => __("Paid", "order"), self::NOTPAID => __("Not paid", "order")) as $id => $label) {
$state->add(array('id' => $id, 'name' => Toolbox::addslashes_deep($label)));
}
}
}
示例14: install
static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
//1.2.0
$DB->query("DROP TABLE IF EXISTS `glpi_dropdown_plugin_order_status`;");
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_orderstates` (\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());
}
$state = new self();
foreach (array(1 => __("Draft", "order"), 2 => __("Waiting for approval", "order"), 3 => __("Validated", "order"), 4 => __("Being delivered", "order"), 5 => __("Delivered", "order"), 6 => __("Canceled", "order"), 7 => __("Paid", "order")) as $id => $label) {
if (!countElementsInTable($table, "`id`='{$id}'")) {
$state->add(array('id' => $id, 'name' => Toolbox::addslashes_deep($label)));
}
}
}
示例15: install
static function install(Migration $migration)
{
global $DB;
$obj = new self();
$table = $obj->getTable();
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` INT(11) NOT NULL auto_increment,\n `name` VARCHAR(255) DEFAULT NULL,\n `label` VARCHAR(255) DEFAULT NULL,\n `itemtype` VARCHAR(255) DEFAULT NULL,\n `type` VARCHAR(255) DEFAULT NULL,\n `subtype` VARCHAR(255) DEFAULT NULL,\n `entities_id` INT(11) NOT NULL DEFAULT '0',\n `is_recursive` TINYINT(1) NOT NULL DEFAULT '0',\n `is_active` TINYINT(1) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `entities_id` (`entities_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
//add display preferences for this class
$d_pref = new DisplayPreference();
$found = $d_pref->find("itemtype = '" . __CLASS__ . "'");
if (count($found) == 0) {
for ($i = 2; $i <= 5; $i++) {
$DB->query("INSERT INTO glpi_displaypreferences VALUES\n (NULL, '" . __CLASS__ . "', {$i}, " . ($i - 1) . ", 0)");
}
}
if (!FieldExists($table, "subtype")) {
$migration->addField($table, 'subtype', 'VARCHAR(255) DEFAULT NULL', array('after' => 'type'));
$migration->migrationOneTable($table);
}
return true;
}