Author Topic: Domain Autocomplete  (Read 7889 times)

Offline loganrockmore

  • Newbie
  • *
  • Posts: 1
Domain Autocomplete
« 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 "user@domain.com", 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:

Quote
Open program/include/main.inc. On line 1446, replace

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

Code: [Select]
$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

Code: [Select]
$this->include_script('app.js');
add the line

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

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

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: Domain Autocomplete
« Reply #1 on: August 23, 2007, 06:57:29 PM »
Or... you could just go in to config/main.inc.php and edit this to:
Code: [Select]
$rcmail_config['username_domain'] = 'domain.com';That would work to.

Offline banshee

  • Newbie
  • *
  • Posts: 2
Re: Domain Autocomplete
« Reply #2 on: December 14, 2007, 01:53:41 AM »
How to change «@» on «+» in address autocomplete? Our provider maked logins for email such: e-mail: test@domain.com, but login: test+domain.com and domain.com+test. I need solutuion for two my examples. Help, please :)

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: Domain Autocomplete
« Reply #3 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.