Roundcube Community Forum

 

Domain Autocomplete

Started by loganrockmore, August 23, 2007, 04:34:01 PM

Previous topic - Next topic

loganrockmore

I've created a small plug-in that will auto-complete the email address with the domain name when logging in. So, instead of typing "[email protected]", you can just type "user" and when the username field loses focus, the "@domain.com" will automatically be added.

I've put the instructions on my blog at http://www.loganrockmore.com/blog/?p=120 and I'll repeat them here:

QuoteOpen program/include/main.inc. On line 1446, replace

$input_user = new textfield(array('name' => '_user', 'id' => 'rcmloginuser', 'size' => 30, 'autocomplete' => 'off'));
with the two lines

$domain = preg_replace("/^www\./", "", $_SERVER['HTTP_HOST']);
$input_user = new textfield(array('name' => '_user', 'id' => 'rcmloginuser', 'size' => 30, 'autocomplete' => 'off', 'onchange' => 'domainautocomplete(\'' . $domain . '\');'));

(Note: if your Roundcube installation is located somewhere like webmail.domain.com, then change “www” in the first line to “webmail”. Basically, that line just gets rid of the first part of the domain, so you’re left with “domain.com” )

Open program/include/rcmail_template.inc. On line 60, after

$this->include_script('app.js');
add the line

$this->include_script('domainautocomplete.js');
Finally, in the directory program/js/ create a new file titled domainautocomplete.js and add this content

function domainautocomplete(domain) {
 
  var loginField = document.getElementById('rcmloginuser');
 
  if( loginField.value != '' &&
    loginField.value.indexOf('@') == -1 ) {
   
    loginField.value = loginField.value + "@" + domain;
  }
}

SKaero

Or... you could just go in to config/main.inc.php and edit this to:
$rcmail_config['username_domain'] = 'domain.com';That would work to.

banshee

How to change «@» on «+» in address autocomplete? Our provider maked logins for email such: e-mail: [email protected], but login: test+domain.com and domain.com+test. I need solutuion for two my examples. Help, please :)

SKaero

Have you tried my solution? It doesn't have any of the js files and its built into round cube so that should work.