Hi
I've already proposed this patch (in April), but you'd asked me to update it
for current release.
http://209.85.129.104/search?q=cache:HCto6VkAqNIJ:www.roundcubeforum.net/ind
ex.php%3Ftopic%3D122.msg2162+round+cube+simplerezo&hl=fr&gl=fr&ct=clnk&cd=1
So here the patch for the current SVN version:
--- index.php.old Tue Oct 17 17:18:46 2006
+++ index.php Tue Oct 17 17:19:28 2006
@@ -166,6 +166,23 @@
if ($_action=='login' && $_task=='mail')
{
$host = $_POST['_host'] ? $_POST['_host'] : $CONFIG['default_host'];
+
+ // auto host
+ if (is_array($host) && is_array(reset($host)))
+ {
+ if (isset($_POST['_user']))
+ {
+ $tmp = split('@', $_POST['_user']);
+ if (sizeof($tmp) > 1)
+ foreach ($host as $cur_host => $domains)
+ if (in_array($tmp[1], $domains))
+ {
+ $host_ok = $cur_host;
+ break;;
+ }
+ $host = isset($host_ok) ? $host_ok : '';
+ }
+ }
// check if client supports cookies
if (empty($_COOKIE))
--- config/main.inc.php.dist.old Tue Oct 17 17:20:09 2006
+++ config/main.inc.php.dist Tue Oct 17 17:21:39 2006
@@ -35,6 +35,12 @@
// leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL connection, enter ssl://hostname:993
+// auto-selection of host depending on domain specified can
+// be enabled using a value like this:
+// $rcmail_config['default_host'] = array(
+// 'mail.server.com' = array('domaine1.com', 'domaine2.net'),
+// 'mail.server2.com' = array('my.otherdomain.net'),
+// 'host.hosting.com' = array('a.net', 'b.org', 'c.com'));
$rcmail_config['default_host'] = '';
// TCP port used for IMAP connections
--- program/include/main.inc.old Tue Oct 17 17:22:14 2006
+++ program/include/main.inc Tue Oct 17 17:23:10 2006
@@ -1717,10 +1717,13 @@
{
$select_host = new select(array('name' => '_host', 'id' =>
'rcmloginhost'));
- foreach ($CONFIG['default_host'] as $key => $value)
- $select_host->add($value, (is_numeric($key) ? $value : $key));
+ if (!(is_array($CONFIG['default_host']) &&
is_array(reset($CONFIG['default_host']))))
+ {
+ foreach ($CONFIG['default_host'] as $key => $value)
+ $select_host->add($value, (is_numeric($key) ? $value : $key));
- $fields['host'] = $select_host->show($_POST['_host']);
+ $fields['host'] = $select_host->show($_POST['_host']);
+ }
}
else if (!strlen($CONFIG['default_host']))
{
I quote myself:
[ Note: you can use in main.inc.php something like:
$rcmail_config['default_host'] = include('mystuff.inc.php');
And in mystuff.inc.php doing whatever you like for building and returning
the associative arrays (retrieving informations from a database for an
example, like we do). Just be aware that this file is called for every HTTP
request (so if you are using database as I said, it could have some
performance issues....). ]
I hope this will be committed soon.
--
Clement Moulin
SimpleRezo