From 4ffa559227a2abecc12f8402b6ef99a06dfa4806 Mon Sep 17 00:00:00 2001 From: alecpl Date: Sat, 3 Mar 2012 13:20:14 +0000 Subject: - Apply fixes from trunk --- program/include/rcube_imap.php | 14 ++++++++------ program/include/rcube_imap_generic.php | 16 ++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'program/include') diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 514d11b4d..a536e9235 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -3040,9 +3040,10 @@ class rcube_imap NULL, array('SUBSCRIBED')); // unsubscribe non-existent folders, remove from the list - if (is_array($a_folders) && $name == '*') { + // we can do this only when LIST response is available + if (is_array($a_folders) && $name == '*' && !empty($this->conn->data['LIST'])) { foreach ($a_folders as $idx => $folder) { - if ($this->conn->data['LIST'] && ($opts = $this->conn->data['LIST'][$folder]) + if (($opts = $this->conn->data['LIST'][$folder]) && in_array('\\NonExistent', $opts) ) { $this->conn->unsubscribe($folder); @@ -3055,11 +3056,12 @@ class rcube_imap else { $a_folders = $this->conn->listSubscribed($root, $name); - // unsubscribe non-existent folders, remove from the list - if (is_array($a_folders) && $name == '*') { + // unsubscribe non-existent folders, remove them from the list, + // we can do this only when LIST response is available + if (is_array($a_folders) && $name == '*' && !empty($this->conn->data['LIST'])) { foreach ($a_folders as $idx => $folder) { - if ($this->conn->data['LIST'] && ($opts = $this->conn->data['LIST'][$folder]) - && in_array('\\Noselect', $opts) + if (!isset($this->conn->data['LIST'][$folder]) + || in_array('\\Noselect', $this->conn->data['LIST'][$folder]) ) { // Some servers returns \Noselect for existing folders if (!$this->mailbox_exists($folder)) { diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php index e390b2448..00802eba3 100644 --- a/program/include/rcube_imap_generic.php +++ b/program/include/rcube_imap_generic.php @@ -2279,12 +2279,16 @@ class rcube_imap_generic $folders[$mailbox] = array(); } - // Add to options array - if (empty($this->data['LIST'][$mailbox])) - $this->data['LIST'][$mailbox] = $opts; - else if (!empty($opts)) - $this->data['LIST'][$mailbox] = array_unique(array_merge( - $this->data['LIST'][$mailbox], $opts)); + // store LSUB options only if not empty, this way + // we can detect a situation when LIST doesn't return specified folder + if (!empty($opts) || $cmd == 'LIST') { + // Add to options array + if (empty($this->data['LIST'][$mailbox])) + $this->data['LIST'][$mailbox] = $opts; + else if (!empty($opts)) + $this->data['LIST'][$mailbox] = array_unique(array_merge( + $this->data['LIST'][$mailbox], $opts)); + } } // * STATUS () else if ($cmd == 'STATUS') { -- cgit v1.2.3