summaryrefslogtreecommitdiff
path: root/program/include/rcube_imap.php
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-10-26 13:44:39 +0000
committeralecpl <alec@alec.pl>2010-10-26 13:44:39 +0000
commit3870bec7ff891677fd848df8d027171acf921420 (patch)
tree6ecb2eb47f02cf8f8685125cf41e4a132122bac6 /program/include/rcube_imap.php
parent10a6fc58e6e8a40388ffda43f949f69f5ec804dc (diff)
- Add support for selection options from LIST-EXTENDED extension (RFC 5258)
- Don't list subscribed but non-existent folders (#1486225) - Fix \Noselect handling performance (#1487082)
Diffstat (limited to 'program/include/rcube_imap.php')
-rw-r--r--program/include/rcube_imap.php36
1 files changed, 31 insertions, 5 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 556441dcb..a4b18c970 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -2816,8 +2816,27 @@ class rcube_imap
$a_folders = $data['folders'];
}
else {
- // retrieve list of folders from IMAP server
- $a_folders = $this->conn->listSubscribed($this->mod_mailbox($root), $filter);
+ // Server supports LIST-EXTENDED, we can use selection options
+ if ($this->get_capability('LIST-EXTENDED')) {
+ // This will also set mailbox options, LSUB doesn't do that
+ $a_folders = $this->conn->listMailboxes($this->mod_mailbox($root), $filter,
+ NULL, array('SUBSCRIBED'));
+
+ // remove non-existent folders
+ if (is_array($a_folders)) {
+ foreach ($a_folders as $idx => $folder) {
+ if ($this->conn->data['LIST'] && ($opts = $this->conn->data['LIST'][$folder])
+ && in_array('\\NonExistent', $opts)
+ ) {
+ unset($a_folders[$idx]);
+ }
+ }
+ }
+ }
+ // retrieve list of folders from IMAP server using LSUB
+ else {
+ $a_folders = $this->conn->listSubscribed($this->mod_mailbox($root), $filter);
+ }
}
if (!is_array($a_folders) || !sizeof($a_folders))
@@ -3121,13 +3140,15 @@ class rcube_imap
/**
- * Gets folder options from LIST/LSUB response, e.g. \Noselect, \Noinferiors
+ * Gets folder options from LIST response, e.g. \Noselect, \Noinferiors
*
* @param string $mbox_name Folder name
+ * @param bool $force Set to True if options should be refreshed
+ * Options are available after LIST command only
*
* @return array Options list
*/
- function mailbox_options($mbox_name)
+ function mailbox_options($mbox_name, $force=false)
{
$mbox = $this->mod_mailbox($mbox_name);
@@ -3136,7 +3157,12 @@ class rcube_imap
}
if (!is_array($this->conn->data['LIST']) || !is_array($this->conn->data['LIST'][$mbox])) {
- $this->conn->listMailboxes($this->mod_mailbox(''), $mbox_name);
+ if ($force) {
+ $this->conn->listMailboxes($this->mod_mailbox(''), $mbox_name);
+ }
+ else {
+ return array();
+ }
}
$opts = $this->conn->data['LIST'][$mbox];