Index: branches/5.0.x/core/units/users/users_event_handler.php
===================================================================
diff -u -r12960 -r12970
--- branches/5.0.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 12960)
+++ branches/5.0.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 12970)
@@ -1,6 +1,6 @@
Application->HandleEvent($dummy, 'session-log:OnStartSession');
$this->processLoginRedirect($event, $password);
+ $this->_processInterfaceLanguage($event);
return true;
}
else {
@@ -325,6 +326,7 @@
if (!$remember_login_cookie) {
$this->processLoginRedirect($event, $password);
+ $this->_processInterfaceLanguage($event);
}
}
else {
@@ -343,6 +345,47 @@
}
/**
+ * Sets correct interface language after sucessful login, based on user settings
+ *
+ * @param kEvent $event
+ */
+ function _processInterfaceLanguage(&$event)
+ {
+ if (($event->status != erSUCCESS) || !$this->Application->isAdmin) {
+ return ;
+ }
+
+ $is_root = $this->Application->RecallVar('user_id') == -1;
+
+ $object =& $this->Application->recallObject('u.current');
+ /* @var $object kDBItem */
+
+ $user_language_id = $is_root ? $this->Application->RecallPersistentVar('AdminLanguage') : $object->GetDBField('AdminLanguage');
+
+ $sql = 'SELECT LanguageId, IF(LanguageId = ' . (int)$user_language_id . ', 2, AdminInterfaceLang) AS SortKey
+ FROM ' . TABLE_PREFIX . 'Language
+ WHERE Enabled = 1
+ HAVING SortKey <> 0
+ ORDER BY SortKey DESC';
+ $language_info = $this->Conn->GetRow($sql);
+ $language_id = $language_info && $language_info['LanguageId'] ? $language_info['LanguageId'] : $user_language_id;
+
+ if ($user_language_id != $language_id) {
+ // first admin login OR language was delelted or disabled
+ if ($is_root) {
+ $this->Application->StorePersistentVar('AdminLanguage', $language_id);
+ }
+ else {
+ $object->SetDBField('AdminLanguage', $language_id);
+ $object->Update();
+ }
+ }
+
+ $event->SetRedirectParam('m_lang', $language_id); // data
+ $this->Application->Session->SetField('Language', $language_id); // interface
+ }
+
+ /**
* [HOOK] Auto-Logins Front-End user when "Remember Login" cookie is found
*
* @param kEvent $event
Index: branches/5.0.x/core/install/install_schema.sql
===================================================================
diff -u -r12877 -r12970
--- branches/5.0.x/core/install/install_schema.sql (.../install_schema.sql) (revision 12877)
+++ branches/5.0.x/core/install/install_schema.sql (.../install_schema.sql) (revision 12970)
@@ -250,14 +250,16 @@
PwResetConfirm varchar(255) DEFAULT NULL,
PwRequestTime int(11) unsigned DEFAULT NULL,
MinPwResetDelay int(11) NOT NULL DEFAULT '1800',
+ AdminLanguage int(11) DEFAULT NULL,
PRIMARY KEY (PortalUserId),
UNIQUE KEY ResourceId (ResourceId),
UNIQUE KEY Login (Login),
KEY CreatedOn (CreatedOn),
KEY `Status` (`Status`),
KEY Modified (Modified),
KEY dob (dob),
- KEY IsBanned (IsBanned)
+ KEY IsBanned (IsBanned),
+ KEY AdminLanguage (AdminLanguage)
);
CREATE TABLE PortalUserCustomData (
Index: branches/5.0.x/core/admin_templates/users/user_edit_items.tpl
===================================================================
diff -u -r12117 -r12970
--- branches/5.0.x/core/admin_templates/users/user_edit_items.tpl (.../user_edit_items.tpl) (revision 12117)
+++ branches/5.0.x/core/admin_templates/users/user_edit_items.tpl (.../user_edit_items.tpl) (revision 12970)
@@ -21,7 +21,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '';
+ Request.progressText = '';
Catalog.prototype.AfterInit = function () {
this.switchTab(); // refresh current item tab
Index: branches/5.0.x/core/units/languages/languages_event_handler.php
===================================================================
diff -u -r12960 -r12970
--- branches/5.0.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 12960)
+++ branches/5.0.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 12970)
@@ -1,6 +1,6 @@
SetDBField('CopyFromLanguage', $primary_lang_id);
}
-
function OnChangeLanguage(&$event)
{
- $this->Application->SetVar('m_lang', $this->Application->GetVar('language'));
+ $language_id = $this->Application->GetVar('language');
if ($this->Application->isAdmin) {
+ // admin data only
+ $this->Application->SetVar('m_lang', $language_id);
+
+ // set new language for this session (admin interface only)
+ $this->Application->Session->SetField('Language', $language_id);
+
+ // remember last user language in administrative console
+ if ($this->Application->RecallVar('user_id') == -1) {
+ $this->Application->StorePersistentVar('AdminLanguage', $language_id);
+ }
+ else {
+ $object =& $this->Application->recallObject('u.current');
+ /* @var $object kDBItem */
+
+ $object->SetDBField('AdminLanguage', $language_id);
+ $object->Update();
+ }
+
// without this language change in admin will cause erase of last remembered tree section
$this->Application->SetVar('skip_last_template', 1);
}
- elseif (MOD_REWRITE) {
- $mod_rewrite_helper =& $this->Application->recallObject('ModRewriteHelper');
- /* @var $mod_rewrite_helper kModRewriteHelper */
+ else {
+ // changing language on Front-End
+ $this->Application->SetVar('m_lang', $language_id);
- $mod_rewrite_helper->removePages();
- }
+ if (MOD_REWRITE) {
+ $mod_rewrite_helper =& $this->Application->recallObject('ModRewriteHelper');
+ /* @var $mod_rewrite_helper kModRewriteHelper */
- //$this->Application->LinkVar('language', 'm_lang');
+ $mod_rewrite_helper->removePages();
+ }
+ }
}
/**
Index: branches/5.0.x/core/units/helpers/permissions_helper.php
===================================================================
diff -u -r12898 -r12970
--- branches/5.0.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 12898)
+++ branches/5.0.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 12970)
@@ -1,6 +1,6 @@
Application->GetVar('t');
- $redirect_params = $this->Application->HttpQuery->getRedirectParams(true);
- $redirect_params['no_amp'] = 1;
- $next_template = $this->Application->HREF($t, '', $redirect_params);
+ if (MOD_REWRITE) {
+// $event->SetRedirectParam('m_cat_id', 0); // category means nothing on admin login screen
+ $event->SetRedirectParam('next_template', urlencode('external:' . $_SERVER['REQUEST_URI']));
+ }
+ else {
+ $event->SetRedirectParam('next_template', $this->Application->GetVar('t'));
+ }
- $event->SetRedirectParam('m_cat_id', 0); // category means nothing on admin login screen
- $event->SetRedirectParam('next_template', urlencode('external:' . $next_template));
-
if ($this->Application->isDebugMode()) {
// for debugging purposes
$event->SetRedirectParam('section', $event->getSection());
@@ -462,10 +462,16 @@
$redirect_params['pass_category'] = $params['pass_cateogry'];
}
- $redirect_params = Array (
- 'm_cat_id' => 0, // category means nothing on admin login screen
- 'next_template' => urlencode('external:' . $this->Application->HREF($t, '', $redirect_params)),
- );
+ if (MOD_REWRITE) {
+ // TODO: $next_t variable is ignored !!! (is anyone using m_RequireLogin tag with "next_template" parameter?)
+ $redirect_params = Array (
+ 'm_cat_id' => 0, // category means nothing on admin login screen
+ 'next_template' => urlencode('external:' . $_SERVER['REQUEST_URI']),
+ );
+ }
+ else {
+ $redirect_params['next_template'] = $t;
+ }
if ($this->Application->isAdmin) {
$redirect_params['m_wid'] = ''; // remove wid, otherwise parent window may add wid to its name breaking all the frameset (for targets)
Index: branches/5.0.x/core/kernel/session/inp_session.php
===================================================================
diff -u -r12734 -r12970
--- branches/5.0.x/core/kernel/session/inp_session.php (.../inp_session.php) (revision 12734)
+++ branches/5.0.x/core/kernel/session/inp_session.php (.../inp_session.php) (revision 12970)
@@ -1,6 +1,6 @@
$this->Application->isAdmin ? 0 : -2, // Guest
- 'Language' => $this->Application->GetDefaultLanguageId(),
+ 'Language' => $this->Application->GetDefaultLanguageId(true),
'Theme' => $this->Application->GetDefaultThemeId(),
'IpAddress' => $_SERVER['REMOTE_ADDR'], // getenv('REMOTE_ADDR') won't work on IIS, so use $_SERVER instead
'GroupId' => $this->Application->ConfigValue('User_GuestGroup'),
Index: branches/5.0.x/core/kernel/languages/phrases_cache.php
===================================================================
diff -u -r12871 -r12970
--- branches/5.0.x/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 12871)
+++ branches/5.0.x/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 12970)
@@ -1,6 +1,6 @@
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);
+ $this->LanguageId = $this->Application->Session->GetField('Language');
}
else {
$this->LanguageId = $this->Application->GetVar('m_lang');
@@ -256,7 +251,7 @@
function LoadPhraseByLabel($label, $original_label, $allow_editing = true, $use_admin = false)
{
- if (!$allow_editing && !array_key_exists($label, $this->_missingPhrases) && array_key_exists($label, $this->Phrases)) {
+ if (!$allow_editing && !$use_admin && !array_key_exists($label, $this->_missingPhrases) && array_key_exists($label, $this->Phrases)) {
// label is aready translated, but it's version without on the fly translation code is requested
$this->Phrases['NE:' . $label] = $this->Phrases[$label];
Index: branches/5.0.x/core/kernel/nparser/nparser.php
===================================================================
diff -u -r12956 -r12970
--- branches/5.0.x/core/kernel/nparser/nparser.php (.../nparser.php) (revision 12956)
+++ branches/5.0.x/core/kernel/nparser/nparser.php (.../nparser.php) (revision 12970)
@@ -1,6 +1,6 @@
_btnPhrases['design'] = $this->Application->Phrase('la_btn_EditDesign', false);
- $this->_btnPhrases['block'] = $this->Application->Phrase('la_btn_EditBlock', false);
+ $this->_btnPhrases['design'] = $this->Application->Phrase('la_btn_EditDesign', false, true);
+ $this->_btnPhrases['block'] = $this->Application->Phrase('la_btn_EditBlock', false, true);
}
}
Index: branches/5.0.x/core/admin_templates/catalog/catalog.tpl
===================================================================
diff -u -r12866 -r12970
--- branches/5.0.x/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 12866)
+++ branches/5.0.x/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 12970)
@@ -31,7 +31,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '';
+ Request.progressText = '';
var $is_catalog = true;
var $Catalog = new Catalog('', 'catalog_', 'Catalog');
$Catalog.TabByCategory = truefalse;
Index: branches/5.0.x/core/units/languages/languages_tag_processor.php
===================================================================
diff -u -r12734 -r12970
--- branches/5.0.x/core/units/languages/languages_tag_processor.php (.../languages_tag_processor.php) (revision 12734)
+++ branches/5.0.x/core/units/languages/languages_tag_processor.php (.../languages_tag_processor.php) (revision 12970)
@@ -1,6 +1,6 @@
getObject($params);
- return $object->GetDBField('LanguageId') == $this->Application->GetVar('m_lang');
+ /* @var $object kDBList */
+
+ if (array_key_exists('type', $params) && $params['type'] == 'data') {
+ // when using language selector on editing forms
+ return $object->GetDBField('LanguageId') == $this->Application->GetVar('m_lang');
+ }
+
+ return $object->GetDBField('LanguageId') == $this->Application->Phrases->LanguageId;
}
/**
Index: branches/5.0.x/core/admin_templates/categories/categories_edit_permissions.tpl
===================================================================
diff -u -r12870 -r12970
--- branches/5.0.x/core/admin_templates/categories/categories_edit_permissions.tpl (.../categories_edit_permissions.tpl) (revision 12870)
+++ branches/5.0.x/core/admin_templates/categories/categories_edit_permissions.tpl (.../categories_edit_permissions.tpl) (revision 12970)
@@ -14,7 +14,7 @@