[dev] Problem with nls on IMP login form

Etienne Goyer etienne.goyer at linuxquebec.com
Tue Sep 9 12:25:48 PDT 2003


Hi,

I noticed a problem with a patch I sent and discussed recently on the
general Horde list.  Sorry if this is confusing, but I prefer to bring
discussion on this issue on the dev list instead, where it is much more
appropriate IMHO.

So basically, the patch I sent modified the way language was chosen
under some circumstance; for example, the login page of IMP would
display in the $nls['defaults']['language'] instead of being negociated
with the browser.  Jan Schneider commited the patch on September 3rd.

I noticed a problem with the behavior of the login form when this
modification is in effect.  If user choose a different language from the
drop-down menu and enter invalid credentials, the error ($reason) and
the login form is displayed in the site-wide default language.  I
believe the error and login form should be displayed in the language the
user previously select.

Here is included two trivial patches that make it behave the way I 
believe is correct.  However, this will have to be checked before 
applying because I am not quite sure the trick I used (relaying the 
"new_lang" parameter) is correct and acceptable.  

Also, there is still a problem with these patches.  If user :

1. Choose a language from the drop-down menu
2. Open a session successfully
3. Logout from that session

The login form displayed is in two language.  The $reason is in the
user-chosen language while the rest of the form is in the site-wide
default.  I think it is related to line 56 of imp/login.php.  There,
$language would need to be setted to the language the session was opened
with, but I don't know how to retrieve it from there.  I have been
banging my head on it for a few hours now and I am quite a bit confused.
I am sure somebody on this list know better than I do, so it's time for
me to stop being stubborn and seek some help ... :)

Thanks for your feedback !

-- 
Etienne Goyer                    Linux Québec Technologies Inc.
http://www.LinuxQuebec.com       etienne.goyer at linuxquebec.com
-------------- next part --------------
--- imp/lib/IMP.php.orig	Tue Sep  9 11:37:34 2003
+++ imp/lib/IMP.php	Tue Sep  9 11:38:58 2003
@@ -686,6 +686,7 @@
                                                                Horde::getFormData('folders'),
             'language' => isset($_SESSION['imp']['language']) ? $_SESSION['imp']['language'] :
                                                                 Horde::getFormData('language'),
+            'new_lang' => Horde::getFormData('new_lang'),
             'reason'   => $reason
         );
 
-------------- next part --------------
--- imp/templates/login/login.inc.orig	Mon Sep  8 15:28:01 2003
+++ imp/templates/login/login.inc	Tue Sep  9 15:01:05 2003
@@ -36,10 +36,14 @@
 
 /* Build the <select> widget containing the available languages. */
 if (!$prefs->isLocked('language')) {
-    $_SESSION['horde_language'] = NLS::select();
+    if (($horde_language = Horde::getFormData('new_lang'))) {
+        $cur_new_lang = $_SESSION['horde_language'] = $horde_language;
+    } else {
+        $cur_new_lang = $_SESSION['horde_language'] = NLS::select();
+    }
     $langs = '<select name="new_lang" onchange="selectLang()">';
     foreach ($nls['languages'] as $key => $val) {
-        $sel = ($key == $_SESSION['horde_language']) ? ' selected="selected"' : '';
+        $sel = ($key == $cur_new_lang) ? ' selected="selected"' : '';
         $langs .= "<option value=\"$key\"$sel>$val</option>";
     }
     $langs .= '</select>';


More information about the dev mailing list