/** * Additional columns and views need to be added to existing fields. * Below is an example using the addtional column and view defined above. * my_new_view_additional_data() is schema defined in * hook_recline_field_columns. */ function hook_update_N(&$sandbox) { $ret = array(); $fields = field_info_fields(); foreach ($fields as $field_name => $field) { if ($field['type'] == 'recline_field' && $field['storage']['type'] == 'field_sql_storage') { foreach ($field['storage']['details']['sql'] as $type => $table_info) { foreach ($table_info as $table_name => $columns) { $column_name = _field_sql_storage_columnname($field_name, 'my_new_view_additional_data'); // Adding my_new_view_additional_data. if (!db_field_exists($table_name, $column_name)) { // Calling schema defined in hook_recline_field_column(). $schema = my_new_view_additional_data(); db_add_field($table_name, $column_name, $schema); } // Adding my_new_view. $column_name = _field_sql_storage_columnname($field_name, 'my_new_view'); $schema = recline_field_schema(); if (!db_field_exists($table_name, $column_name)) { db_add_field($table_name, $column_name, $schema['columns']['my_new_view']); } field_cache_clear(); } } } } return $ret; }
function upgrade_0_15_9() { global $t_project_version_table; if (!db_field_exists('date_order', $t_project_version_table)) { $query = "ALTER TABLE {$t_project_version_table} ADD date_order DATETIME DEFAULT '1970-01-01 00:00:01' NOT NULL"; $result = @db_query($query); if (false == $result) { return false; } } return true; }
function remove($module) { global $db, $messageStack; $error = false; if (db_field_exists(TABLE_CURRENT_STATUS, 'next_capa_num')) { $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_capa_num"); } if (db_field_exists(TABLE_CURRENT_STATUS, 'next_capa_desc')) { $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_capa_desc"); } return $error; }
function upgrade_0_16_13() { global $t_user_pref_table; if (!db_field_exists('project_id', $t_user_pref_table)) { $query = "ALTER TABLE {$t_user_pref_table} ADD project_id INT(7) UNSIGNED ZEROFILL NOT NULL AFTER user_id"; $result = @db_query($query); if (false == $result) { return false; } } return true; }
/** * Displays the bean. */ public function view($bean, $content, $view_mode = 'default', $langcode = NULL) { // Retrieve the terms from the loaded entity. $active_entity = bean_tax_active_entity_array(); // Check for cached content on this block. $cache_name = 'bean_tax:listing:' . $bean->delta . ':' . $active_entity['type'] . ':' . $active_entity['ids'][0]; if ($cache = cache_get($cache_name)) { $content = $cache->data; } else { // We need to make sure that the bean is configured correctly. if ($active_entity['type'] != 'bean' && !empty($bean->filters['vocabulary']) && (isset($active_entity['terms']) && count($active_entity['terms']))) { // Reformat vocabulary list from machine names to vocabulary vids. $vids = array(); foreach ($bean->filters['vocabulary'] as $vm) { $query = new EntityFieldQuery(); $result = $query->entityCondition('entity_type', 'taxonomy_vocabulary'); $query->propertyCondition('machine_name', $vm); global $language; if ($language->language != NULL && db_field_exists('taxonomy_vocabulary', 'language')) { $query->propertyCondition('language', $language->language); } $result = $query->execute(); foreach ($result['taxonomy_vocabulary'] as $vocabulary) { $vids[$vocabulary->vid] = $vocabulary->vid; } } $i = 0; $content['terms'] = array(); // Parse terms from correct vocabularies, limit list to X results. foreach ($active_entity['terms'] as $term) { $term = entity_load_single('taxonomy_term', $term->tid); if (in_array($term->vid, $vids) && $i < $bean->settings['records_shown']) { $content['terms'][$term->tid] = entity_view('taxonomy_term', array($term->tid => $term), $bean->settings['term_view_mode']); $i++; } } cache_set($cache_name, $content, 'cache', time() + 60 * $bean->settings['cache_duration']); } elseif (isset($active_entity['type']) && $active_entity['type'] == 'bean' && $bean->bid === $active_entity['object']->bid) { $content['#markup'] = ''; } elseif ($bean->settings['hide_empty'] || !$active_entity['object']) { return; } else { $content['#markup'] = t('No terms.'); } } return $content; }
function update($module) { global $db, $messageStack; $error = false; if (MODULE_ASSETS_STATUS < 3.1) { $tab_map = array('0' => '0'); if (db_table_exists(DB_PREFIX . 'assets_tabs')) { $result = $db->Execute("select * from " . DB_PREFIX . 'assets_tabs'); while (!$result->EOF) { $updateDB = $db->Execute("insert into " . TABLE_EXTRA_TABS . " set \n\t\t\t module_id = 'assets',\n\t\t\t tab_name = '" . $result->fields['category_name'] . "',\n\t\t\t description = '" . $result->fields['category_description'] . "',\n\t\t\t sort_order = '" . $result->fields['sort_order'] . "'"); $tab_map[$result->fields['category_id']] = db_insert_id(); $result->MoveNext(); } $db->Execute("DROP TABLE " . DB_PREFIX . "assets_tabs"); } if (db_table_exists(DB_PREFIX . 'assets_fields')) { $result = $db->Execute("select * from " . DB_PREFIX . 'assets_fields'); while (!$result->EOF) { $updateDB = $db->Execute("insert into " . TABLE_EXTRA_FIELDS . " set \n\t\t\t module_id = 'assets',\n\t\t\t tab_id = '" . $tab_map[$result->fields['category_id']] . "',\n\t\t\t entry_type = '" . $result->fields['entry_type'] . "',\n\t\t\t field_name = '" . $result->fields['field_name'] . "',\n\t\t\t description = '" . $result->fields['description'] . "',\n\t\t\t params = '" . $result->fields['params'] . "'"); $result->MoveNext(); } $db->Execute("DROP TABLE " . DB_PREFIX . "assets_fields"); } xtra_field_sync_list('assets', TABLE_ASSETS); } if (MODULE_ASSETS_STATUS < 3.3) { if (!db_field_exists(TABLE_ASSETS, 'attachments')) { $db->Execute("ALTER TABLE " . TABLE_ASSETS . " ADD attachments TEXT NOT NULL AFTER terminal_date"); } require_once DIR_FS_MODULES . 'phreedom/functions/phreedom.php'; xtra_field_sync_list('assets', TABLE_ASSETS); } if (!$error) { write_configure('MODULE_' . strtoupper($module) . '_STATUS', constant('MODULE_' . strtoupper($module) . '_VERSION')); $messageStack->add(sprintf(GEN_MODULE_UPDATE_SUCCESS, $module, constant('MODULE_' . strtoupper($module) . '_VERSION')), 'success'); } return $error; }
function install($module) { global $db; // add field amazon_confirm if (!db_field_exists(TABLE_SHIPPING_LOG, 'amazon_confirm')) { $db->Execute("ALTER TABLE " . TABLE_SHIPPING_LOG . " ADD amazon_confirm ENUM('0', '1') NOT NULL DEFAULT '0'"); } if (!db_field_exists(TABLE_INVENTORY, 'amazon')) { // setup new tab in table inventory $result = $db->Execute("SELECT id FROM " . TABLE_EXTRA_TABS . " WHERE tab_name='Amazon'"); if ($result->RecordCount() == 0) { $sql_data_array = array('module_id' => 'inventory', 'tab_name' => 'Amazon', 'description' => 'Amazon Inventory Settings', 'sort_order' => '49'); db_perform(TABLE_EXTRA_TABS, $sql_data_array); $tab_id = db_insert_id(); } else { $tab_id = $result->fields['id']; } // setup extra fields for inventory $sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'check_box', 'field_name' => 'amazon', 'description' => 'Add to Amazon prduct upload feed.', 'sort_order' => 50, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'check_box', 'select' => '0', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:'))); db_perform(TABLE_EXTRA_FIELDS, $sql_data_array); $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD COLUMN amazon enum('0','1') DEFAULT '0'"); } }
function install($module) { global $db, $messageStack; $error = false; if (!db_field_exists(TABLE_CONTACTS, 'bank_account_1')) { $sql = "select id from " . TABLE_EXTRA_FIELDS . " where module_id = 'contacts' and field_name = 'bank_account'"; $result = $db->Execute($sql); if ($result->RecordCount() == 0) { $result = $db->Execute("select id from " . TABLE_EXTRA_TABS . " where module_id='contacts' and tab_name = 'import_banking'"); if ($result->RecordCount() == 0) { $entry = array('module_id' => 'contacts', 'tab_name' => 'import_banking', 'sort_order' => '100'); db_perform(TABLE_EXTRA_TABS, $entry, 'insert'); $tab_id = $db->insert_ID(); } else { $tab_id = $result->fields['id']; } $entry = array('module_id' => 'contacts', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'bank_account_1', 'description' => 'Bank Account', 'params' => 'a:4:{s:4:"type";s:4:"text";s:12:"contact_type";s:16:"customer:vendor:";s:6:"length";i:32;s:7:"default";s:0:"";}'); db_perform(TABLE_EXTRA_FIELDS, $entry, 'insert'); //$db->Execute("INSERT INTO " . TABLE_EXTRA_FIELDS . " VALUES ('', 'contacts', ". $tab_id .",'text', 'bank_account', 'Bank Account','c:v:', );"); $db->Execute("ALTER TABLE " . TABLE_CONTACTS . " ADD bank_account_1 varchar(32) default NULL"); } } return $error; }
function enum_bug_group($p_enum_string, $p_enum) { $t_bug_table = db_get_table('mantis_bug_table'); $t_project_id = helper_get_current_project(); $t_bug_table = db_get_table('mantis_bug_table'); $t_user_id = auth_get_current_user_id(); $t_res_val = config_get('bug_resolved_status_threshold'); $t_clo_val = config_get('bug_closed_status_threshold'); $specific_where = " AND " . helper_project_specific_where($t_project_id, $t_user_id); if (!db_field_exists($p_enum, $t_bug_table)) { trigger_error(ERROR_DB_FIELD_NOT_FOUND, ERROR); } $t_array_indexed_by_enum_values = MantisEnum::getAssocArrayIndexedByValues($p_enum_string); $enum_count = count($t_array_indexed_by_enum_values); foreach ($t_array_indexed_by_enum_values as $t_value => $t_label) { # Calculates the number of bugs opened and puts the results in a table $query = "SELECT COUNT(*)\n\t\t\t\t\tFROM {$t_bug_table}\n\t\t\t\t\tWHERE {$p_enum}=" . db_param() . " AND\n\t\t\t\t\t\tstatus<" . db_param() . " {$specific_where}"; $result2 = db_query_bound($query, array($t_value, $t_res_val)); $t_metrics['open'][$t_label] = db_result($result2, 0, 0); # Calculates the number of bugs closed and puts the results in a table $query = "SELECT COUNT(*)\n\t\t\t\t\tFROM {$t_bug_table}\n\t\t\t\t\tWHERE {$p_enum}=" . db_param() . " AND\n\t\t\t\t\t\tstatus>=" . db_param() . " {$specific_where}"; $result2 = db_query_bound($query, array($t_value, $t_clo_val)); $t_metrics['closed'][$t_label] = db_result($result2, 0, 0); # Calculates the number of bugs resolved and puts the results in a table $query = "SELECT COUNT(*)\n\t\t\t\t\tFROM {$t_bug_table}\n\t\t\t\t\tWHERE {$p_enum}=" . db_param() . " AND\n\t\t\t\t\t\tstatus>=" . db_param() . " AND\n\t\t\t\t\t\tstatus<" . db_param() . " {$specific_where}"; $result2 = db_query_bound($query, array($t_value, $t_res_val, $t_clo_val)); $t_metrics['resolved'][$t_label] = db_result($result2, 0, 0); } # ## end for return $t_metrics; }
function lostpassword_fix_1() { global $t_user_table; if (!db_field_exists('failed_login_count', $t_user_table)) { $query = "ALTER TABLE {$t_user_table} ADD failed_login_count INT(2) DEFAULT '0' NOT NULL\r\n\t\t\t\tAFTER login_count"; $result = @db_query($query); if (false == $result) { return false; } } if (!db_field_exists('lost_password_in_progress_count', $t_user_table)) { $query = "ALTER TABLE {$t_user_table} ADD lost_password_in_progress_count INT(2) DEFAULT '0' NOT NULL\r\n\t\t\t\tAFTER login_count"; $result = @db_query($query); if (false == $result) { return false; } } return true; }
function remove($module) { global $db; $error = false; if (db_field_exists(TABLE_CURRENT_STATUS, 'next_rma_num')) { $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_rma_num"); } return $error; }
function update($module) { global $db, $messageStack; $error = false; if (MODULE_ZENCART_STATUS < 3.4) { write_configure('MODULE_ZENCART_LAST_UPDATE', date('0000-00-00 00:00:00')); } $result = $db->Execute("select tab_id from " . TABLE_EXTRA_FIELDS . " where field_name = 'category_id'"); if ($result->RecordCount() == 0) { $error = $messageStack->add('can not find tab_name ZenCart', 'error'); } else { $tab_id = $result->fields['tab_id']; } if ($error == false && !db_field_exists(TABLE_INVENTORY, 'ProductURL')) { $sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'ProductURL', 'description' => ZENCART_CATALOG_URL, 'params' => serialize(array('type' => 'text', 'length' => '64', 'default' => '', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:'))); db_perform(TABLE_EXTRA_FIELDS, $sql_data_array); $db->Execute("alter table " . TABLE_INVENTORY . " add column ProductURL varchar(64) default ''"); } if ($error == false && !db_field_exists(TABLE_INVENTORY, 'ProductModel')) { $sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'ProductModel', 'description' => ZENCART_CATALOG_MODEL, 'params' => serialize(array('type' => 'text', 'length' => '64', 'default' => '', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:'))); db_perform(TABLE_EXTRA_FIELDS, $sql_data_array); $db->Execute("alter table " . TABLE_INVENTORY . " add column ProductModel varchar(64) default ''"); } if (!$error) { write_configure('MODULE_' . strtoupper($module) . '_STATUS', constant('MODULE_' . strtoupper($module) . '_VERSION')); $messageStack->add(sprintf(GEN_MODULE_UPDATE_SUCCESS, $module, constant('MODULE_' . strtoupper($module) . '_VERSION')), 'success'); } return $error; }
$f_dir = 'DESC'; } # Show Disabled if ( isset( $t_manage_arr[3] ) ) { $f_show_disabled = $t_manage_arr[3]; } } else { $f_sort = gpc_get_string( 'sort', 'username' ); $f_dir = gpc_get_string( 'dir', 'ASC' ); $f_hide_inactive = gpc_get_bool( 'hideinactive' ); $f_show_disabled = gpc_get_bool( 'showdisabled' ); } # Clean up the form variables if( !db_field_exists( $f_sort, db_get_table( 'user' ) ) ) { $c_sort = 'username'; } else { $c_sort = addslashes( $f_sort ); } $c_dir = ( $f_dir == 'ASC' ) ? 'ASC' : 'DESC'; # 0 = show inactive users, anything else = hide them $c_hide_inactive = ( $f_hide_inactive == 0 ) ? 0 : 1; $t_hide_inactive_filter = '&hideinactive=' . $c_hide_inactive; # 0 = hide disabled users, anything else = show them $c_show_disabled = ( $f_show_disabled == 0 ) ? 0 : 1; $t_show_disabled_filter = '&showdisabled=' . $c_show_disabled;
/** * Return the specified field value * @param integer $p_file_id File identifier. * @param string $p_field_name Database field name to retrieve. * @param string $p_table Database table name. * @return string */ function file_get_field($p_file_id, $p_field_name, $p_table = 'bug') { $t_bug_file_table = db_get_table($p_table . '_file'); if (!db_field_exists($p_field_name, $t_bug_file_table)) { trigger_error(ERROR_DB_FIELD_NOT_FOUND, ERROR); } $t_query = 'SELECT ' . $p_field_name . ' FROM ' . $t_bug_file_table . ' WHERE id=' . db_param(); $t_result = db_query($t_query, array((int) $p_file_id), 1); return db_result($t_result); }
function remove($module) { global $db, $messageStack; $error = false; if (db_field_exists(TABLE_CURRENT_STATUS, 'next_cust_id_num')) { $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_cust_id_num"); } if (db_field_exists(TABLE_CURRENT_STATUS, 'next_cust_id_desc')) { $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_cust_id_desc"); } if (db_field_exists(TABLE_CURRENT_STATUS, 'next_vend_id_num')) { $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_vend_id_num"); } if (db_field_exists(TABLE_CURRENT_STATUS, 'next_vend_id_desc')) { $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_vend_id_desc"); } $db->Execute("delete from " . TABLE_EXTRA_FIELDS . " where module_id = 'contacts'"); $db->Execute("delete from " . TABLE_EXTRA_TABS . " where module_id = 'contacts'"); return $error; }
function remove($module) { global $db; $error = false; // load and remove all modules $method_dir = DIR_FS_ADMIN . 'modules/' . $module . '/methods/'; $methods = array(); if ($dir = @dir($method_dir)) { while ($choice = $dir->read()) { if (file_exists($method_dir . $choice . '/' . $choice . '.php') && $choice != '.' && $choice != '..') { $methods[] = $choice; } } $dir->close(); foreach ($methods as $method) { require_once DIR_FS_ADMIN . 'modules/' . $module . '/methods/' . $method . '/' . $method . '.php'; $properties = new $method(); remove_configure('MODULE_' . strtoupper($module) . '_' . strtoupper($method) . '_STATUS'); foreach ($properties->keys() as $key) { remove_configure($key['key']); } if (method_exists($properties, 'remove')) { $properties->remove(); } } } if (db_field_exists(TABLE_CURRENT_STATUS, 'next_shipment_num')) { $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_shipment_num"); } if (db_field_exists(TABLE_CURRENT_STATUS, 'next_shipment_desc')) { $db->Execute("ALTER TABLE " . TABLE_CURRENT_STATUS . " DROP next_shipment_desc"); } return $error; }
// // This script updates Release 1.8 to Release 1.9, it is included as part of the updater script // *************************** IMPORTANT UPDATE INFORMATION *********************************// //********************************* END OF IMPORTANT ****************************************// // Release 1.8 to 1.9 if (!file_exists(DIR_FS_MY_FILES . $_SESSION['company'] . '/index.html')) { install_blank_webpage(DIR_FS_MY_FILES . '/index.html'); install_blank_webpage(DIR_FS_MY_FILES . 'backups/index.html'); install_blank_webpage(DIR_FS_MY_FILES . $_SESSION['company'] . '/index.html'); } if (!db_field_exists(TABLE_JOURNAL_MAIN, 'printed')) { $db->Execute("ALTER TABLE " . TABLE_JOURNAL_MAIN . " ADD printed enum('0','1') NOT NULL DEFAULT '0' AFTER closed"); $db->Execute("ALTER TABLE " . TABLE_JOURNAL_MAIN . " ADD INDEX (closed)"); $db->Execute("ALTER TABLE " . TABLE_JOURNAL_MAIN . " ADD INDEX (bill_acct_id)"); } if (!db_field_exists(TABLE_JOURNAL_ITEM, 'project_id')) { $db->Execute("ALTER TABLE " . TABLE_JOURNAL_ITEM . " ADD project_id VARCHAR(16) NULL AFTER serialize_number"); } if (!db_table_exists(TABLE_PROJECTS_PHASES)) { $db->Execute("CREATE TABLE " . TABLE_PROJECTS_PHASES . " (\n\tphase_id int(8) NOT NULL auto_increment,\n\tdescription_short varchar(16) collate utf8_unicode_ci NOT NULL default '',\n\tdescription_long varchar(64) collate utf8_unicode_ci NOT NULL default '',\n\tcost_type varchar(3) collate utf8_unicode_ci default NULL,\n\tcost_breakdown enum('0','1') collate utf8_unicode_ci NOT NULL default '0',\n\tinactive enum('0','1') collate utf8_unicode_ci NOT NULL default '0',\n\tPRIMARY KEY (phase_id),\n\tKEY description_short (description_short)\n\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"); } if (!db_table_exists(TABLE_PROJECTS_COSTS)) { $db->Execute("CREATE TABLE " . TABLE_PROJECTS_COSTS . " (\n\tcost_id int(8) NOT NULL auto_increment,\n\tdescription_short varchar(16) collate utf8_unicode_ci NOT NULL default '',\n\tdescription_long varchar(64) collate utf8_unicode_ci NOT NULL default '',\n\tcost_type varchar(3) collate utf8_unicode_ci default NULL,\n\tinactive enum('0','1') collate utf8_unicode_ci NOT NULL default '0',\n\tPRIMARY KEY (cost_id),\n\tKEY description_short (description_short)\n\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"); } if (!defined('ROUND_TAX_BY_AUTH')) { $db->Execute("INSERT INTO " . TABLE_CONFIGURATION . "\n ( configuration_title , configuration_key , configuration_value , configuration_description , configuration_group_id , sort_order , last_modified , date_added , use_function , set_function )\n VALUES ( 'CD_01_52_TITLE', 'ROUND_TAX_BY_AUTH', '0', 'CD_01_52_DESC', '1', '52', NULL , now(), NULL , 'cfg_keyed_select_option(array(0 =>\\'" . TEXT_NO . "\\', 1=>\\'" . TEXT_YES . "\\'),' );"); } // add gl_type to adjustments for ajax page loading $result = $db->Execute("update " . TABLE_JOURNAL_MAIN . " m inner join " . TABLE_JOURNAL_ITEM . " i on m.id = i.ref_id\n\tset i.gl_type = 'adj' where m.journal_id = 16 and i.gl_type = '' and i.sku <> ''"); $result = $db->Execute("update " . TABLE_JOURNAL_MAIN . " m inner join " . TABLE_JOURNAL_ITEM . " i on m.id = i.ref_id\n\tset i.gl_type = 'ttl' where m.journal_id = 16 and i.gl_type = '' and i.sku = ''"); // change printed type to integer for incrmenting print counts of a record
if (db_table_exists(DB_PREFIX . 'doc_ctl_document')) { write_configure('MODULE_DOC_CTL_STATUS', '0.1'); } if (db_table_exists(DB_PREFIX . 'receiving_module')) { write_configure('MODULE_RECEIVING_STATUS', '0.1'); } if (db_table_exists(DB_PREFIX . 'rma_module')) { write_configure('MODULE_RMA_STATUS', '0.1'); } if (db_table_exists(DB_PREFIX . 'translate_files')) { write_configure('MODULE_TRANSLATOR_STATUS', '0.1'); } if (db_table_exists(DB_PREFIX . 'wo_main')) { write_configure('MODULE_WORK_ORDERS_STATUS', '0.1'); } if (db_field_exists(DB_PREFIX . 'inventory', 'catalog')) { write_configure('MODULE_ZENCART_STATUS', '0.1'); } // check installed payment and shipping methods and update if (defined('MODULE_PAYMENT_AUTHORIZENET_ORDER')) { write_configure('MODULE_PAYMENT_AUTHORIZENET_STATUS', '0.1'); } if (defined('MODULE_PAYMENT_COD_SORT_ORDER')) { write_configure('MODULE_PAYMENT_COD_STATUS', '0.1'); } if (defined('MODULE_PAYMENT_DIRECTDEBIT_SORT_ORDER')) { write_configure('MODULE_PAYMENT_DIRECTDEBIT_STATUS', '0.1'); } if (defined('MODULE_PAYMENT_NOVA_XML_SORT_ORDER')) { write_configure('MODULE_PAYMENT_NOVA_XML_STATUS', '0.1'); }
public static function changeSchema(array &$field, array $column_renames = array()) { // Update the field schema $old_schema = array_intersect_key($field, array('columns' => '', 'indexes' => '', 'foreign keys' => '')); module_load_install($field['module']); $new_schema = (array) module_invoke($field['module'], 'field_schema', $field); $new_schema += array('columns' => array(), 'indexes' => array(), 'foreign keys' => array()); $field['data']['columns'] = $new_schema['columns']; $field['data']['indexes'] = $new_schema['indexes']; $field['data']['foreign keys'] = $new_schema['foreign keys']; $data_table = _field_sql_storage_tablename($field); $revision_table = _field_sql_storage_revision_tablename($field); // Validate that all the columns described in the existing schema actually exist. foreach (array_keys($old_schema['columns']) as $old_column) { $old_column_name = _field_sql_storage_columnname($field['field_name'], $old_column); if (!db_field_exists($data_table, $old_column_name)) { throw new Exception(); } if (!db_field_exists($revision_table, $old_column_name)) { throw new Exception(); } // Attempt to re-use any columns that have the same name. // This can be skipped by setting $column_renames['column-name'] = FALSE; if (!empty($new_schema['columns'][$old_column]) && !isset($column_renames[$old_column])) { $column_renames[$old_column] = $old_column; } } // Validate that any columns to be renamed actually exist. foreach ($column_renames as $old_column => $new_column) { if (!isset($old_schema['columns'][$old_column])) { throw new Exception("Cannot rename field {$field['field_name']} column {$old_column} because it does not exist in the old schema."); } if (!isset($new_schema['columns'][$new_column])) { throw new Exception("Cannot rename field {$field['field_name']} column {$old_column} to {$new_column} because it does not exist in the new schema."); } } // Remove all existing indexes. foreach ($old_schema['indexes'] as $index => $index_fields) { $index_name = _field_sql_storage_indexname($field['field_name'], $index); if (db_index_exists($data_table, $index_name)) { watchdog('helper', "Dropped index {$data_table}.{$index_name}"); db_drop_index($data_table, $index_name); } if (db_index_exists($revision_table, $index_name)) { watchdog('helper', "Dropped index {$revision_table}.{$index_name}"); db_drop_index($revision_table, $index_name); } } // Rename any columns. foreach ($column_renames as $old_column => $new_column) { $old_column_name = _field_sql_storage_columnname($field['field_name'], $old_column); if ($new_column === FALSE) { db_drop_field($data_table, $old_column_name); watchdog('helper', "Dropped column {$data_table}.{$old_column_name}"); db_drop_field($revision_table, $old_column_name); watchdog('helper', "Dropped column {$revision_table}.{$old_column_name}"); unset($old_schema['columns'][$old_column]); } else { $new_column_name = _field_sql_storage_columnname($field['field_name'], $new_column); db_change_field($data_table, $old_column_name, $new_column_name, $new_schema['columns'][$new_column]); watchdog('helper', "Changed column {$data_table}.{$old_column_name}<br/><pre>" . print_r($new_schema['columns'][$new_column], TRUE) . '</pre>'); db_change_field($revision_table, $old_column_name, $new_column_name, $new_schema['columns'][$new_column]); watchdog('helper', "Changed column {$revision_table}.{$old_column_name}<br/><pre>" . print_r($new_schema['columns'][$new_column], TRUE) . '</pre>'); // Remove these fields so they aren't removed or added in the code below. unset($new_schema['columns'][$new_column]); unset($old_schema['columns'][$old_column]); } } // Remove any old columns. $old_columns = array_diff_key($old_schema['columns'], $new_schema['columns']); foreach (array_keys($old_columns) as $old_column) { $old_column_name = _field_sql_storage_columnname($field['field_name'], $old_column); db_drop_field($data_table, $old_column_name); watchdog('helper', "Dropped column {$data_table}.{$old_column_name}"); db_drop_field($revision_table, $old_column_name); watchdog('helper', "Dropped column {$revision_table}.{$old_column_name}"); } // Add any new columns. $new_columns = array_diff_key($new_schema['columns'], $old_schema['columns']); foreach (array_keys($new_columns) as $new_column) { $new_column_name = _field_sql_storage_columnname($field['field_name'], $new_column); db_add_field($data_table, $new_column_name, $new_schema['columns'][$new_column]); watchdog('helper', "Added column {$data_table}.{$new_column_name}"); db_add_field($revision_table, $new_column_name, $new_schema['columns'][$new_column]); watchdog('helper', "Added column {$revision_table}.{$new_column_name}"); } // Re-add indexes. foreach ($new_schema['indexes'] as $index => $index_fields) { foreach ($index_fields as &$index_field) { if (is_array($index_field)) { $index_field[0] = _field_sql_storage_columnname($field['field_name'], $index_field[0]); } else { $index_field = _field_sql_storage_columnname($field['field_name'], $index_field); } } $index_name = _field_sql_storage_indexname($field['field_name'], $index); db_add_index($data_table, $index_name, $index_fields); watchdog('helper', "Added index {$data_table}.{$index_name}<br/><pre>" . print_r($index_fields, TRUE) . '</pre>'); db_add_index($revision_table, $index_name, $index_fields); watchdog('helper', "Added index {$revision_table}.{$index_name}<br/><pre>" . print_r($index_fields, TRUE) . '</pre>'); } }
function upgrade_0_17_vb_19() { global $t_bug_history_table; if (!db_field_exists('id', $t_bug_history_table)) { $query = "ALTER TABLE {$t_bug_history_table} ADD id INT(7) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"; $result = @db_query($query); if (false == $result) { return false; } } return true; }
function update($module) { global $db, $messageStack; $error = false; $db_version = defined('MODULE_PHREEDOM_STATUS') ? MODULE_PHREEDOM_STATUS : false; foreach ($this->keys as $key => $value) { if (!defined($key)) { write_configure($key, $value); } } if ($db_version < MODULE_PHREEDOM_STATUS) { $db_version = $this->release_update($module, 3.0, DIR_FS_MODULES . 'phreedom/updates/PBtoR30.php'); if (!$db_version) { return true; } } if (MODULE_PHREEDOM_STATUS < 3.1) { foreach ($this->tables as $table => $create_table_sql) { if (!db_table_exists($table)) { if (!$db->Execute($create_table_sql)) { $error = true; } } } write_configure(PHREEHELP_FORCE_RELOAD, '1'); } if (MODULE_PHREEDOM_STATUS < 3.2) { if (!db_field_exists(TABLE_USERS, 'is_role')) { $db->Execute("ALTER TABLE " . TABLE_USERS . " ADD is_role ENUM('0','1') NOT NULL DEFAULT '0' AFTER admin_id"); } } if (MODULE_PHREEDOM_STATUS < 3.4) { if (!db_field_exists(TABLE_DATA_SECURITY, 'exp_date')) { $db->Execute("ALTER TABLE " . TABLE_DATA_SECURITY . " ADD exp_date DATE NOT NULL DEFAULT '2049-12-31' AFTER enc_value"); } if (!db_field_exists(TABLE_AUDIT_LOG, 'ip_address')) { $db->Execute("ALTER TABLE " . TABLE_AUDIT_LOG . " ADD ip_address VARCHAR(15) NOT NULL AFTER user_id"); } } if (MODULE_PHREEDOM_STATUS < 3.5) { if (!db_field_exists(TABLE_EXTRA_FIELDS, 'group_by')) { $db->Execute("ALTER TABLE " . TABLE_EXTRA_FIELDS . " ADD group_by varchar(64) NOT NULL default ''"); } if (!db_field_exists(TABLE_EXTRA_FIELDS, 'sort_order')) { $db->Execute("ALTER TABLE " . TABLE_EXTRA_FIELDS . " ADD sort_order varchar(64) NOT NULL default ''"); } if (!db_field_exists(TABLE_AUDIT_LOG, 'stats')) { $db->Execute("ALTER TABLE " . TABLE_AUDIT_LOG . " ADD stats VARCHAR(32) NOT NULL AFTER ip_address"); } } if (MODULE_PHREEDOM_STATUS < 3.7) { $db->Execute("ALTER TABLE " . TABLE_AUDIT_LOG . " CHANGE amount amount DOUBLE NOT NULL DEFAULT '0'"); $db->Execute("ALTER TABLE " . TABLE_CURRENCIES . " CHANGE value value DOUBLE NOT NULL DEFAULT '0'"); } if (!$error) { write_configure('MODULE_' . strtoupper($module) . '_STATUS', constant('MODULE_' . strtoupper($module) . '_VERSION')); $messageStack->add(sprintf(GEN_MODULE_UPDATE_SUCCESS, $module, constant('MODULE_' . strtoupper($module) . '_VERSION')), 'success'); } return $error; }
function email_collect_recipients($p_bug_id, $p_notify_type) { $c_bug_id = db_prepare_int($p_bug_id); $t_recipients = array(); # add Reporter if (ON == email_notify_flag($p_notify_type, 'reporter')) { $t_reporter_id = bug_get_field($p_bug_id, 'reporter_id'); $t_recipients[$t_reporter_id] = true; log_event(LOG_EMAIL_RECIPIENT, "bug={$p_bug_id}, add reporter={$t_reporter_id}"); } # add Handler if (ON == email_notify_flag($p_notify_type, 'handler')) { $t_handler_id = bug_get_field($p_bug_id, 'handler_id'); if ($t_handler_id > 0) { $t_recipients[$t_handler_id] = true; log_event(LOG_EMAIL_RECIPIENT, "bug={$p_bug_id}, add handler={$t_handler_id}"); } } $t_project_id = bug_get_field($p_bug_id, 'project_id'); # add users monitoring the bug $t_bug_monitor_table = config_get('mantis_bug_monitor_table'); if (ON == email_notify_flag($p_notify_type, 'monitor')) { $query = "SELECT DISTINCT user_id\n\t\t\t\t\t FROM {$t_bug_monitor_table}\n\t\t\t\t\t WHERE bug_id={$c_bug_id}"; $result = db_query($query); $count = db_num_rows($result); for ($i = 0; $i < $count; $i++) { $t_user_id = db_result($result, $i); $t_recipients[$t_user_id] = true; log_event(LOG_EMAIL_RECIPIENT, "bug={$p_bug_id}, add monitor={$t_user_id}"); } } # add users who contributed bugnotes $t_bugnote_id = bugnote_get_latest_id($p_bug_id); $t_bugnote_view = bugnote_get_field($t_bugnote_id, 'view_state'); $t_bugnote_date = db_unixtimestamp(bugnote_get_field($t_bugnote_id, 'last_modified')); $t_bug_date = bug_get_field($p_bug_id, 'last_updated'); $t_bugnote_table = config_get('mantis_bugnote_table'); if (ON == email_notify_flag($p_notify_type, 'bugnotes')) { $query = "SELECT DISTINCT reporter_id\n\t\t\t\t\t FROM {$t_bugnote_table}\n\t\t\t\t\t WHERE bug_id = {$c_bug_id}"; $result = db_query($query); $count = db_num_rows($result); for ($i = 0; $i < $count; $i++) { $t_user_id = db_result($result, $i); $t_recipients[$t_user_id] = true; log_event(LOG_EMAIL_RECIPIENT, "bug={$p_bug_id}, add note author={$t_user_id}"); } } # add project users who meet the thresholds $t_bug_is_private = bug_get_field($p_bug_id, 'view_state') == VS_PRIVATE; $t_threshold_min = email_notify_flag($p_notify_type, 'threshold_min'); $t_threshold_max = email_notify_flag($p_notify_type, 'threshold_max'); $t_threshold_users = project_get_all_user_rows($t_project_id, $t_threshold_min); foreach ($t_threshold_users as $t_user) { if ($t_user['access_level'] <= $t_threshold_max) { if (!$t_bug_is_private || access_compare_level($t_user['access_level'], config_get('private_bug_threshold'))) { $t_recipients[$t_user['id']] = true; log_event(LOG_EMAIL_RECIPIENT, "bug={$p_bug_id}, add project user="******"bug={$p_bug_id}, drop {$t_id} (own)"); continue; } # Eliminate users who don't exist anymore or who are disabled if (!user_exists($t_id) || !user_is_enabled($t_id)) { log_event(LOG_EMAIL_RECIPIENT, "bug={$p_bug_id}, drop {$t_id} (disabled)"); continue; } # Exclude users who have this notification type turned off if ($t_pref_field) { $t_notify = user_pref_get_pref($t_id, $t_pref_field); if (OFF == $t_notify) { log_event(LOG_EMAIL_RECIPIENT, "bug={$p_bug_id}, drop {$t_id} (pref {$t_pref_field} off)"); continue; } else { # Users can define the severity of an issue before they are emailed for # each type of notification $t_min_sev_pref_field = $t_pref_field . '_min_severity'; $t_min_sev_notify = user_pref_get_pref($t_id, $t_min_sev_pref_field); $t_bug_severity = bug_get_field($p_bug_id, 'severity'); if ($t_bug_severity < $t_min_sev_notify) { log_event(LOG_EMAIL_RECIPIENT, "bug={$p_bug_id}, drop {$t_id} (pref threshold)"); continue; } } } # check that user can see bugnotes if the last update included a bugnote if ($t_bug_date == $t_bugnote_date) { if (!access_has_bugnote_level(VIEWER, $t_bugnote_id, $t_id)) { log_event(LOG_EMAIL_RECIPIENT, "bug={$p_bug_id}, drop {$t_id} (access level)"); continue; } } # Finally, let's get their emails, if they've set one $t_email = user_get_email($t_id); if (is_blank($t_email)) { log_event(LOG_EMAIL_RECIPIENT, "bug={$p_bug_id}, drop {$t_id} (no email)"); } else { # @@@ we could check the emails for validity again but I think # it would be too slow $t_final_recipients[$t_id] = $t_email; } } return $t_final_recipients; }
function upgrade_escaping_fix_9() { global $t_bug_history_table; if (db_field_exists('id', $t_bug_history_table)) { return upgrade_fix_strings($t_bug_history_table, 'id', array('field_name', 'old_value', 'new_value')); } return false; }
} } $result->MoveNext(); } } // some other cleanup $db->Execute("ALTER TABLE " . TABLE_SHIPPING_LOG . " CHANGE ship_date ship_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'"); $db->Execute("ALTER TABLE " . TABLE_SHIPPING_LOG . " CHANGE deliver_date deliver_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'"); $db->Execute("ALTER TABLE " . TABLE_SHIPPING_LOG . " CHANGE actual_date actual_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'"); $db->Execute("ALTER TABLE " . TABLE_SHIPPING_LOG . " CHANGE ref_id ref_id VARCHAR(16) NOT NULL DEFAULT '0'"); $db->Execute("ALTER TABLE " . TABLE_JOURNAL_ITEM . " CHANGE reconciled reconciled SMALLINT(4) NOT NULL DEFAULT '0'"); if (!defined('AR_DEF_DEP_LIAB_ACCT')) { $db->Execute("INSERT INTO " . TABLE_CONFIGURATION . "\n ( configuration_title , configuration_key , configuration_value , configuration_description , configuration_group_id , sort_order , last_modified , date_added , use_function , set_function )\n VALUES ( 'CD_02_07_TITLE', 'AR_DEF_DEP_LIAB_ACCT', '', 'CD_02_07_DESC', '2', '7', NULL , now(), NULL , 'cfg_pull_down_gl_acct_list(' );"); $db->Execute("INSERT INTO " . TABLE_CONFIGURATION . "\n ( configuration_title , configuration_key , configuration_value , configuration_description , configuration_group_id , sort_order , last_modified , date_added , use_function , set_function )\n VALUES ( 'CD_03_07_TITLE', 'AP_DEF_DEP_LIAB_ACCT', '', 'CD_03_07_DESC', '3', '7', NULL , now(), NULL , 'cfg_pull_down_gl_acct_list(' );"); } if (!db_field_exists(TABLE_JOURNAL_MAIN, 'discount')) { $db->Execute("ALTER TABLE " . TABLE_JOURNAL_MAIN . " ADD discount DOUBLE NOT NULL DEFAULT '0' AFTER freight"); } $result = $db->Execute("select ref_id, debit_amount from " . TABLE_JOURNAL_ITEM . " where gl_type = 'dsc'"); while (!$result->EOF) { $db->Execute("update " . TABLE_JOURNAL_MAIN . " set discount = " . $result->fields['debit_amount'] . " where id = " . $result->fields['ref_id']); $result->MoveNext(); } // set reconciled for past closed journal_mains $result = $db->Execute("select * from " . TABLE_RECONCILIATION); while (!$result->EOF) { $period = $result->fields['period']; $gl_account = $result->fields['gl_account']; $cleared_items = unserialize($result->fields['cleared_items']); if (sizeof($cleared_items) > 0) { $one_period = $db->Execute("select id from " . TABLE_JOURNAL_MAIN . "\n where closed = '1' and journal_id in (2, 18, 20) and id in (" . implode(',', $cleared_items) . ")");
require_once 'icon_api.php'; auth_reauthenticate(); access_ensure_global_level(config_get('manage_user_threshold')); $f_sort = gpc_get_string('sort', 'username'); $f_dir = gpc_get_string('dir', 'ASC'); $f_hide_inactive = gpc_get_bool('hideinactive'); $f_show_disabled = gpc_get_bool('showdisabled'); $f_save = gpc_get_bool('save'); $f_filter = utf8_strtoupper(gpc_get_string('filter', config_get('default_manage_user_prefix'))); $f_page_number = gpc_get_int('page_number', 1); $t_user_table = db_get_table('mantis_user_table'); $t_cookie_name = config_get('manage_cookie'); $t_lock_image = '<img src="' . config_get('icon_path') . 'protected.gif" width="8" height="15" border="0" alt="' . lang_get('protected') . '" />'; $c_filter = ''; # Clean up the form variables if (!db_field_exists($f_sort, $t_user_table)) { $c_sort = 'username'; } else { $c_sort = addslashes($f_sort); } $c_dir = $f_dir == 'ASC' ? 'ASC' : 'DESC'; # 0 = show inactive users, anything else = hide them $c_hide_inactive = $f_hide_inactive == 0 ? 0 : 1; $t_hide_inactive_filter = '&hideinactive=' . $c_hide_inactive; # 0 = hide disabled users, anything else = show them $c_show_disabled = $f_show_disabled == 0 ? 0 : 1; $t_show_disabled_filter = '&showdisabled=' . $c_show_disabled; # set cookie values for hide inactive, sort by, dir and show disabled if ($f_save) { $t_manage_string = $c_hide_inactive . ':' . $c_sort . ':' . $c_dir . ':' . $c_show_disabled; gpc_set_cookie($t_cookie_name, $t_manage_string, true);
/** * Tests that enabling translation via the API triggers schema updates. */ function testSettingsApi() { $this->container->get('content_translation.manager')->setEnabled('entity_test_mul', 'entity_test_mul', TRUE); $result = db_field_exists('entity_test_mul_property_data', 'content_translation_source') && db_field_exists('entity_test_mul_property_data', 'content_translation_outdated'); $this->assertTrue($result, 'Schema updates correctly performed.'); }
/** * Tests the db_field_exists() function. */ function testDBFieldExists() { $this->assertIdentical(TRUE, db_field_exists('test', 'name'), 'Returns true for existent column.'); $this->assertIdentical(FALSE, db_field_exists('test', 'nosuchcolumn'), 'Returns false for nonexistent column.'); }
/** * Function which gives the absolute values according to the status (opened/closed/resolved) * * @param string $p_enum_string Enumeration string. * @param string $p_enum Enumeration field. * @return array */ function enum_bug_group($p_enum_string, $p_enum) { $t_project_id = helper_get_current_project(); $t_user_id = auth_get_current_user_id(); $t_res_val = config_get('bug_resolved_status_threshold'); $t_clo_val = config_get('bug_closed_status_threshold'); $t_specific_where = ' AND ' . helper_project_specific_where($t_project_id, $t_user_id); if (!db_field_exists($p_enum, db_get_table('bug'))) { trigger_error(ERROR_DB_FIELD_NOT_FOUND, ERROR); } $t_array_indexed_by_enum_values = MantisEnum::getAssocArrayIndexedByValues($p_enum_string); foreach ($t_array_indexed_by_enum_values as $t_value => $t_label) { # Calculates the number of bugs opened and puts the results in a table $t_query = 'SELECT COUNT(*) FROM {bug} WHERE ' . $p_enum . '=' . db_param() . ' AND status<' . db_param() . ' ' . $t_specific_where; $t_result2 = db_query($t_query, array($t_value, $t_res_val)); $t_metrics['open'][$t_label] = db_result($t_result2, 0, 0); # Calculates the number of bugs closed and puts the results in a table $t_query = 'SELECT COUNT(*) FROM {bug} WHERE ' . $p_enum . '=' . db_param() . ' AND status>=' . db_param() . ' ' . $t_specific_where; $t_result2 = db_query($t_query, array($t_value, $t_clo_val)); $t_metrics['closed'][$t_label] = db_result($t_result2, 0, 0); # Calculates the number of bugs resolved and puts the results in a table $t_query = 'SELECT COUNT(*) FROM {bug} WHERE ' . $p_enum . '=' . db_param() . ' AND status>=' . db_param() . ' AND status<' . db_param() . ' ' . $t_specific_where; $t_result2 = db_query($t_query, array($t_value, $t_res_val, $t_clo_val)); $t_metrics['resolved'][$t_label] = db_result($t_result2, 0, 0); } return $t_metrics; }
/** * Tests creating unsigned columns and data integrity thereof. */ function testUnsignedColumns() { // First create the table with just a serial column. $table_name = 'unsigned_table'; $table_spec = array('fields' => array('serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE)), 'primary key' => array('serial_column')); db_create_table($table_name, $table_spec); // Now set up columns for the other types. $types = array('int', 'float', 'numeric'); foreach ($types as $type) { $column_spec = array('type' => $type, 'unsigned' => TRUE); if ($type == 'numeric') { $column_spec += array('precision' => 10, 'scale' => 0); } $column_name = $type . '_column'; $table_spec['fields'][$column_name] = $column_spec; db_add_field($table_name, $column_name, $column_spec); } // Finally, check each column and try to insert invalid values into them. foreach ($table_spec['fields'] as $column_name => $column_spec) { $this->assertTrue(db_field_exists($table_name, $column_name), format_string('Unsigned @type column was created.', array('@type' => $column_spec['type']))); $this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), format_string('Unsigned @type column rejected a negative value.', array('@type' => $column_spec['type']))); } }
/** * Will be executed, if the user hits the install link on the plugin * overview page and before schema() */ function install() { $t_plugin_path = config_get_global('plugin_path') . plugin_get_current() . DIRECTORY_SEPARATOR; // Install site key plugin_config_set('gadiv_sitekey', md5(uniqid(rand(), true))); $this->installConfigurationParams(); // Create custom fields $this->create_custom_field('ProductBacklog', array('possible_values' => '', 'type' => '6')); // List $this->create_custom_field('Sprint', array('possible_values' => '', 'type' => '6')); // List $this->create_custom_field('Storypoints', array('possible_values' => '', 'type' => '1')); // Number $this->create_custom_field('BusinessValue', array('possible_values' => '', 'type' => '0')); // Text $this->create_custom_field('RankingOrder', array('possible_values' => '', 'type' => '1')); // Number $this->create_custom_field('Presentable', array('possible_values' => '1|2|3', 'type' => '6')); // List $this->create_custom_field('Technical', array('possible_values' => 'Ja', 'type' => '5')); // Checkbox $this->create_custom_field('InReleaseDocu', array('possible_values' => 'Ja', 'type' => '5')); // Checkbox $this->create_custom_field('PlannedWork', array('possible_values' => '', 'type' => '1')); // Number $this->create_custom_field('PlannedWorkUnit', array('possible_values' => '0|1|2|3', 'type' => '0', 'filter_by' => '0')); // Text // If old tables exists, that where not created by ADODB, the setting 'plugin_agileMantis_schema' // needs to be set to the last block of the schema that was created without ADODB. // e.g. if the last table created without ADODB was 'gadiv_teams', the plugin_agileMantis_schema // needs to be set to the corresponding schema block. Only the blocks after that will be executed. if (plugin_config_get('schema', -1) == -1) { if (db_is_mysql()) { if ($this->getDBVersion() == '2.0.0') { // Version 2.0. is installed, set block to #21 plugin_config_set('schema', 21); } else { if (db_field_exists('expert', 'gadiv_additional_user_fields')) { // Version 1.3 is installed, set block to #14 plugin_config_set('schema', 14); } else { if (db_table_exists('gadiv_sprints')) { // Version < 1.3 is installed, set block to #13 plugin_config_set('schema', 13); } } } } else { if (db_is_mssql()) { plugin_config_set('schema', -1); } } } return TRUE; }