Roundcube Community Forum

 

login page rcmloginhost helper if user enters full email address patch

Started by redax, July 02, 2016, 04:57:51 AM

Previous topic - Next topic

redax

Hi

just made a small patch for our university webmail, maybe it is helpful for others, please revise and do whatever, could be good if this or similar feature would be in roundcube.
the patch is against program/include/rcmail_output_html.php

best regards,
Redax


--- rcmail_output_html.php-orig 2016-05-22 13:06:46.000000000 +0200
+++ rcmail_output_html.php      2016-07-01 14:49:11.313145058 +0200
@@ -1868,6 +1868,33 @@

         // include script for timezone detection
         $this->include_script('jstz.min.js');
+
+       $_hosts="";
+       $_hn=0;
+       foreach ($this->config->get("mail_domain") as $key => $value) {
+               if( $_hn++ > 0 ) $_hosts.=",\n";
+               $_hosts.="\"$value\":\"$key\"";
+       }
+
+       $this->add_script('
+$( document ).ready(function() {
+$("#rcmloginuser").focusout(function(){
+  var email  = $("#rcmloginuser").val();
+  var name   = email.substring(0, email.lastIndexOf("@"));
+  var domain = email.substring(email.lastIndexOf("@") +1);
+  var hosts = {'.$_hosts.'};
+  var v="";
+
+  if( email.indexOf("@") > -1 ) {
+       v=hosts[domain];
+       if( v && v.length > 0 ) {
+               $("#rcmloginhost").val(v);
+               $("#rcmloginuser").val(name);
+       }
+  }
+  });
+});
+');

         return $out;
     }

SKaero

This could be done with a plugin which would also be upgrade safe.