Index: core/kernel/languages/phrases_cache.php =================================================================== RCS file: /www/cvs/kernel4_dev/kernel4/languages/phrases_cache.php,v retrieving revision 1.19.2.6 diff -u -r1.19.2.6 phrases_cache.php --- core/kernel/languages/phrases_cache.php 24 Sep 2009 14:52:36 -0000 1.19.2.6 +++ core/kernel/languages/phrases_cache.php 5 Oct 2009 12:24:53 -0000 @@ -109,12 +109,17 @@ } 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); + $language_id = $this->Application->Session->GetField('Language'); + + if (!$language_id) { + // when admin is not logged in + $sql = 'SELECT ' . $this->Application->getUnitOption('lang', 'IDField') . ' + FROM ' . $this->Application->getUnitOption('lang', 'TableName') . ' + WHERE AdminInterfaceLang = 1'; + $language_id = $this->Conn->GetOne($sql); + } + + $this->LanguageId = $language_id; } else { $this->LanguageId = $this->Application->GetVar('m_lang'); Index: core/units/users/users_event_handler.php =================================================================== RCS file: /www/cvs/kernel.X/core/units/users/users_event_handler.php,v retrieving revision 1.87.2.33 diff -u -r1.87.2.33 users_event_handler.php --- core/units/users/users_event_handler.php 24 Sep 2009 14:53:24 -0000 1.87.2.33 +++ core/units/users/users_event_handler.php 5 Oct 2009 12:48:04 -0000 @@ -248,6 +248,8 @@ $this->Application->SetVar('u.current_id', $user_id); $this->Application->StoreVar('user_id', $user_id); + $this->Application->LoadPersistentVars(); + if ($super_admin) { $this->Application->StoreVar('super_admin', 1); } Index: custom/admin_templates/incs/in-portal.tpl =================================================================== RCS file: /www/cvs/intexsys/custom/admin_templates/incs/Attic/in-portal.tpl,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 in-portal.tpl --- custom/admin_templates/incs/in-portal.tpl 25 Sep 2009 11:11:46 -0000 1.1.2.1 +++ custom/admin_templates/incs/in-portal.tpl 5 Oct 2009 12:31:49 -0000 @@ -6,4 +6,45 @@ id="_" value="" onclick="update_checkbox_options(/^_([0-9A-Za-z-]+)/, '');"> 
+
+ + + + + + + + + + + + + + +
+ : + +
+ + + + + + onchange="update_checkbox(this, document.getElementById(''));" /> + + +
+ *  +
+ + + + *  + +
\ No newline at end of file Index: custom/install/install_schema.sql =================================================================== RCS file: /www/cvs/intexsys/custom/install/install_schema.sql,v retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1.2.1 install_schema.sql --- custom/install/install_schema.sql 25 Sep 2009 11:11:42 -0000 1.1.1.1.2.1 +++ custom/install/install_schema.sql 5 Oct 2009 13:15:06 -0000 @@ -40,3 +40,7 @@ # ===== SQLs above this line already on DEV ======================================================================================================== # place here only sql queries, that were executed on prod server !!! + +ALTER TABLE `int_PortalUser` + ADD `AdminLanguage` INT(11) NULL DEFAULT NULL, + ADD INDEX (`AdminLanguage`); \ No newline at end of file Index: custom/units/sections/e_user_eh.php =================================================================== RCS file: /www/cvs/intexsys/custom/units/sections/e_user_eh.php,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 e_user_eh.php --- custom/units/sections/e_user_eh.php 24 Sep 2009 15:23:23 -0000 1.1.1.1 +++ custom/units/sections/e_user_eh.php 5 Oct 2009 13:24:40 -0000 @@ -9,43 +9,6 @@ class EUserEventHandler extends UsersEventHandler { /** - * Allows to override standart permission mapping - * - */ - function mapPermissions() - { - parent::mapPermissions(); - - $permissions = Array ( - # admin - 'OnCustomEvent1' => Array ('self' => true), - - # front - 'OnCustomEvent2' => Array ('self' => true), - ); - - $this->permMapping = array_merge($this->permMapping, $permissions); - } - - /** - * Permission exceptions - * - * @param kEvent $event - */ - function CheckPermission(&$event) - { - $skip_permissions_check_events = Array ( - 'OnAnotherCustomEvent', - ); - - if ( in_array($event->Name, $skip_permissions_check_events) ) { - return true; - } - - return parent::CheckPermission($event); - } - - /** * Updates structure config * * @param kEvent $event @@ -56,133 +19,56 @@ # 1. Regular Fields from /core/units/users/users_config.php $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); #get regular fields -// $fields['Status']['default'] = 1; #add/edit configuration (make default = 1) + $fields['AdminLanguage'] = Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language ORDER BY PackName', 'option_key_field' => 'LanguageId', 'option_title_field' => 'LocalName', + 'default' => NULL + ); $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); #save regular fields - - # 2. Virtual Fields from /core/units/users/users_config.php - $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields'); #get virtual fields -// $virtual_fields['FullName']['default'] = ''; #add/edit configuration - $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields); #save virtual fields } /** - * Sets custom query for the list + * Checks user data and logs it in if allowed * - * @param kEvent $event - */ - function SetCustomQuery(&$event) - { - parent::SetCustomQuery($event); - - $object =& $event->getObject(); - /* @var $object kDBList */ - - # identifying event based on special and setting filter - if ( $event->Special == 'custom-special' ) { -// $object->addFilter('primary_filter', '%1$s.Status = ' . STATUS_DISABLED); - } - - # identifying event based not admin condition and setting filter - if ( !$this->Application->IsAdmin() ) { -// $object->addFilter('status_filter', '%1$s.Status = ' . STATUS_ACTIVE); - } - } - - /** - * Before new item created - * - * @param kEvent $event - */ - function OnBeforeItemCreate(&$event) - { - parent::OnBeforeItemCreate($event); - - - } - - /** - * Before existing item updated + * OnLogin is called from u:autoLoginUser and password is supplied + * OnLogin is called from u:OnAutoLoginUser supplying cookie with encoded username & password * * @param kEvent $event */ - function OnBeforeItemUpdate(&$event) + function OnLogin(&$event) { - parent::OnBeforeItemUpdate($event); + parent::OnLogin($event); + if ($event->status != erSUCCESS || !$this->Application->IsAdmin()) { + return ; + } - } - - /** - * Before item deleted - * - * @param kEvent $event - */ - function OnBeforeItemDelete(&$event) - { - parent::OnBeforeItemDelete($event); - - - } - - /** - * After item loaded - * - * @param kEvent $event - */ - function OnBeforeItemLoad(&$event) - { - parent::OnBeforeItemLoad($event); - - - } - - - /** - * After new item created - * - * @param kEvent $event - */ - function OnAfterItemCreate(&$event) - { - parent::OnAfterItemCreate($event); - - - } - - /** - * After existing item updated - * - * @param kEvent $event - */ - function OnAfterItemUpdate(&$event) - { - parent::OnAfterItemUpdate($event); - - - } - - /** - * After item deleted - * - * @param kEvent $event - */ - function OnAfterItemDelete(&$event) - { - parent::OnAfterItemDelete($event); - + $is_root = $this->Application->RecallVar('user_id') == -1; - } + $object =& $this->Application->recallObject('u.current'); + /* @var $object kDBItem */ - /** - * After item loaded - * - * @param kEvent $event - */ - function OnAfterItemLoad(&$event) - { - parent::OnAfterItemLoad($event); + $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(); + } + } + $this->Application->Session->SetField('Language', $language_id); } - } \ No newline at end of file Index: custom/units/sections/sections_config.php =================================================================== RCS file: /www/cvs/intexsys/custom/units/sections/sections_config.php,v retrieving revision 1.1.1.1.2.2 diff -u -r1.1.1.1.2.2 sections_config.php --- custom/units/sections/sections_config.php 25 Sep 2009 11:28:14 -0000 1.1.1.1.2.2 +++ custom/units/sections/sections_config.php 5 Oct 2009 12:45:49 -0000 @@ -33,6 +33,11 @@ Array ('pseudo' => 'formsubs_EventHandler', 'class' => 'EFormSubmissionEventHandler', 'file' => 'e_form_submission_eh.php'), Array ('pseudo' => 'formsubs_TagProcessor', 'class' => 'EFormSubmissionTagProcessor', 'file' => 'e_form_submission_tp.php'), + + Array ('pseudo' => 'lang_EventHandler', 'class' => 'ELanguageEventHandler', 'file' => 'e_language_eh.php'), + Array ('pseudo' => 'lang_TagProcessor', 'class' => 'ELanguageTagProcessor', 'file' => 'e_language_tp.php'), + + Array ('pseudo' => 'u_EventHandler', 'class' => 'EUserEventHandler', 'file' => 'e_user_eh.php'), ), # Replace/substiture any admin default templates with custom ones --- e_language_eh.php +++ e_language_eh.php @@ -0,0 +1,30 @@ +Application->IsAdmin()) { + // language changing on Front-End stays without changes + parent::OnChangeLanguage($event); + } + + // set new language for this session + $language_id = $this->Application->GetVar('language'); + $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(); + } + + $this->Application->SetVar('skip_last_template', 1); + } + } --- e_language_tp.php +++ e_language_tp.php @@ -0,0 +1,16 @@ +getObject($params); + + return $object->GetDBField('LanguageId') == $this->Application->Phrases->LanguageId; + } + }