Roundcube Community Forum

Third Party Contributions => Old Style Plug-Ins => Topic started by: loganrockmore on August 23, 2007, 04:34:01 PM

Title: Domain Autocomplete
Post by: loganrockmore on August 23, 2007, 04:34:01 PM
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;
  }
}
Title: Re: Domain Autocomplete
Post by: SKaero on August 23, 2007, 06:57:29 PM
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.
Title: Re: Domain Autocomplete
Post by: banshee on December 14, 2007, 01:53:41 AM
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 :)
Title: Re: Domain Autocomplete
Post by: SKaero on December 15, 2007, 07:14:05 PM
Have you tried my solution? It doesn't have any of the js files and its built into round cube so that should work.