Roundcube 0.8.5 login mod for ISPconfig
I've made a little mod for roundcube, that would be very useful on ispconfig servers.. My original post: http://www.arty.lv/?p=24
Many of virtual hosting providers are using Roundcube webmail, but it lacks one very useful feature for multiple domains on single server – automatic domain completion in login form. Every user needs to use full e-mail address as login name, and this is very annoying for long domain names… So here is my solution:
1: ) Apache configuration.
I’m assuming you are using alias for every domain to access one single webmail (in case you are not, this patch does not make any use). This is how Apache virtual host should look like:
ServerAlias mail.domain1.lv mail.domain2.lv mail.*.*
This means every user can access his webmail on “mail” subdomain.
2: ) Setting up roundcube.
I will not go through the Roundcube webmail setup steps. You can find it here: http://trac.roundcube.net/wiki/Howto_Install
Just make sure, there is only one imap host defined in main.inc.php (can be other than localhost) or else there is a better way to map domain to username:
$rcmail_config['default_host'] = 'localhost';
3: ) Roundcube Modifications.
First we need to add a new field to login form for domain. Edit file ./program/include/rcube_template.php. Add folowing line inside “private function loginform($attrib)” function. I placed it between “$input_user = …” and “$input_pass = … ” to maintain the correct order according to login form.
$input_domain = new html_inputfield(array('name' => '_domain', 'id' => 'username_domain') + $attrib);
Next, add folowing lines between “ $table->add(‘input’, $input_user->show(get_input_value(‘_user’, RCUBE_INPUT_GPC)));” and “$table->add(‘title’, html::label(‘rcmloginpwd’, Q(rcube_label(‘password’))));” lines:
$hostStr = $_SERVER['HTTP_HOST'];
$wPos = strPos($hostStr, '.')+1;
$input_domain = new html_inputfield(array('name' => '_domain', 'id' => 'rcmlogindomain', 'value' => substr($hostStr,$wPos))
+ $attrib + $host_attrib);
$table->add('title', html::label('rcmloginuser', Q(rcube_label('atsymbol'))));
$table->add('input', $input_domain->show(get_input_value('_domain', RCUBE_INPUT_GPC)));
Next, add folowing line to your default localization file. In my case its ./program/localization/en_US/labels.inc:
$labels['atsymbol'] = '@';
Save file, and check out your new login page it should look like this:
loginscreenWith automatically filled domain field for every domain (http://mail.domain1.com will show “domain1.com”, http://mail.domain2.com will show “domain2.com” etc.).
Ok, one more thing to do – we need to make roundcube to get this variable and add it to username. Edit file “./index.php” – add folowing between “ ’user’ => trim(get_input_value(‘_user’, RCUBE_INPUT_POST)),” and “‘pass’ => get_input_value(‘_pass’, RCUBE_INPUT_POST, true,” lines:
'username_domain' => trim(get_input_value('_domain', RCUBE_INPUT_POST)),
Next add folowing right before “// Login” line:
$loginvards = $auth['user'];
$loginvards = $auth['user'] . "@" . $auth['username_domain'];
Final thing – replace folowing line “$RCMAIL->login($auth[user], $auth['pass'], $auth['host'], $auth['cookiecheck'])” with this one:
$RCMAIL->login($loginvards, $auth['pass'], $auth['host'], $auth['cookiecheck'])
4: ) Enjoy!
Now every user should be able to log in with his username only, when accessing webmail on his subdomain. You can also manually modify this field and type in a different domain or even leave it blank and log in using full e-mail address as username!
Please feel free to leave any comments or suggestions, and keep in mind, that I’m not a php programmer, so there could be some other (or better) way to achieve this.
I wouldn't recommend to do this your way. Roundcube can easily be modified with plugins in pretty much everyway. So modifing the source code of roundcube itself is a no go.
I would recommend you to create domain specific files, which roundcube can handle or to use the roundcube user autocompletion.
|All times are GMT +2. The time now is 22:17.|
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.