Index: admin_templates/users/admins_edit.tpl
===================================================================
--- admin_templates/users/admins_edit.tpl (revision 14925)
+++ admin_templates/users/admins_edit.tpl (working copy)
@@ -75,7 +75,8 @@
-
+
+
Index: admin_templates/users/users_edit.tpl
===================================================================
--- admin_templates/users/users_edit.tpl (revision 14925)
+++ admin_templates/users/users_edit.tpl (working copy)
@@ -83,8 +83,9 @@
-
+
+
Index: install/english.lang
===================================================================
--- install/english.lang (revision 14925)
+++ install/english.lang (working copy)
@@ -302,6 +302,7 @@
QWRkcmVzcyBMaW5lIDI=
TWVzc2FnZXMgZnJvbSBTaXRlIEFkbWluIGFyZSBmcm9t
QWRtaW4gUHJpbWFyeQ==
+ TGFuZ3VhZ2U=
QWR2YW5jZWQgQ1NT
QWR2YW5jZWQgU2VhcmNo
QWxsb3cgQ2hhbmdpbmcgIlRvIiBSZWNpcGllbnQ=
@@ -423,6 +424,7 @@
U2hvcnQgVVJM
RnJvbSBFbWFpbA==
RnJvbnQtRW5kIE9ubHk=
+ TGFuZ3VhZ2U=
QWxsb3cgUmVnaXN0cmF0aW9uIG9uIEZyb250LWVuZA==
VXNlciBHcm91cA==
SUQ=
Index: install/install_schema.sql
===================================================================
--- install/install_schema.sql (revision 14925)
+++ 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 14925)
+++ install/upgrades.sql (working copy)
@@ -2428,4 +2428,7 @@
UPDATE ConfigurationValues
SET HintLabel = CONCAT('hint:', Prompt)
-WHERE VariableName IN ('ForceModRewriteUrlEnding', 'PerformExactSearch');
\ No newline at end of file
+WHERE VariableName IN ('ForceModRewriteUrlEnding', 'PerformExactSearch');
+
+ALTER TABLE PortalUser ADD FrontLanguage INT(11) NULL AFTER PwRequestTime;
+ALTER TABLE PortalUser DROP INDEX AdminLanguage;
\ No newline at end of file
Index: units/email_events/email_events_event_handler.php
===================================================================
--- units/email_events/email_events_event_handler.php (revision 14925)
+++ units/email_events/email_events_event_handler.php (working copy)
@@ -297,7 +297,7 @@
* @param kEvent $event
* @param Array $direct_params
*/
- function _processRecipients(&$event, $direct_params = Array ())
+ function _processRecipients(&$event, &$direct_params = Array ())
{
$this->Application->removeObject('u.email-to');
@@ -341,7 +341,8 @@
$to_user_id = $event->getEventParam('EmailEventToUserId');
if ($to_user_id > 0) {
- $sql = 'SELECT FirstName, LastName, Email
+ $language_field = $event->getEventParam('EmailEventType') ? 'AdminLanguage' : 'FrontLanguage';
+ $sql = 'SELECT FirstName, LastName, Email, '.$language_field.' AS Language
FROM ' . TABLE_PREFIX . 'PortalUser
WHERE PortalUserId = ' . $to_user_id;
$user_info = $this->Conn->GetRow($sql);
@@ -353,6 +354,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 14925)
+++ 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 14925)
+++ 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 14942)
+++ 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 14942)
+++ units/users/users_event_handler.php (working copy)
@@ -1629,6 +1629,24 @@
// get user subscription status
$object->SetDBField('SubscribeToMailing', $object->isSubscribed() ? 1 : 0);
+
+ if (!$this->Application->isAdmin) {
+ // Set language limitations
+
+ $list = $this->Application->recallObject('lang.enabled', 'lang_List');
+ /* @var $list kDBList */
+
+ $list->GoFirst();
+ $lang_options = Array();
+
+ while (!$list->EOL()) {
+ $lang_options[$list->GetId()] = $list->GetField('PackName');
+ $list->GoNext();
+ }
+
+ $object->SetFieldOption('FrontLanguage', 'options', $lang_options);
+ $object->SetFieldOption('FrontLanguage', 'options_prepared', true);
+ }
}
/**