Hello list,

Here is a fast solution to avoid writing of "@domain" after username when your server hosted virtual domains.

With this patch is enought to write only "john" in login form instead of "john@virtualdomaintest"
If $rcmail_config['add_domain2username']  is true RoundCube will strip domain name from web addresses like: http://webmail.virtualdomaintest/ or http://www.virtualdomain.test/RoundCube/ and add it  to username.

Changes in config/main.inc.php:
===================================================================
// If this is true will use hostname to get domain name
$rcmail_config['add_domain2username'] = true;

Changes in program/include/main.inc

--- start diff ---
Index: program/include/main.inc
===================================================================
RCS file: /cvsroot/roundcubemail/roundcubemail/program/include/main.inc,v
retrieving revision 1.48
diff -u -p -r1.48 main.inc
--- program/include/main.inc    23 Mar 2006 22:32:32 -0000      1.48
+++ program/include/main.inc    11 May 2006 14:51:57 -0000
@@ -366,6 +366,19 @@ function rcmail_set_locale($lang)
   $OUTPUT->set_charset(rcube_language_prop($lang, 'charset'));
   }

+function  parse_domain($url) {
+  $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)';
+  // Followed by one or max 63 domain characters (dot separated).
+  // Must be followed by one set consisting a period of two
+  $regex = '^(' . $domain . '\.)+((' . $domain . '{1,63}\.)'.
+    $domain . '{2,63}'.
+    ')$';
+  if (ereg( $regex, strtolower($url), $regs)) {
+    return $regs[4];
+  }
+  return false;
+}
+

 // perfom login to the IMAP server and to the webmail service
 function rcmail_login($user, $pass, $host=NULL)
@@ -376,6 +389,14 @@ function rcmail_login($user, $pass, $hos
   if (!$host)
     $host = $CONFIG['default_host'];

+  // parse username for syntax like username@domain
+  $have_at = explode("@", $user);
+  if ($CONFIG['add_domain2username'] && sizeof($have_at) == 1) {
+    if ($domain = parse_domain($_SERVER[HTTP_HOST])) {
+      $user = $user . '@' . $domain; // add domain from hostname
+    }
+  }
+
   // parse $host URL
   $a_host = parse_url($host);
   if ($a_host['host'])
@@ -1586,13 +1607,18 @@ function rcmail_login_form($attrib)
 EOF;

   $OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('loginform', '$form_name');");
-
+  $domain = strtoupper (parse_domain($_SERVER[HTTP_HOST])) ;
   $out = <<<EOF
 $form_start
 $SESS_HIDDEN_FIELD
 $fields[action]
 <table><tr>

+<td class="title">Domain</td>
+<td class="title">$domain</td>
+
+</tr><tr>
+
 <td class="title">$labels[user]</td>
 <td>$fields[user]</td>

--- end of diff


--
There are no answers, only cross references