Index: branches/RC/core/install/install_schema.sql =================================================================== diff -u -N -r9295 -r9363 --- branches/RC/core/install/install_schema.sql (.../install_schema.sql) (revision 9295) +++ branches/RC/core/install/install_schema.sql (.../install_schema.sql) (revision 9363) @@ -110,6 +110,8 @@ LocalName varchar(40) NOT NULL default '', Enabled int(11) NOT NULL default '1', PrimaryLang int(11) NOT NULL default '0', + AdminInterfaceLang tinyint(3) unsigned NOT NULL default '0', + Priority int(11) NOT NULL default '0', IconURL varchar(255) default NULL, DateFormat varchar(50) NOT NULL default '', TimeFormat varchar(50) NOT NULL default '', Index: branches/RC/core/units/general/cat_tag_processor.php =================================================================== diff -u -N -r9175 -r9363 --- branches/RC/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 9175) +++ branches/RC/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 9363) @@ -463,6 +463,30 @@ return preg_replace('/('.implode('|', $keywords).')/i', $opening.'\\1'.$closing, $ret); } + function AdvancedSearchForm($params) + { + $search_table = $this->Application->getUnitOption('confs', 'TableName'); + $module_name = $this->Application->findModule('Var', $this->Prefix, 'Name'); + + $sql = 'SELECT * + FROM '.$search_table.' + WHERE (ModuleName = '.$this->Conn->qstr($module_name).') AND (AdvancedSearch = 1) + ORDER BY DisplayOrder'; + $search_config = $this->Conn->Query($sql); + + $ret = ''; + foreach ($search_config as $record) { + $params['name'] = $this->SelectParam($params, 'and_or_render_as,and_or_block'); + $params['field'] = $record['FieldName']; + $params['andor'] = $this->Application->ParseBlock($params); + + $params['name'] = $this->SelectParam($params, $record['FieldType'].'_render_as,'.$record['FieldType'].'_block'); + $params['caption'] = $this->Application->Phrase($record['DisplayName']); + $ret .= $this->Application->ParseBlock($params); + } + return $ret; + } + /** * Returns last modification date of items in category / system * Index: branches/RC/core/units/permissions/permissions_event_handler.php =================================================================== diff -u -N -r8929 -r9363 --- branches/RC/core/units/permissions/permissions_event_handler.php (.../permissions_event_handler.php) (revision 8929) +++ branches/RC/core/units/permissions/permissions_event_handler.php (.../permissions_event_handler.php) (revision 9363) @@ -31,7 +31,7 @@ $object =& $event->getObject( Array('skip_autoload' => true) ); $permissions_helper =& $this->Application->recallObject('PermissionsHelper'); /* @var $permissions_helper kPermissionsHelper */ - + $permissions_helper->LoadPermissions($group_id, $category_id, 0, 'c'); // format: ['inherited'] || ['value'] @@ -99,7 +99,7 @@ $group_id = $this->Application->GetVar('g_id'); $permissions_helper =& $this->Application->recallObject('PermissionsHelper'); /* @var $permissions_helper kPermissionsHelper */ - + $permissions_helper->LoadPermissions($group_id, 0, 1, 'g'); $delete_ids = Array(); @@ -113,12 +113,12 @@ $sections_helper =& $this->Application->recallObject('SectionsHelper'); foreach ($permissions as $section_name => $section_permissions) { $section_data =& $sections_helper->getSectionData($section_name); - + if ($section_data && isset($section_data['perm_prefix'])) { // using permission from other prefix $section_name = $this->Application->getUnitOption($section_data['perm_prefix'].'.main', 'PermSection'); } - + foreach ($section_permissions as $perm_name => $perm_value) { if (!$permissions_helper->isOldPermission($section_name, $perm_name)) { @@ -132,7 +132,7 @@ } elseif ($db_perm_value == 0 && $perm_value == 1) { // permission was enabled => created it's record - $create_sql[] = sprintf($create_mask, $new_id--, $this->Conn->qstr($perm_name), $this->Conn->qstr($perm_value)); + $create_sql[$perm_name] = sprintf($create_mask, $new_id--, $this->Conn->qstr($perm_name), $this->Conn->qstr($perm_value)); } // permission state was not changed in all other cases } Index: branches/RC/kernel/units/config_search/config_search_event_handler.php =================================================================== diff -u -N -r8929 -r9363 --- branches/RC/kernel/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 8929) +++ branches/RC/kernel/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 9363) @@ -81,7 +81,7 @@ $cf_search = Array(); $cf_search['DisplayOrder'] = $custom_field->GetDBField('DisplayOrder'); - $cf_search['ElementType'] = $custom_field->GetDBField('ElementType'); + $cf_search['FieldType'] = $custom_field->GetDBField('ElementType'); $cf_search['DisplayName'] = $custom_field->GetDBField('FieldLabel'); $cf_search['FieldName'] = $custom_field->GetDBField('FieldName'); $cf_search['Description'] = $custom_field->GetDBField('Prompt'); Index: branches/RC/core/units/groups/groups_config.php =================================================================== diff -u -N -r8929 -r9363 --- branches/RC/core/units/groups/groups_config.php (.../groups_config.php) (revision 8929) +++ branches/RC/core/units/groups/groups_config.php (.../groups_config.php) (revision 9363) @@ -89,24 +89,24 @@ 'Default' => Array( 'Icons' => Array(1 => 'icon16_group.gif', 0 => 'icon16_group_disabled.gif'), 'Fields' => Array( - 'GroupId' => Array('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td'), + 'GroupId' => Array('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'), 'Name' => Array('title' => 'la_col_GroupName'), - 'UserCount' => Array('title' => 'la_col_UserCount'), + 'UserCount' => Array('title' => 'la_col_UserCount', 'filter_block' => 'grid_range_filter'), ), ), 'UserGroups' => Array ( 'Icons' => Array (1 => 'icon16_group.gif', 0 => 'icon16_group_disabled.gif'), 'Fields' => Array ( - 'GroupId' => Array('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td'), + 'GroupId' => Array('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'), 'Name' => Array('title' => 'la_col_GroupName'), ), ), 'Radio' => Array ( 'Icons' => Array(1 => 'icon16_group.gif', 0 => 'icon16_group_disabled.gif'), 'Fields' => Array( - 'GroupId' => Array('title' => 'la_col_Id', 'data_block' => 'grid_radio_td'), + 'GroupId' => Array('title' => 'la_col_Id', 'data_block' => 'grid_radio_td', 'filter_block' => 'grid_range_filter'), 'Name' => Array('title' => 'la_col_GroupName'), 'Description' => Array('title' => 'la_col_Description'), ), @@ -115,7 +115,7 @@ 'GroupSelector' => Array ( 'Icons' => Array(1 => 'icon16_group.gif', 0 => 'icon16_group_disabled.gif'), 'Fields' => Array( - 'GroupId' => Array('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td'), + 'GroupId' => Array('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'), 'Name' => Array('title' => 'la_col_GroupName'), 'Description' => Array('title' => 'la_col_Description'), ), Index: branches/RC/core/units/related_searches/related_searches_config.php =================================================================== diff -u -N -r9329 -r9363 --- branches/RC/core/units/related_searches/related_searches_config.php (.../related_searches_config.php) (revision 9329) +++ branches/RC/core/units/related_searches/related_searches_config.php (.../related_searches_config.php) (revision 9363) @@ -17,18 +17,7 @@ 'EventHandlerClass' => Array('class'=>'RelatedSearchEventHandler','file'=>'related_searches_event_handler.php','build_event'=>'OnBuild'), 'TagProcessorClass' => Array('class'=>'RelatedSearchTagProcessor','file'=>'related_searches_tag_processor.php','build_event'=>'OnBuild'), 'AutoLoad' => true, - 'Hooks' => Array( - Array( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => '#PARENT#', - 'HookToSpecial' => '*', - 'HookToEvent' => Array('OnAfterItemDelete'), - 'DoPrefix' => '', - 'DoSpecial' => '', - /*'DoEvent' => 'OnDeleteForeignRelations',*/ - ), - ), + 'QueryString' => Array( 1 => 'id', 2 => 'page', Index: branches/RC/core/units/config_search/config_search_event_handler.php =================================================================== diff -u -N -r8929 -r9363 --- branches/RC/core/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 8929) +++ branches/RC/core/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 9363) @@ -81,7 +81,7 @@ $cf_search = Array(); $cf_search['DisplayOrder'] = $custom_field->GetDBField('DisplayOrder'); - $cf_search['ElementType'] = $custom_field->GetDBField('ElementType'); + $cf_search['FieldType'] = $custom_field->GetDBField('ElementType'); $cf_search['DisplayName'] = $custom_field->GetDBField('FieldLabel'); $cf_search['FieldName'] = $custom_field->GetDBField('FieldName'); $cf_search['Description'] = $custom_field->GetDBField('Prompt'); Index: branches/RC/admin/install/upgrades/inportal_upgrade_v4.2.1.php =================================================================== diff -u -N --- branches/RC/admin/install/upgrades/inportal_upgrade_v4.2.1.php (revision 0) +++ branches/RC/admin/install/upgrades/inportal_upgrade_v4.2.1.php (revision 9363) @@ -0,0 +1,8 @@ +Upgrade_4_2_1('after'); +?> \ No newline at end of file Index: branches/RC/kernel/units/related_searches/related_searches_config.php =================================================================== diff -u -N -r9329 -r9363 --- branches/RC/kernel/units/related_searches/related_searches_config.php (.../related_searches_config.php) (revision 9329) +++ branches/RC/kernel/units/related_searches/related_searches_config.php (.../related_searches_config.php) (revision 9363) @@ -17,18 +17,7 @@ 'EventHandlerClass' => Array('class'=>'RelatedSearchEventHandler','file'=>'related_searches_event_handler.php','build_event'=>'OnBuild'), 'TagProcessorClass' => Array('class'=>'RelatedSearchTagProcessor','file'=>'related_searches_tag_processor.php','build_event'=>'OnBuild'), 'AutoLoad' => true, - 'Hooks' => Array( - Array( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => '#PARENT#', - 'HookToSpecial' => '*', - 'HookToEvent' => Array('OnAfterItemDelete'), - 'DoPrefix' => '', - 'DoSpecial' => '', - /*'DoEvent' => 'OnDeleteForeignRelations',*/ - ), - ), + 'QueryString' => Array( 1 => 'id', 2 => 'page', Index: branches/RC/core/kernel/languages/phrases_cache.php =================================================================== diff -u -N -r8929 -r9363 --- branches/RC/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 8929) +++ branches/RC/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 9363) @@ -26,7 +26,23 @@ function Init($prefix, $special = '') { - $this->LanguageId = constOn('IS_INSTALL') ? 1 : $this->Application->GetVar('m_lang'); + if (constOn('IS_INSTALL')) { + $this->LanguageId = 1; + } + else { + if ($this->Application->IsAdmin()) { + $id_field = $this->Application->getUnitOption('lang', 'IDField'); + $table_name = $this->Application->getUnitOption('lang', 'TableName'); + $sql = 'SELECT '.$id_field.' + FROM '.$table_name.' + WHERE AdminInterfaceLang = 1'; + $this->LanguageId = $this->Conn->GetOne($sql); + } + else { + $this->LanguageId = $this->Application->GetVar('m_lang'); + } + } + if (isset($this->Application->Caches['PhraseList'])) { $this->LoadPhrases( $this->Application->Caches['PhraseList'] ); } Index: branches/RC/core/units/languages/languages_config.php =================================================================== diff -u -N -r9280 -r9363 --- branches/RC/core/units/languages/languages_config.php (.../languages_config.php) (revision 9280) +++ branches/RC/core/units/languages/languages_config.php (.../languages_config.php) (revision 9363) @@ -136,17 +136,20 @@ ), // key - special, value - list select sql 'ItemSQLs' => Array( ''=>'SELECT * FROM %s', ), - 'ListSortings' => Array( - '' => Array( - 'Sorting' => Array('PackName' => 'asc'), - ) - ), + 'ListSortings' => Array ( + '' => Array ( + 'Sorting' => Array ('Priority' => 'desc', 'PackName' => 'asc'), + ), + ), + 'Fields' => Array( 'LanguageId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), 'PackName' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'LocalName' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'Enabled' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(0 => 'la_Disabled', 1 => 'la_Enabled'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 1), - 'PrimaryLang' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), + 'PrimaryLang' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0), + 'AdminInterfaceLang' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0), + 'Priority' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'IconURL' => Array('type' => 'string','default' => null), 'DateFormat' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'TimeFormat' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), @@ -164,16 +167,18 @@ ), 'Grids' => Array( - 'Default' => Array( - 'Icons' => Array('default'=>'icon16_custom.gif','0_0'=>'icon16_language_disabled.gif','1_0'=>'icon16_language.gif','0_1'=>'icon16_language_disabled.gif','1_1'=>'icon16_language_primary.gif'), - 'Fields' => Array( - 'PackName' => Array( 'title'=>'la_col_PackName', 'data_block' => 'grid_checkbox_td'), - 'LocalName' => Array( 'title'=>'la_col_LocalName' ), - 'Enabled' => Array( 'title'=>'la_col_Status', 'filter_block' => 'grid_options_filter'), - ), - - ), - ), + 'Default' => Array ( + 'Icons' => Array ('default' => 'icon16_custom.gif', '0_0' => 'icon16_language_disabled.gif', '1_0' => 'icon16_language.gif', '0_1' => 'icon16_language_disabled.gif', '1_1' => 'icon16_language_primary.gif'), + 'Fields' => Array( + 'LanguageId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'), + 'PackName' => Array ('title' => 'la_col_PackName',), + 'LocalName' => Array ('title' => 'la_col_LocalName'), + 'Enabled' => Array ('title' => 'la_col_Status', 'filter_block' => 'grid_options_filter'), + 'PrimaryLang' => Array ('title' => 'la_col_IsPrimary', 'filter_block' => 'grid_options_filter'), + 'AdminInterfaceLang' => Array ('title' => 'la_col_AdminInterfaceLang', 'filter_block' => 'grid_options_filter'), + ), + ), + ), ); ?> \ No newline at end of file Index: branches/RC/core/admin_templates/groups/groups_edit_permissions.tpl =================================================================== diff -u -N -r8953 -r9363 --- branches/RC/core/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 8953) +++ branches/RC/core/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 9363) @@ -63,7 +63,7 @@ - + [][]" name="[][]" value=""> [][]" name="_cb_[][]" checked onchange="update_checkbox(this, document.getElementById('[][]'));" onclick=""> Index: branches/RC/kernel/admin_templates/groups/groups_edit_permissions.tpl =================================================================== diff -u -N -r8953 -r9363 --- branches/RC/kernel/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 8953) +++ branches/RC/kernel/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 9363) @@ -63,7 +63,7 @@ - + [][]" name="[][]" value=""> [][]" name="_cb_[][]" checked onchange="update_checkbox(this, document.getElementById('[][]'));" onclick=""> Index: branches/RC/core/units/languages/languages_event_handler.php =================================================================== diff -u -N -r8929 -r9363 --- branches/RC/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 8929) +++ branches/RC/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 9363) @@ -55,6 +55,8 @@ if ($ids) { $id = array_shift($ids); $object =& $event->getObject( Array('skip_autoload' => true) ); + /* @var $object LanguagesItem */ + $object->Load($id); $object->setPrimary(); } @@ -68,16 +70,21 @@ function OnUpdatePrimary(&$event) { $object =& $event->getObject( Array('skip_autoload' => true) ); + /* @var $object LanguagesItem */ + $object->SwitchToLive(); // set primary for each languages, that have this checkbox checked $ids = explode(',', $event->MasterEvent->getEventParam('ids')); foreach ($ids as $id) { $object->Load($id); if ($object->GetDBField('PrimaryLang')) { - $object->setPrimary(); + $object->setPrimary(true, false); } + if ($object->GetDBField('AdminInterfaceLang')) { + $object->setPrimary(true, true); + } } // if no primary language left, then set primary last language (not to load again) from edited list @@ -87,8 +94,17 @@ $primary_language = $this->Conn->GetOne($sql); if (!$primary_language) { - $object->setPrimary(false); + $object->setPrimary(false, false); // set primary language } + + $sql = 'SELECT '.$object->IDField.' + FROM '.$object->TableName.' + WHERE AdminInterfaceLang = 1'; + $primary_language = $this->Conn->GetOne($sql); + + if (!$primary_language) { + $object->setPrimary(false, true); // set admin interface language + } } @@ -453,7 +469,7 @@ $object =& $event->getObject(array('skip_autload' => true)); $object->Load($del_id); - if ($object->GetDBField('PrimaryLang') || $del_id == $this->Application->GetVar('m_lang')) { + if ($object->GetDBField('PrimaryLang') || $object->GetDBField('AdminInterfaceLang') || $del_id == $this->Application->GetVar('m_lang')) { $event->status = erFAIL; } } Index: branches/RC/core/install/upgrades.sql =================================================================== diff -u -N -r9295 -r9363 --- branches/RC/core/install/upgrades.sql (.../upgrades.sql) (revision 9295) +++ branches/RC/core/install/upgrades.sql (.../upgrades.sql) (revision 9363) @@ -126,4 +126,8 @@ INSERT INTO ConfigurationAdmin VALUES ('UseSmallHeader', 'la_Text_Website', 'la_config_UseSmallHeader', 'checkbox', '', '', 10.21, 0, 0); INSERT INTO ConfigurationValues VALUES (DEFAULT, 'UseSmallHeader', '0', 'In-Portal', 'in-portal:configure_general'); ALTER TABLE Category ADD SymLinkCategoryId INT UNSIGNED NULL DEFAULT NULL AFTER `Type`, ADD INDEX (SymLinkCategoryId); -ALTER TABLE ConfigurationValues CHANGE VariableValue VariableValue TEXT NULL DEFAULT NULL; \ No newline at end of file +ALTER TABLE ConfigurationValues CHANGE VariableValue VariableValue TEXT NULL DEFAULT NULL; + +ALTER TABLE Language + ADD AdminInterfaceLang TINYINT UNSIGNED NOT NULL AFTER PrimaryLang, + ADD Priority INT NOT NULL AFTER AdminInterfaceLang; \ No newline at end of file Index: branches/RC/core/admin_templates/regional/languages_edit.tpl =================================================================== diff -u -N -r8929 -r9363 --- branches/RC/core/admin_templates/regional/languages_edit.tpl (.../languages_edit.tpl) (revision 8929) +++ branches/RC/core/admin_templates/regional/languages_edit.tpl (.../languages_edit.tpl) (revision 9363) @@ -74,12 +74,14 @@ + + "> - + : Index: branches/RC/core/admin_templates/incs/form_blocks.tpl =================================================================== diff -u -N -r9339 -r9363 --- branches/RC/core/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 9339) +++ branches/RC/core/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 9363) @@ -1,4 +1,4 @@ - + Index: branches/RC/core/units/general/cat_event_handler.php =================================================================== diff -u -N -r9302 -r9363 --- branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 9302) +++ branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 9363) @@ -934,7 +934,14 @@ // processing fields from local table if ($search_config[$field]['CustomFieldId']) { $local_table = 'custom_data'; - $field_list[$key] = 'l'.$lang.'_cust_'.array_search($field_list[$key], $custom_fields); + + // search by custom field value on current language + $custom_field_id = array_search($field_list[$key], $custom_fields); + $field_list[$key] = 'l'.$lang.'_cust_'.$custom_field_id; + + // search by custom field value on primary language + $field_list[$key.'_primary'] = 'l'.$this->Application->GetDefaultLanguageId().'_cust_'.$custom_field_id; + $search_config_map[ $field_list[$key.'_primary'] ] = $field; } $field_list[$key] = $local_table.'.'.$field_list[$key]; $search_config_map[ $field_list[$key] ] = $field; Index: branches/RC/admin/install/upgrades/inportal_upgrade_v4.2.1.sql =================================================================== diff -u -N -r9295 -r9363 --- branches/RC/admin/install/upgrades/inportal_upgrade_v4.2.1.sql (.../inportal_upgrade_v4.2.1.sql) (revision 9295) +++ branches/RC/admin/install/upgrades/inportal_upgrade_v4.2.1.sql (.../inportal_upgrade_v4.2.1.sql) (revision 9363) @@ -4,5 +4,7 @@ ALTER TABLE Category ADD SymLinkCategoryId INT UNSIGNED NULL DEFAULT NULL AFTER `Type`, ADD INDEX (SymLinkCategoryId); ALTER TABLE ConfigurationValues CHANGE VariableValue VariableValue TEXT NULL DEFAULT NULL; +ALTER TABLE Language ADD AdminInterfaceLang TINYINT UNSIGNED NOT NULL AFTER PrimaryLang, ADD Priority INT NOT NULL AFTER AdminInterfaceLang; + UPDATE Modules SET Version = '4.2.1' WHERE Name = 'Core'; UPDATE Modules SET Version = '4.2.1' WHERE Name = 'In-Portal'; \ No newline at end of file Index: branches/RC/core/units/languages/languages_item.php =================================================================== diff -u -N -r8929 -r9363 --- branches/RC/core/units/languages/languages_item.php (.../languages_item.php) (revision 8929) +++ branches/RC/core/units/languages/languages_item.php (.../languages_item.php) (revision 9363) @@ -8,16 +8,17 @@ return $this->Conn->GetOne($sql) + 1; } - function setPrimary($reset_primary = true) + function setPrimary($reset_primary = true, $admin_language = false) { + $primary_field = $admin_language ? 'AdminInterfaceLang' : 'PrimaryLang'; if ($reset_primary) { $sql = 'UPDATE '.$this->TableName.' - SET PrimaryLang = 0'; + SET '.$primary_field.' = 0'; $this->Conn->Query($sql); } $sql = 'UPDATE '.$this->TableName.' - SET PrimaryLang = 1, Enabled = 1 + SET '.$primary_field.' = 1, Enabled = 1 WHERE '.$this->IDField.' = '.$this->GetID(); $this->Conn->Query($sql); } Index: branches/RC/core/install/upgrades.php =================================================================== diff -u -N -r9127 -r9363 --- branches/RC/core/install/upgrades.php (.../upgrades.php) (revision 9127) +++ branches/RC/core/install/upgrades.php (.../upgrades.php) (revision 9363) @@ -157,6 +157,37 @@ } } + /** + * Makes admin primary language same as front-end + * + * @param string $mode when called mode {before, after) + */ + function Upgrade_4_2_1($mode) + { + if ($mode == 'after') { + $id_field = $this->Application->getUnitOption('lang', 'IDField'); + $table_name = $this->Application->getUnitOption('lang', 'TableName'); + + $sql = 'SELECT '.$id_field.' + FROM '.$table_name.' + WHERE PrimaryLang = 1 AND Enabled = 1'; + $language_id = $this->Conn->GetOne($sql); + + if ($language_id) { + // reset admin language + $sql = 'UPDATE '.$table_name.' + SET AdminInterfaceLang = 0'; + $this->Conn->Query($sql); + + // set admin language to front-end + $sql = 'UPDATE '.$table_name.' + SET AdminInterfaceLang = 1 + WHERE '.$id_field.' = '.$language_id; + $this->Conn->Query($sql); + } + } + } + } ?> \ No newline at end of file