From 060311ab7dacc6221b00bcf5b71f0693bb1724c4 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 23 Sep 2003 21:26:58 +0000 Subject: [PATCH] fixed prob with login-scree-message and no cookie --- login.php | 24 +++++++++------------- phpgwapi/inc/class.translation_sql.inc.php | 5 +++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/login.php b/login.php index bd3ae0a1b8..a72dcfb13c 100755 --- a/login.php +++ b/login.php @@ -254,29 +254,25 @@ $accounts = CreateObject('phpgwapi.accounts'); $prefs = CreateObject('phpgwapi.preferences', $accounts->name2id($_COOKIE['last_loginid'])); - if (! $prefs->account_id) - { - // Default to the first language, the users browser accepts. - list($lang) = explode(',',$_SERVER["HTTP_ACCEPT_LANGUAGE"]); - $lang = substr($lang,0,2); - if(strlen($lang) != 2) $lang="en"; - $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $lang; - } - else + if ($prefs->account_id) { $GLOBALS['phpgw_info']['user']['preferences'] = $prefs->read_repository(); } - #print 'LANG:' . $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] . '
'; } - else + if (!isset($_COOKIE['last_loginid']) || !$prefs->account_id) { // If the lastloginid cookies isn't set, we will default to the first language, // the users browser accepts. - list($lang) = explode(',',$_SERVER["HTTP_ACCEPT_LANGUAGE"]); - $lang = substr($lang,0,2); - if(strlen($lang) != 2) $lang="en"; + list($lang) = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); + if (strlen($lang) > 2) + { + $lang = substr($lang,0,2); + } $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $lang; } + #print 'LANG:' . $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] . '
'; + + $GLOBALS['phpgw']->translation->init(); // this will set the language according to the (new) set prefs $GLOBALS['phpgw']->translation->add_app('login'); $GLOBALS['phpgw']->translation->add_app('loginscreen'); if (lang('loginscreen_message') == 'loginscreen_message*') diff --git a/phpgwapi/inc/class.translation_sql.inc.php b/phpgwapi/inc/class.translation_sql.inc.php index ae80715c2e..e4f5bf5e74 100644 --- a/phpgwapi/inc/class.translation_sql.inc.php +++ b/phpgwapi/inc/class.translation_sql.inc.php @@ -48,6 +48,11 @@ $this->userlang = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang']; } $this->add_app('common'); + if (!count($GLOBALS['lang'])) + { + $this->userlang = 'en'; + $this->add_app('common'); + } $this->add_app($GLOBALS['phpgw_info']['flags']['currentapp']); }