Fix language change on login screen
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 20 Dec 2010 17:18:17 +0000 (10:18 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 20 Dec 2010 17:26:50 +0000 (10:26 -0700)
horde/login.php

index 1fa2918..267deb3 100644 (file)
@@ -70,33 +70,6 @@ if (!$is_auth) {
 /* Get an Auth object. */
 $auth = $injector->getInstance('Horde_Core_Factory_Auth')->create(($is_auth && $vars->app) ? $vars->app : null);
 
-/* Build the list of necessary login parameters. */
-$loginparams = array(
-    'horde_user' => array(
-        'label' => _("Username"),
-        'type' => 'text',
-        'value' => $vars->horde_user
-    ),
-    'horde_pass' => array(
-        'label' => _("Password"),
-        'type' => 'password'
-    )
-);
-$js_code = array(
-    'HordeLogin.user_error' => _("Please enter a username."),
-    'HordeLogin.pass_error' => _("Please enter a password.")
-);
-$js_files = array(
-    array('login.js', 'horde')
-);
-
-try {
-    $result = $auth->getLoginParams();
-    $loginparams = array_filter(array_merge($loginparams, $result['params']));
-    $js_code = array_merge($js_code, $result['js_code']);
-    $js_files = array_merge($js_files, $result['js_files']);
-} catch (Horde_Exception $e) {}
-
 /* Get URL/Anchor strings now. */
 if ($vars->url) {
     $url_in = new Horde_Url($vars->url);
@@ -161,9 +134,13 @@ if ($logout_reason) {
     $auth_params = array(
         'password' => Horde_Util::getPost('horde_pass')
     );
-    foreach (array_diff(array_keys($loginparams), array('horde_user', 'horde_pass')) as $val) {
-        $auth_params[$val] = Horde_Util::getPost($val);
-    }
+
+    try {
+        $result = $auth->getLoginParams();
+        foreach ($result['params'] as $val) {
+            $auth_params[$val] = Horde_Util::getPost($val);
+        }
+    } catch (Horde_Exception $e) {}
 
     if ($vars->ie_version) {
         $browser->setIEVersion($vars->ie_version);
@@ -201,13 +178,38 @@ if ($logout_reason) {
     $entry = sprintf('FAILED LOGIN for %s [%s] to Horde',
                      $vars->horde_user, $_SERVER['REMOTE_ADDR']);
     Horde::logMessage($entry, 'ERR');
-} else {
-    $new_lang = Horde_Util::getGet('new_lang');
-    if ($new_lang) {
-        $registry->setLanguageEnvironment($new_lang);
-    }
+} elseif ($new_lang = Horde_Util::getGet('new_lang')) {
+    $registry->setLanguageEnvironment($new_lang);
 }
 
+/* Build the list of necessary login parameters.
+ * Need to wait until after we set language to get login parameters. */
+$loginparams = array(
+    'horde_user' => array(
+        'label' => _("Username"),
+        'type' => 'text',
+        'value' => $vars->horde_user
+    ),
+    'horde_pass' => array(
+        'label' => _("Password"),
+        'type' => 'password'
+    )
+);
+$js_code = array(
+    'HordeLogin.user_error' => _("Please enter a username."),
+    'HordeLogin.pass_error' => _("Please enter a password.")
+);
+$js_files = array(
+    array('login.js', 'horde')
+);
+
+try {
+    $result = $auth->getLoginParams();
+    $loginparams = array_filter(array_merge($loginparams, $result['params']));
+    $js_code = array_merge($js_code, $result['js_code']);
+    $js_files = array_merge($js_files, $result['js_files']);
+} catch (Horde_Exception $e) {}
+
 /* If we currently are authenticated, and are not trying to authenticate to
  * an application, redirect to initial page. This is done in index.php.
  * If we are trying to authenticate to an application, but don't have to,