summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UPGRADING2
-rw-r--r--config/main.inc.php.dist3
-rw-r--r--program/include/rcmail.php22
-rw-r--r--program/include/rcube_imap.php23
4 files changed, 32 insertions, 18 deletions
diff --git a/UPGRADING b/UPGRADING
index 45130c9ff..b2c1977b2 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -18,8 +18,6 @@ of RoundCube Webmail.
open http://url-to-roundcube/installer/ in a browser. To enable
the latter one, you have to temporary set 'enable_installer' to true
in your local config/main.inc.php file.
- WARNING: If you don't know what an "IMAP root directory" is,
- set the imap_root option to NULL
3. Let the update script/installer check your configuration and
update your config files as suggested by the updater.
4. If suggested by the update script, run all commands in
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index fff301751..3ea62e115 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -62,8 +62,7 @@ $rcmail_config['default_port'] = 143;
$rcmail_config['imap_auth_type'] = null;
// If you know your imap's root directory and its folder delimiter,
-// you can specify them here. Otherwise they will be determined
-// during every imap connection.
+// you can specify them here. Otherwise they will be determined automatically.
$rcmail_config['imap_root'] = null;
$rcmail_config['imap_delimiter'] = null;
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index c7f26d96d..fcd39502b 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -352,6 +352,20 @@ class rcmail
// set pagesize from config
$this->imap->set_pagesize($this->config->get('pagesize', 50));
+
+ // Setting root and delimiter before iil_Connect can save time detecting them
+ // using NAMESPACE and LIST
+ $options = array(
+ 'imap' => $this->config->get('imap_auth_type', 'check'),
+ 'delimiter' => isset($_SESSION['imap_delimiter']) ? $_SESSION['imap_delimiter'] : $this->config->get('imap_delimiter'),
+ );
+
+ if (isset($_SESSION['imap_root']))
+ $options['rootdir'] = $_SESSION['imap_root'];
+ else if ($imap_root = $this->config->get('imap_root'))
+ $options['rootdir'] = $imap_root;
+
+ $this->imap->set_options($options);
// set global object for backward compatibility
$GLOBALS['IMAP'] = $this->imap;
@@ -371,7 +385,7 @@ class rcmail
$conn = false;
if ($_SESSION['imap_host'] && !$this->imap->conn) {
- if (!($conn = $this->imap->connect($_SESSION['imap_host'], $_SESSION['username'], $this->decrypt_passwd($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl'], rcmail::get_instance()->config->get('imap_auth_type', 'check')))) {
+ if (!($conn = $this->imap->connect($_SESSION['imap_host'], $_SESSION['username'], $this->decrypt_passwd($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl']))) {
if ($this->output)
$this->output->show_message($this->imap->error_code == -1 ? 'imaperror' : 'sessionerror', 'error');
}
@@ -452,7 +466,7 @@ class rcmail
$username = $user->data['username'];
// exit if IMAP login failed
- if (!($imap_login = $this->imap->connect($host, $username, $pass, $imap_port, $imap_ssl, $config['imap_auth_type'])))
+ if (!($imap_login = $this->imap->connect($host, $username, $pass, $imap_port, $imap_ssl)))
return false;
// user already registered -> update user's record
@@ -524,6 +538,10 @@ class rcmail
if (isset($_SESSION['page'])) {
$this->imap->set_page($_SESSION['page']);
}
+
+ // cache IMAP root and delimiter in session for performance reasons
+ $_SESSION['imap_root'] = $this->imap->root_dir;
+ $_SESSION['imap_delimiter'] = $this->imap->delimiter;
}
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index e16651af9..401bc8f7e 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -66,6 +66,7 @@ class rcube_imap
var $search_sort_field = '';
var $debug_level = 1;
var $error_code = 0;
+ var $options = array('imap' => 'check');
/**
@@ -90,7 +91,7 @@ class rcube_imap
* @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 @@ class rcube_imap
$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 @@ class rcube_imap
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 @@ class rcube_imap
$root = substr($root, 0, -1);
$this->root_dir = $root;
+ $this->options['rootdir'] = $root;
if (empty($this->delimiter))
$this->get_hierarchy_delimiter();