Author Topic: Patch for better imap_root support on multiple imap accounts  (Read 3525 times)

Offline jost_d

  • Newbie
  • *
  • Posts: 1
Patch for better imap_root support on multiple imap accounts
« on: August 13, 2008, 11:27:47 PM »
I use roundCube to connect to two imap accounts. Because one is an older UW-imap server the mail folder (imap_root) has to be specified by the client. The other server needs an empty string for the imap_root. So I cannot specify the imap_root parameter globally.

I know it could be done in a convoluted way by using vitual hosts... but I have a very simple patch to specify the imap_root in the server URL:
for example ssl://host-2:993/rootFolder

Code: [Select]

--- roundcubemail-0.2-alpha/program/include/rcmail.php.org 2008-08-10 15:14:01.000000000 -0700
+++ roundcubemail-0.2-alpha/program/include/rcmail.php 2008-08-10 11:05:09.000000000 -0700
@@ -361,6 +361,8 @@
       $host = $a_host['host'];
       $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null;
       $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $config['default_port']);
+      $imap_root = isset($a_host['path']) ? $a_host['path'] : $config['imap_root'];
+      $imap_root = ltrim($imap_root, '/ ');
     }
     else
       $imap_port = $config['default_port'];
@@ -425,6 +427,7 @@
       $_SESSION['imap_host'] = $host;
       $_SESSION['imap_port'] = $imap_port;
       $_SESSION['imap_ssl']  = $imap_ssl;
+      $_SESSION['imap_root'] = $imap_root;
       $_SESSION['password']  = $this->encrypt_passwd($pass);
       $_SESSION['login_time'] = mktime();
 
@@ -450,10 +453,8 @@
   {
     $this->imap->set_charset($this->config->get('default_charset', RCMAIL_CHARSET));
 
-    // set root dir from config
-    if ($imap_root = $this->config->get('imap_root')) {
-      $this->imap->set_rootdir($imap_root);
-    }
+    $this->imap->set_rootdir($_SESSION['imap_root']);
+
     if ($default_folders = $this->config->get('default_imap_folders')) {
       $this->imap->set_default_mailboxes($default_folders);
     }


--- roundcubemail-0.2-alpha/config/main.inc.php.dist.org 2008-08-13 19:59:15.000000000 -0700
+++ roundcubemail-0.2-alpha/config/main.inc.php.dist 2008-08-13 20:06:42.000000000 -0700
@@ -35,6 +35,10 @@
 // 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
+// To enable a choice of which imap host to connect to enter
+//  array( 'host-1' => 'friendlyName-1', 'ssl://host-2:993/rootFolder' => 'friendlyName-2')
+//  the optional 'rootFolder' argument takes precedence over the 'imap_root' parameter below.
+
 $rcmail_config['default_host'] = '';

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,385
Patch for better imap_root support on multiple imap accounts
« Reply #1 on: August 15, 2008, 07:09:29 AM »
Hi,

Please see http://trac.roundcube.net/wiki/Howto_ReportIssues for how to submit patches to RC. I think perhaps a better solution would be to allow the imap_root config to take an array, which will then match up with the default_host one.

Thanks
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and moreā€¦