public static function install(Migration $migration) { global $DB; $table = getTableForItemType(__CLASS__); if (!TableExists($table)) { $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL DEFAULT '0',\n `is_recursive` tinyint(1) NOT NULL DEFAULT '1',\n `name` varchar(255) NOT NULL DEFAULT '',\n `comment` text collate utf8_unicode_ci,\n `color` varchar(50) NOT NULL DEFAULT '' 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()); } if (!FieldExists($table, 'type_menu')) { $migration->addField($table, 'type_menu', "varchar(50) NOT NULL DEFAULT ''"); $migration->addKey($table, 'type_menu'); $migration->migrationOneTable($table); } // Version 0.90-1.1 $result = $DB->query("SHOW FIELDS FROM `{$table}` where Field ='type_menu'"); if ($result && $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { if (stristr($data["Type"], 'varchar') !== FALSE) { $DB->query("ALTER TABLE `{$table}` DROP INDEX `type_menu`;"); $DB->query("ALTER TABLE `{$table}` MODIFY `type_menu` text COLLATE utf8_unicode_ci;"); $datas = getAllDatasFromTable($table, "`type_menu` IS NOT NULL"); if (!empty($datas)) { foreach ($datas as $data) { $itemtypes = PluginTagTagItem::getItemtypes($data['type_menu']); $DB->query("UPDATE `{$table}` SET `type_menu` = '" . json_encode($itemtypes) . "' WHERE `id` = '" . $data['id'] . "'"); } } break; } } } return true; }
// check if itemtype can display tag control if (in_array(strtolower($_POST['itemtype']), array_map('strtolower', getBlacklistItemtype()))) { return ''; } $class = $_POST['itemtype'] == 'ticket' ? "tab_bg_1" : ''; echo "<tr class='{$class} tab_bg_1'>"; echo "<th>" . _n('Tag', 'Tags', 2, 'tag') . "</th>"; echo "<td colspan='3'>"; PluginTagTag::tagDropdownMultiple(); echo "</td>"; echo "</tr>"; break; case 'add_subtypes': // Sub type add $itemtypes = array(); foreach (PluginTagTagItem::getItemtypes($_POST['type_menu']) as $itemtype) { $item = getItemForItemtype($itemtype); $itemtypes[$itemtype] = $item->getTypeName(); } Dropdown::showFromArray("add_subtypes", $itemtypes, array('multiple' => true, 'rand' => $_POST['rand'], 'width' => '50%')); // Add subtypes button echo " <a class=\"vsubmit\" onclick=\"pluginTagAddSubType('dropdown_subtypes" . $_POST['rand'] . "', 'dropdown_add_subtypes" . $_POST['rand'] . "', '" . $CFG_GLPI['root_doc'] . "/plugins/tag/ajax/tag.php');\">" . __('Add type', 'tag') . "</a>"; break; case 'list_subtypes': // Sub type list $itemtypes = array(); if (!empty($_POST['subtypes'])) { foreach ($_POST['subtypes'] as $key => $itemtype) { $item = getItemForItemtype($itemtype); $itemtypes[$key]['value'] = $itemtype; $itemtypes[$key]['text'] = $item->getTypeName();