Attached Files |
preferred_language_core_929.patch [^] (12,837 bytes) 2011-12-29 09:56
[Show Content]
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 @@
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="LastName" title="la_fld_LastName"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="Email" title="la_fld_Email"/>
- <inp2:m_RenderElement name="subsection" prefix="u" fields="IPAddress,IPRestrictions" title="la_section_Properties"/>
+ <inp2:m_RenderElement name="subsection" prefix="u" fields="AdminLanguage,IPAddress,IPRestrictions" title="la_section_Properties"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="u" field="AdminLanguage"/>
<inp2:m_if check="u_Field" name="IPAddress">
<inp2:m_RenderElement name="inp_label" prefix="u" field="IPAddress"/>
</inp2:m_if>
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 @@
<inp2:m_RenderElement name="inp_edit_options" prefix="u" field="Country" has_empty="1"/>
<inp2:m_RenderElement name="inp_edit_multioptions" prefix="u" field="DisplayToPublic"/>
- <inp2:m_RenderElement name="subsection" prefix="u" fields="Status,CreatedOn,Modified,IPAddress,IPRestrictions" title="la_section_Properties"/>
+ <inp2:m_RenderElement name="subsection" prefix="u" fields="Status,FrontLanguage,CreatedOn,Modified,IPAddress,IPRestrictions" title="la_section_Properties"/>
<inp2:m_RenderElement name="inp_edit_radio" prefix="u" field="Status"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="u" field="FrontLanguage"/>
<inp2:m_RenderElement name="inp_edit_date_time" prefix="u" field="CreatedOn"/>
<inp2:m_RenderElement name="inp_edit_date_time" prefix="u" field="Modified"/>
Index: install/english.lang
===================================================================
--- install/english.lang (revision 14925)
+++ install/english.lang (working copy)
@@ -302,6 +302,7 @@
<PHRASE Label="la_fld_AddressLine2" Module="Core" Type="1">QWRkcmVzcyBMaW5lIDI=</PHRASE>
<PHRASE Label="la_fld_AdminEmail" Module="Core" Type="1">TWVzc2FnZXMgZnJvbSBTaXRlIEFkbWluIGFyZSBmcm9t</PHRASE>
<PHRASE Label="la_fld_AdminInterfaceLang" Module="Core" Type="1" Column="QWRtaW4gUHJpbWFyeQ==">QWRtaW4gUHJpbWFyeQ==</PHRASE>
+ <PHRASE Label="la_fld_AdminLanguage" Module="Core" Type="1" Column="TGFuZ3VhZ2U=">TGFuZ3VhZ2U=</PHRASE>
<PHRASE Label="la_fld_AdvancedCSS" Module="Core" Type="1">QWR2YW5jZWQgQ1NT</PHRASE>
<PHRASE Label="la_fld_AdvancedSearch" Module="Core" Type="1">QWR2YW5jZWQgU2VhcmNo</PHRASE>
<PHRASE Label="la_fld_AllowChangingRecipient" Module="Core" Type="1">QWxsb3cgQ2hhbmdpbmcgIlRvIiBSZWNpcGllbnQ=</PHRASE>
@@ -423,6 +424,7 @@
<PHRASE Label="la_fld_FriendlyURL" Module="Core" Type="1">U2hvcnQgVVJM</PHRASE>
<PHRASE Label="la_fld_FromEmail" Module="Core" Type="1" Column="RnJvbSBFLW1haWw=">RnJvbSBFbWFpbA==</PHRASE>
<PHRASE Label="la_fld_FrontEndOnly" Module="Core" Type="1" Column="RnJvbnQtRW5kIE9ubHk=">RnJvbnQtRW5kIE9ubHk=</PHRASE>
+ <PHRASE Label="la_fld_FrontLanguage" Module="Core" Type="1" Column="TGFuZ3VhZ2U=">TGFuZ3VhZ2U=</PHRASE>
<PHRASE Label="la_fld_FrontRegistration" Module="Core" Type="1" Column="QWxsb3cgUmVnaXN0cmF0aW9u">QWxsb3cgUmVnaXN0cmF0aW9uIG9uIEZyb250LWVuZA==</PHRASE>
<PHRASE Label="la_fld_Group" Module="Core" Type="1" Column="R3JvdXA=">VXNlciBHcm91cA==</PHRASE>
<PHRASE Label="la_fld_GroupId" Module="Core" Type="1">SUQ=</PHRASE>
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);
+ }
}
/**
preferred_language_theme_929.patch [^] (1,790 bytes) 2011-12-29 09:56
[Show Content]
Index: _install/english.lang
===================================================================
--- _install/english.lang (revision 14942)
+++ _install/english.lang (working copy)
@@ -163,6 +163,7 @@
<PHRASE Label="lu_fld_HintTranslation" Module="Core" Type="0">SGludCBUcmFuc2xhdGlvbg==</PHRASE>
<PHRASE Label="lu_fld_Image1" Module="Core" Type="0">Mm5kIEltYWdl</PHRASE>
<PHRASE Label="lu_fld_Image2" Module="Core" Type="0">M3JkIEltYWdl</PHRASE>
+ <PHRASE Label="lu_fld_Language" Module="Core" Type="0" Column="TGFuZ3VhZ2U=">TGFuZ3VhZ2U=</PHRASE>
<PHRASE Label="lu_fld_LastName" Module="Core" Type="0">TGFzdCBuYW1l</PHRASE>
<PHRASE Label="lu_fld_module" Module="Core" Type="0">TW9kdWxl</PHRASE>
<PHRASE Label="lu_fld_MoreCategories" Module="Core" Type="0">QWRkaXRpb25hbCBDYXRlZ29yaWVz</PHRASE>
Index: platform/my_account/my_profile.tpl
===================================================================
--- platform/my_account/my_profile.tpl (revision 14902)
+++ platform/my_account/my_profile.tpl (working copy)
@@ -69,6 +69,7 @@
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="State" title="lu_fld_State" style="width:155px" />
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="Zip" title="lu_fld_Zip" style="width:55px" />
<inp2:m_RenderElement name="inp_edit_options" prefix="u" field="Country" title="lu_fld_Country" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="u" field="FrontLanguage" title="lu_fld_Language"/>
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="u" field="SubscribeToMailing" title="lu_fld_SubscribeToMailing"/>
<inp2:m_RenderElement name="inp_edit_image_upload" prefix="u" field="PrimaryImage" title="lu_prompt_Avatar" is_last="1"/>
preferred_language_core_v2.patch [^] (13,009 bytes) 2011-12-30 11:39
[Show Content]
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 @@
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="LastName" title="la_fld_LastName"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="Email" title="la_fld_Email"/>
- <inp2:m_RenderElement name="subsection" prefix="u" fields="IPAddress,IPRestrictions" title="la_section_Properties"/>
+ <inp2:m_RenderElement name="subsection" prefix="u" fields="AdminLanguage,IPAddress,IPRestrictions" title="la_section_Properties"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="u" field="AdminLanguage" has_empty="1"/>
+
<inp2:m_if check="u_Field" name="IPAddress">
<inp2:m_RenderElement name="inp_label" prefix="u" field="IPAddress"/>
</inp2:m_if>
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 @@
<inp2:m_RenderElement name="inp_edit_options" prefix="u" field="Country" has_empty="1"/>
<inp2:m_RenderElement name="inp_edit_multioptions" prefix="u" field="DisplayToPublic"/>
- <inp2:m_RenderElement name="subsection" prefix="u" fields="Status,CreatedOn,Modified,IPAddress,IPRestrictions" title="la_section_Properties"/>
+ <inp2:m_RenderElement name="subsection" prefix="u" fields="Status,FrontLanguage,CreatedOn,Modified,IPAddress,IPRestrictions" title="la_section_Properties"/>
<inp2:m_RenderElement name="inp_edit_radio" prefix="u" field="Status"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="u" field="FrontLanguage" has_empty="1"/>
<inp2:m_RenderElement name="inp_edit_date_time" prefix="u" field="CreatedOn"/>
<inp2:m_RenderElement name="inp_edit_date_time" prefix="u" field="Modified"/>
Index: install/english.lang
===================================================================
--- install/english.lang (revision 14964)
+++ install/english.lang (working copy)
@@ -306,6 +306,7 @@
<PHRASE Label="la_fld_AddressLine2" Module="Core" Type="1" Column="QWRkcmVzcyBMaW5lIDI=">QWRkcmVzcyBMaW5lIDI=</PHRASE>
<PHRASE Label="la_fld_AdminEmail" Module="Core" Type="1">TWVzc2FnZXMgZnJvbSBTaXRlIEFkbWluIGFyZSBmcm9t</PHRASE>
<PHRASE Label="la_fld_AdminInterfaceLang" Module="Core" Type="1" Column="QWRtaW4gUHJpbWFyeQ==">QWRtaW4gUHJpbWFyeQ==</PHRASE>
+ <PHRASE Label="la_fld_AdminLanguage" Module="Core" Type="1" Column="TGFuZ3VhZ2U=">TGFuZ3VhZ2U=</PHRASE>
<PHRASE Label="la_fld_AdvancedCSS" Module="Core" Type="1">QWR2YW5jZWQgQ1NT</PHRASE>
<PHRASE Label="la_fld_AdvancedSearch" Module="Core" Type="1">QWR2YW5jZWQgU2VhcmNo</PHRASE>
<PHRASE Label="la_fld_AllowChangingRecipient" Module="Core" Type="1">QWxsb3cgQ2hhbmdpbmcgIlRvIiBSZWNpcGllbnQ=</PHRASE>
@@ -428,6 +429,7 @@
<PHRASE Label="la_fld_FriendlyURL" Module="Core" Type="1">U2hvcnQgVVJM</PHRASE>
<PHRASE Label="la_fld_FromEmail" Module="Core" Type="1" Column="RnJvbSBFLW1haWw=">RnJvbSBFbWFpbA==</PHRASE>
<PHRASE Label="la_fld_FrontEndOnly" Module="Core" Type="1" Column="RnJvbnQtRW5kIE9ubHk=">RnJvbnQtRW5kIE9ubHk=</PHRASE>
+ <PHRASE Label="la_fld_FrontLanguage" Module="Core" Type="1" Column="TGFuZ3VhZ2U=">TGFuZ3VhZ2U=</PHRASE>
<PHRASE Label="la_fld_FrontRegistration" Module="Core" Type="1" Column="QWxsb3cgUmVnaXN0cmF0aW9u">QWxsb3cgUmVnaXN0cmF0aW9uIG9uIEZyb250LWVuZA==</PHRASE>
<PHRASE Label="la_fld_FullName" Module="Core" Type="1" Column="RnVsbCBOYW1l">RnVsbCBOYW1l</PHRASE>
<PHRASE Label="la_fld_Group" Module="Core" Type="1" Column="R3JvdXA=">VXNlciBHcm91cA==</PHRASE>
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);
+ }
}
/**
hide_language_fields_in_simple_interface_preset.patch [^] (1,338 bytes) 2012-01-03 11:17
[Show Content]
Index: system_presets/simple/users_u.php
===================================================================
--- system_presets/simple/users_u.php (revision 14973)
+++ system_presets/simple/users_u.php (working copy)
@@ -71,7 +71,8 @@
$hidden_fields = Array (
/* 'PortalUserId', 'Username', 'Password', 'FirstName','LastName', 'Company', 'Email', 'CreatedOn',
'Phone', 'Fax', 'Street', 'Street2', 'City', 'State' , 'Zip', 'Country', 'ResourceId', 'Status', 'EmailVerified',
- 'Modified', 'dob', 'tz',*/ 'IPAddress', /*'IsBanned', 'PwResetConfirm', 'PwRequestTime',*/ 'IPRestrictions',
+ 'Modified', 'dob', 'tz',*/ 'IPAddress', /*'IsBanned', 'PwResetConfirm', 'PwRequestTime',*/ 'FrontLanguage',
+ 'AdminLanguage', 'IPRestrictions',
);
// virtual fields to hide
@@ -83,7 +84,8 @@
$required_fields = Array (
/*'PortalUserId',*/ 'Username', /*'Password', 'FirstName', 'LastName', 'Company', */'Email', /*'CreatedOn',
'Phone', 'Fax', 'Street', 'Street2', 'City', 'State' , 'Zip', 'Country', 'ResourceId', 'Status', 'EmailVerified',
- 'Modified', 'dob', 'tz', 'IPAddress', 'IsBanned', 'PwResetConfirm', 'PwRequestTime',*/
+ 'Modified', 'dob', 'tz', 'IPAddress', 'IsBanned', 'PwResetConfirm', 'PwRequestTime', 'FrontLanguage',
+ 'AdminLanguage', 'IPRestrictions',*/
);
// virtual fields to make required
|