From 230f944bf62f141f47c021dbfe6cc3d07b74a76d Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Wed, 24 Dec 2008 09:29:47 -0500
Subject: [PATCH] Allow empty strings for imap_root config parameter (was changed in r2143) to remain backward compatible but cache imap root and delimiter in session

---
 program/include/rcube_imap.php |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index e16651a..401bc8f 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -66,6 +66,7 @@
   var $search_sort_field = '';  
   var $debug_level = 1;
   var $error_code = 0;
+  var $options = array('imap' => 'check');
 
 
   /**
@@ -90,7 +91,7 @@
    * @return boolean  TRUE on success, FALSE on failure
    * @access public
    */
-  function connect($host, $user, $pass, $port=143, $use_ssl=null, $auth_type=null)
+  function connect($host, $user, $pass, $port=143, $use_ssl=null)
     {
     global $ICL_SSL, $ICL_PORT, $IMAP_USE_INTERNAL_DATE;
     
@@ -107,17 +108,7 @@
     $ICL_PORT = $port;
     $IMAP_USE_INTERNAL_DATE = false;
 
-    // set connection options
-    $options['imap'] = $auth_type ? $auth_type : 'check';
-
-    // Setting root and delimiter before iil_Connect can save time detecting them
-    // using NAMESPACE and LIST 
-    if (is_string($imap_root = rcmail::get_instance()->config->get('imap_root'))) 
-        $options['rootdir'] = $imap_root;
-    if($imap_delimiter = rcmail::get_instance()->config->get('imap_delimiter'))
-        $options['delimiter'] = $imap_delimiter;
-
-    $this->conn = iil_Connect($host, $user, $pass, $options);
+    $this->conn = iil_Connect($host, $user, $pass, $this->options);
     $this->host = $host;
     $this->user = $user;
     $this->pass = $pass;
@@ -182,6 +173,13 @@
       iil_C_Select($this->conn, $this->mailbox);
     }
 
+  /**
+   * Set options to be used in iil_Connect()
+   */
+  function set_options($opt)
+  {
+    $this->options = array_merge((array)$opt, $this->options);
+  }
 
   /**
    * Set a root folder for the IMAP connection.
@@ -198,6 +196,7 @@
       $root = substr($root, 0, -1);
 
     $this->root_dir = $root;
+    $this->options['rootdir'] = $root;
     
     if (empty($this->delimiter))
       $this->get_hierarchy_delimiter();

--
Gitblit v1.9.1