/** * Activate all items of all types in the database */ function plugin_customfields_activate_all_types() { global $DB; $sql = "SELECT `itemtype`\r\n FROM `glpi_plugin_customfields_itemtypes`\r\n WHERE `enabled` = 1"; $result = $DB->query($sql); while ($data = $DB->fetch_array($result)) { plugin_customfields_activate_all($data['itemtype']); } }
$sql = "SELECT MAX(`sopt_pos`)+1 AS next_sopt_pos\n FROM `glpi_plugin_customfields_fields`\n WHERE `itemtype` = '{$itemtype}'"; $result = $DB->query($sql); $data = $DB->fetch_assoc($result); $sopt_pos = $data['next_sopt_pos']; if (!$sopt_pos) { $sopt_pos = 1; } // Insert field $sql = "INSERT INTO `glpi_plugin_customfields_fields`\n (`itemtype`, `system_name`, `label`, `data_type`,\n `sort_order`, `dropdown_table`, `deleted`,\n `sopt_pos`, `restricted`)\n VALUES ('{$itemtype}', '{$system_name}', '{$label}',\n '{$data_type}', '{$sort}', '{$dd_table}', 0,\n '{$sopt_pos}', 0)"; $result = $DB->query($sql); if ($data_type != 'sectionhead') { // add the field to the data table if it isn't a section header $table = plugin_customfields_table($itemtype); if (CUSTOMFIELDS_AUTOACTIVATE) { // creates table and activates IF necessary plugin_customfields_activate_all($itemtype); } else { // creates table if it doesn't alreay exist plugin_customfields_create_data_table($itemtype); } switch ($data_type) { case 'general': $db_data_type = 'VARCHAR(255) collate utf8_unicode_ci default NULL'; break; case 'yesno': $db_data_type = 'SMALLINT(6) NOT NULL default \'0\''; break; case 'text': $db_data_type = 'TEXT collate utf8_unicode_ci'; break; case 'notes':