Index: branches/5.0.x/in-link/install/upgrades.php =================================================================== diff -u -N --- branches/5.0.x/in-link/install/upgrades.php (revision 12746) +++ branches/5.0.x/in-link/install/upgrades.php (revision 0) @@ -1,141 +0,0 @@ -_toolkit =& $instance; - } - - /** - * Changes table structure, where multilingual fields of TEXT type are present - * - * @param string $mode when called mode {before, after) - */ - function Upgrade_5_0_0($mode) - { - if ($mode == 'after') { - $root_category = $this->Application->findModule('Name', 'In-Link', 'RootCat'); - - $sql = 'UPDATE ' . $this->Application->getUnitOption('c', 'TableName') . ' - SET UseMenuIconUrl = 1, MenuIconUrl = "in-link/img/menu_links.gif" - WHERE ' . $this->Application->getUnitOption('c', 'IDField') . ' = ' . $root_category; - $this->Conn->Query($sql); - - $this->_updateDetailTemplate('l', 'inlink/detail', 'in-link/designs/detail'); - - // copy link name and description to their multilingual equivalents - $this->_copyToMultilingual(); - } - } - - /** - * Copy link values from normal fields to multilingual - * - */ - function _copyToMultilingual() - { - $fields = Array ('Name', 'Description'); - $primary_language = $this->Application->GetDefaultLanguageId(); - - $set_clause = Array (); - foreach ($fields as $field) { - $set_clause[] = 'l' . $primary_language . '_' . $field . ' = ' . $field; - } - - $sql = 'UPDATE ' . TABLE_PREFIX . 'Link - SET ' . implode(', ', $set_clause); - $this->Conn->Query($sql); - } - - /** - * Replaces deprecated detail template design with new one - * - * @param string $prefix - * @param string $from_template - * @param string $to_template - */ - function _updateDetailTemplate($prefix, $from_template, $to_template) - { - $sql = 'SELECT CustomFieldId - FROM ' . TABLE_PREFIX . 'CustomField - WHERE FieldName = "' . $prefix . '_ItemTemplate"'; - $custom_field_id = $this->Conn->GetOne($sql); - - $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - /* @var $ml_formatter kMultiLanguage */ - - $field = $ml_formatter->LangFieldName('cust_' . $custom_field_id, true); - - $sql = 'UPDATE ' . TABLE_PREFIX . 'CategoryCustomData - SET ' . $field . ' = "' . $to_template . '" - WHERE ' . $field . ' = "' . $from_template . '"'; - $this->Conn->Query($sql); - } - - /** - * Update to 5.0.1 - * - * @param string $mode when called mode {before, after) - */ - function Upgrade_5_0_1($mode) - { - if ($mode == 'after') { - $this->_updateDetailTemplate('l', 'in-link/designs/detail', 'in-link/links/link_detail'); - - // delete old events - $events_to_delete = Array ( 'LINK.OWNER.MODIFY.PENDING', 'LINK.OWNER.MODIFY' ); - - $sql = 'SELECT EventId FROM ' . TABLE_PREFIX . 'Events - WHERE Event IN ("' . implode('","', $events_to_delete) . '")'; - $event_ids = $this->Conn->GetCol($sql); - - if ($event_ids) { - $sql = 'DELETE FROM ' . TABLE_PREFIX . 'EmailMessage - WHERE EventId IN (' . implode(',', $event_ids) . ')'; - $this->Conn->Query($sql); - - $sql = 'DELETE FROM ' . TABLE_PREFIX . 'Events - WHERE EventId IN (' . implode(',', $event_ids) . ')'; - $this->Conn->Query($sql); - - $sql = 'DELETE FROM ' . TABLE_PREFIX . 'Phrase - WHERE Phrase IN ("la_event_link.owner.modify", "la_event_link.owner.modify.pending")'; - $this->Conn->Query($sql); - } - } - } - - } \ No newline at end of file