Hi
I did a small index page for my website, with links to RC for several users.
I'd like username to be prefilled using a carrystring value
ex : http://mywebsite/mail/?username=foo
where foo is a valid user.
My browser will fill the password value by itself.
is anyone can help me ?
Thanx.
Regards.
PS : i tried to add :
$_user = $_GET['username'];
at the top of RC index.php but it doesn't work :(
Hi,
Look for this in program/include/rcube_template.php (about line 869 in v0.2a, i think)
$input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser', 'size' => 30, 'autocomplete' => 'off'));
and then change it to:
$input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser', 'size' => 30, 'autocomplete' => 'off', 'value' => $_GET['username']));
this should set the default value for the username field to the value of the username parameter in the URL.
ouch.
thx for your help but doesn't work ... :(
I leave the _GET at the beginning of index.php
value of username doesn't seem to be kept from index to other files (include files)
ok, try this....
Forget what i said before, the value is set later (I didnt have a chance to actually try the code before but I have now). Still in program/include/rcube_template.php look for:
$table->add(null, $input_user->show(get_input_value('_user', RCUVE_INPUT_POST)));
This line sets the value of the username field to what you just entered when you get the password wrong so I would guess you want to keep it but we can alter it to pick up the username from the URL as well.... replace the line with this:
$post_user = get_input_value('_user', RCUVE_INPUT_POST);
if (!empty($post_user))
$table->add(null, $input_user->show($post_user));
else
$table->add(null, $input_user->show($_GET['_user']));
You can't read the value from the URL into a variable at the top of index.php and then read that variable from within the login_form function as it will be out of scope.
I tested this on the latest SVN, not 0.2a but it should work just the same.
almost perfect !
value is correctly filled at the good place ! well done :)
... but next field (password) is already activated and so my browser (firefox) doesn't filled it automatically with the recorded password.
It's better than to have to fill username AND password, I now just have to click on the filled username and re-click on the password field and the browser does its job...
ok that works !
I change autocomplete from off to on right here :
$input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser', 'size' => 30, 'autocomplete' => 'on'));
:)