Index: admin_templates/users/admins_edit.tpl
===================================================================
--- admin_templates/users/admins_edit.tpl (revision 14949)
+++ admin_templates/users/admins_edit.tpl (working copy)
@@ -75,7 +75,9 @@
-
+
+
+
Index: admin_templates/users/users_edit.tpl
===================================================================
--- admin_templates/users/users_edit.tpl (revision 14949)
+++ admin_templates/users/users_edit.tpl (working copy)
@@ -83,8 +83,9 @@
-
+
+
Index: install/english.lang
===================================================================
--- install/english.lang (revision 14964)
+++ install/english.lang (working copy)
@@ -306,6 +306,7 @@
QWRkcmVzcyBMaW5lIDI=
TWVzc2FnZXMgZnJvbSBTaXRlIEFkbWluIGFyZSBmcm9t
QWRtaW4gUHJpbWFyeQ==
+ TGFuZ3VhZ2U=
QWR2YW5jZWQgQ1NT
QWR2YW5jZWQgU2VhcmNo
QWxsb3cgQ2hhbmdpbmcgIlRvIiBSZWNpcGllbnQ=
@@ -428,6 +429,7 @@
U2hvcnQgVVJM
RnJvbSBFbWFpbA==
RnJvbnQtRW5kIE9ubHk=
+ TGFuZ3VhZ2U=
QWxsb3cgUmVnaXN0cmF0aW9uIG9uIEZyb250LWVuZA==
RnVsbCBOYW1l
VXNlciBHcm91cA==
Index: install/install_schema.sql
===================================================================
--- install/install_schema.sql (revision 14949)
+++ install/install_schema.sql (working copy)
@@ -268,6 +268,7 @@
IsBanned tinyint(1) NOT NULL DEFAULT '0',
PwResetConfirm varchar(255) NOT NULL,
PwRequestTime int(11) unsigned DEFAULT NULL,
+ FrontLanguage int(11) DEFAULT NULL,
AdminLanguage int(11) DEFAULT NULL,
DisplayToPublic text,
UserType tinyint(4) NOT NULL,
@@ -281,7 +282,6 @@
KEY Modified (Modified),
KEY dob (dob),
KEY IsBanned (IsBanned),
- KEY AdminLanguage (AdminLanguage),
KEY UserType (UserType),
KEY Username (Username)
);
Index: install/upgrades.sql
===================================================================
--- install/upgrades.sql (revision 14964)
+++ install/upgrades.sql (working copy)
@@ -2503,3 +2503,10 @@
DELETE FROM ConfigurationValues
WHERE VariableName IN ('User_Review_Deny', 'User_Votes_Deny');
+
+ALTER TABLE PortalUser ADD FrontLanguage INT(11) NULL AFTER PwRequestTime;
+ALTER TABLE PortalUser DROP INDEX AdminLanguage;
+
+UPDATE PortalUser
+SET FrontLanguage = 1
+WHERE UserType = 0;
\ No newline at end of file
Index: units/email_events/email_events_event_handler.php
===================================================================
--- units/email_events/email_events_event_handler.php (revision 14949)
+++ units/email_events/email_events_event_handler.php (working copy)
@@ -321,7 +321,7 @@
* @param Array $direct_params
* @return Array
*/
- function _processRecipients(&$event, $direct_params = Array ())
+ function _processRecipients(&$event, &$direct_params = Array ())
{
$this->Application->removeObject('u.email-to');
@@ -348,7 +348,9 @@
$to_user_id = $event->getEventParam('EmailEventToUserId');
if ( $to_user_id > 0 ) {
- $sql = 'SELECT FirstName, LastName, Email
+ $language_field = $event->getEventParam('EmailEventType') == EmailEvent::EVENT_TYPE_FRONTEND ? 'FrontLanguage' : 'AdminLanguage';
+
+ $sql = 'SELECT FirstName, LastName, Email, ' . $language_field . ' AS Language
FROM ' . TABLE_PREFIX . 'PortalUser
WHERE PortalUserId = ' . $to_user_id;
$user_info = $this->Conn->GetRow($sql);
@@ -360,6 +362,10 @@
'RecipientName' => trim($user_info['FirstName'] . ' ' . $user_info['LastName']),
);
+ if ( $user_info['Language'] && !isset($direct_params['language_id']) ) {
+ $direct_params['language_id'] = $user_info['Language'];
+ }
+
array_unshift($all_recipients[EmailEvent::RECIPIENT_TYPE_TO], $add_recipient);
$user =& $this->Application->recallObject('u.email-to', null, Array('skip_autoload' => true));
Index: units/helpers/user_helper.php
===================================================================
--- units/helpers/user_helper.php (revision 14949)
+++ units/helpers/user_helper.php (working copy)
@@ -362,17 +362,15 @@
*/
protected function _processInterfaceLanguage()
{
- if ( !$this->Application->isAdmin ) {
- return;
- }
-
+ $language_field = $this->Application->isAdmin ? 'AdminLanguage' : 'FrontLanguage';
+ $primary_language_field = $this->Application->isAdmin ? 'AdminInterfaceLang' : 'PrimaryLang';
$is_root = $this->Application->RecallVar('user_id') == USER_ROOT;
$object =& $this->getUserObject();
- $user_language_id = $is_root ? $this->Application->RecallPersistentVar('AdminLanguage') : $object->GetDBField('AdminLanguage');
+ $user_language_id = $is_root ? $this->Application->RecallPersistentVar($language_field) : $object->GetDBField($language_field);
- $sql = 'SELECT LanguageId, IF(LanguageId = ' . (int)$user_language_id . ', 2, AdminInterfaceLang) AS SortKey
+ $sql = 'SELECT LanguageId, IF(LanguageId = ' . (int)$user_language_id . ', 2, ' . $primary_language_field . ') AS SortKey
FROM ' . TABLE_PREFIX . 'Language
WHERE Enabled = 1
HAVING SortKey <> 0
@@ -381,12 +379,12 @@
$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 deleted or disabled
+ // first login OR language was deleted or disabled
if ( $is_root ) {
- $this->Application->StorePersistentVar('AdminLanguage', $language_id);
+ $this->Application->StorePersistentVar($language_field, $language_id);
}
else {
- $object->SetDBField('AdminLanguage', $language_id);
+ $object->SetDBField($language_field, $language_id);
$object->Update();
}
}
Index: units/languages/languages_event_handler.php
===================================================================
--- units/languages/languages_event_handler.php (revision 14949)
+++ units/languages/languages_event_handler.php (working copy)
@@ -397,33 +397,27 @@
function OnChangeLanguage(&$event)
{
$language_id = $this->Application->GetVar('language');
+ $language_field = $this->Application->isAdmin ? 'AdminLanguage' : 'FrontLanguage';
- if ($this->Application->isAdmin) {
- // admin data only
- $this->Application->SetVar('m_lang', $language_id);
+ $this->Application->SetVar('m_lang', $language_id);
- // set new language for this session (admin interface only)
- $this->Application->Session->SetField('Language', $language_id);
+ // set new language for this session
+ $this->Application->Session->SetField('Language', $language_id);
- // remember last user language in administrative console
- if ($this->Application->RecallVar('user_id') == USER_ROOT) {
- $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);
+ // remember last user language
+ if ($this->Application->RecallVar('user_id') == USER_ROOT) {
+ $this->Application->StorePersistentVar($language_field, $language_id);
}
else {
- // changing language on Front-End
- $this->Application->SetVar('m_lang', $language_id);
+ $object =& $this->Application->recallObject('u.current');
+ /* @var $object kDBItem */
+
+ $object->SetDBField($language_field, $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);
}
/**
Index: units/users/users_config.php
===================================================================
--- units/users/users_config.php (revision 14949)
+++ units/users/users_config.php (working copy)
@@ -389,6 +389,10 @@
'IsBanned' => Array ('default' => 0),
'PwResetConfirm' => Array ('default' => ''),
'PwRequestTime' => Array ('formatter' => 'kDateFormatter', 'default' => NULL),
+ 'FrontLanguage' => Array (
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language ORDER BY PackName',
+ 'option_key_field' => 'LanguageId', 'option_title_field' => 'LocalName', 'default' => NULL
+ ),
'AdminLanguage' => Array (
'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language ORDER BY PackName',
'option_key_field' => 'LanguageId', 'option_title_field' => 'LocalName', 'default' => NULL
@@ -540,6 +544,7 @@
'IsBanned' => Array ('type' => 'int', 'not_null' => 1),
'PwResetConfirm' => Array ('type' => 'string', 'not_null' => 1),
'PwRequestTime' => Array ('type' => 'int'),
+ 'FrontLanguage' => Array ('type' => 'int'),
'AdminLanguage' => Array ('type' => 'int'),
'DisplayToPublic' => Array ('type' => 'string'),
'UserType' => Array ('type' => 'int', 'not_null' => 1),
Index: units/users/users_event_handler.php
===================================================================
--- units/users/users_event_handler.php (revision 14955)
+++ units/users/users_event_handler.php (working copy)
@@ -518,6 +518,10 @@
}
$object->SetDBField('IPAddress', $_SERVER['REMOTE_ADDR']);
+
+ if ( !$this->Application->isAdmin ) {
+ $object->SetDBField('FrontLanguage', $this->Application->GetVar('m_lang'));
+ }
}
/**
@@ -1630,6 +1634,21 @@
// get user subscription status
$object->SetDBField('SubscribeToMailing', $object->isSubscribed() ? 1 : 0);
+
+ if ( !$this->Application->isAdmin ) {
+ $list = $this->Application->recallObject('lang.enabled', 'lang_List');
+ /* @var $list kDBList */
+
+ $list->GoFirst();
+ $languages = Array ();
+
+ while (!$list->EOL()) {
+ $languages[$list->GetID()] = $list->GetField('LocalName');
+ $list->GoNext();
+ }
+
+ $object->SetFieldOption('FrontLanguage', 'options', $languages);
+ }
}
/**