Index: branches/5.1.x/core/install/upgrades.php =================================================================== diff -u -r13393 -r13470 --- branches/5.1.x/core/install/upgrades.php (.../upgrades.php) (revision 13393) +++ branches/5.1.x/core/install/upgrades.php (.../upgrades.php) (revision 13470) @@ -1,6 +1,6 @@ Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + $ml_helper->createFields('phrases'); $ml_helper->createFields('emailevents'); @@ -1428,6 +1430,76 @@ $this->Conn->Query('DROP TABLE IF EXISTS ' . TABLE_PREFIX . 'Phrase'); $this->Conn->Query('RENAME TABLE ' . $temp_table . ' TO ' . TABLE_PREFIX . 'Phrase'); + // refactor StdDestinations table + $sql = 'RENAME TABLE ' . TABLE_PREFIX . 'StdDestinations TO ' . TABLE_PREFIX . 'CountryStates'; + $this->Conn->Query($sql); + + $sql = 'ALTER TABLE ' . TABLE_PREFIX . 'CountryStates + CHANGE DestId CountryStateId INT(11) NOT NULL AUTO_INCREMENT, + CHANGE DestType Type INT(11) NOT NULL DEFAULT \'1\', + CHANGE DestParentId StateCountryId INT(11) NULL DEFAULT NULL, + CHANGE DestAbbr IsoCode CHAR(3) NOT NULL DEFAULT \'\', + CHANGE DestAbbr2 ShortIsoCode CHAR(2) NULL DEFAULT NULL, + DROP INDEX DestType, + DROP INDEX DestParentId, + ADD INDEX (`Type`), + ADD INDEX (StateCountryId)'; + $this->Conn->Query($sql); + + // move country/state translations from Phrase to CountryStates table + $ml_helper->createFields('country-state'); + + for ($language_id = 1; $language_id <= $ml_helper->languageCount; $language_id++) { + if (!$ml_helper->LanguageFound($language_id)) { + continue; + } + + $sub_select = ' SELECT l' . $language_id . '_Translation + FROM ' . TABLE_PREFIX . 'Phrase + WHERE Phrase = DestName'; + + $sql = 'UPDATE ' . TABLE_PREFIX . 'CountryStates + SET l' . $language_id . '_Name = (' . $sub_select . ')'; + $this->Conn->Query($sql); + } + + $sql = 'ALTER TABLE ' . TABLE_PREFIX . 'CountryStates + DROP DestName'; + $this->Conn->Query($sql); + + $sql = 'DELETE FROM ' . TABLE_PREFIX . 'Phrase + WHERE Phrase LIKE ' . $this->Conn->qstr('la_country_%') . ' OR Phrase LIKE ' . $this->Conn->qstr('la_state_%'); + $this->Conn->Query($sql); + + // makes configuration values dropdowns use "||" as separator + $custom_field_helper =& $this->Application->recallObject('InpCustomFieldsHelper'); + /* @var $custom_field_helper InpCustomFieldsHelper */ + + $sql = 'SELECT ValueList, VariableName + FROM ' . TABLE_PREFIX . 'ConfigurationAdmin + WHERE ValueList LIKE "%,%"'; + $variables = $this->Conn->GetCol($sql, 'VariableName'); + + foreach ($variables as $variable_name => $value_list) { + $ret = Array (); + $options = $custom_field_helper->GetValuesHash($value_list, ',', false); + + foreach ($options as $option_key => $option_title) { + if (substr($option_key, 0, 3) == 'SQL') { + $ret[] = $option_title; + } + else { + $ret[] = $option_key . '=' . $option_title; + } + } + + $fields_hash = Array ( + 'ValueList' => implode(VALUE_LIST_SEPARATOR, $ret), + ); + + $this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'ConfigurationAdmin', 'VariableName = ' . $this->Conn->qstr($variable_name)); + } + // save "config.php" in php format, not ini format as before $this->_toolkit->SaveConfig(); }