Index: trunk/core/install/upgrades.php =================================================================== diff -u -N -r8078 -r8397 --- trunk/core/install/upgrades.php (.../upgrades.php) (revision 8078) +++ trunk/core/install/upgrades.php (.../upgrades.php) (revision 8397) @@ -1,46 +1,73 @@ Installator =& $instance; } - + /** * Changes table structure, where multilingual fields of TEXT type are present * * @param string $mode when called mode {before, after) */ - function Upgrade_4_0_2($mode) + function Upgrade_4_1_0($mode) { if ($mode == 'before') { // don't user after, because In-Portal calls this method too $this->Installator->SaveConfig(); } - + if ($mode == 'after') { $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); /* @var $ml_helper kMultiLanguageHelper */ - + $lang_count = $ml_helper->getLanguageCount(); $this->Application->UnitConfigReader->iterateConfigs(Array (&$this, 'updateTextFields'), $lang_count); } } /** + * Moves ReplacementTags functionality from EmailMessage to Events table + * + * @param string $mode when called mode {before, after) + */ + function Upgrade_4_1_1($mode) + { + if ($mode == 'after') { + $sql = 'SELECT ReplacementTags, EventId + FROM '.TABLE_PREFIX.'EmailMessage + WHERE (ReplacementTags IS NOT NULL) AND (ReplacementTags <> "") AND (LanguageId = 1)'; + $replacement_tags = $this->Conn->GetCol($sql, 'EventId'); + + foreach ($replacement_tags as $event_id => $replacement_tag) { + $sql = 'UPDATE '.TABLE_PREFIX.'Events + SET ReplacementTags = '.$this->Conn->qstr($replacement_tag).' + WHERE EventId = '.$event_id; + $this->Conn->Query($sql); + } + + // drop moved field from source table + $sql = 'ALTER TABLE '.TABLE_PREFIX.'EmailMessage + DROP `ReplacementTags`'; + $this->Conn->Query($sql); + } + } + + /** * Callback function, that makes all ml fields of text type null with same default value * * @param string $prefix @@ -54,14 +81,14 @@ // invalid config found or prefix not found return false; } - + $table_name = $config_data['TableName']; $table_structure = $this->Conn->Query('DESCRIBE '.$table_name, 'Field'); if (!$table_structure) { // table not found return false; } - + $sqls = Array (); foreach ($config_data['Fields'] as $field => $options) { if (isset($options['formatter']) && $options['formatter'] == 'kMultiLanguage' && !isset($options['master_field'])) { @@ -72,22 +99,22 @@ $sqls[] = 'CHANGE '.$ml_field.' '.$ml_field.' TEXT NULL DEFAULT NULL'; } } - + // update if found (old format) if (isset($table_structure[$field]) && $table_structure[$field]['Type'] == 'text') { $sqls[] = 'CHANGE '.$field.' '.$field.' TEXT NULL DEFAULT NULL'; } } } - + if ($sqls) { $sql = 'ALTER TABLE '.$table_name.' '.implode(', ', $sqls); $this->Conn->Query($sql); } - + return true; } - + } - + ?> \ No newline at end of file