summaryrefslogtreecommitdiff
path: root/program/include/rcube_imap_generic.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_generic.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_generic.php')
-rw-r--r--program/include/rcube_imap_generic.php37
1 files changed, 28 insertions, 9 deletions
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index c79124bec..41240a2d1 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -1826,14 +1826,15 @@ class rcube_imap_generic
* @param string $ref Reference name
* @param string $mailbox Mailbox name
* @param array $status_opts (see self::_listMailboxes)
+ * @param array $select_opts (see self::_listMailboxes)
*
* @return array List of mailboxes or hash of options if $status_opts argument
* is non-empty.
* @access public
*/
- function listMailboxes($ref, $mailbox, $status_opts=array())
+ function listMailboxes($ref, $mailbox, $status_opts=array(), $select_opts=array())
{
- return $this->_listMailboxes($ref, $mailbox, false, $status_opts);
+ return $this->_listMailboxes($ref, $mailbox, false, $status_opts, $select_opts);
}
/**
@@ -1843,13 +1844,13 @@ class rcube_imap_generic
* @param string $mailbox Mailbox name
* @param array $status_opts (see self::_listMailboxes)
*
- * @return array List of mailboxes or hash of options if $status_ops argument
+ * @return array List of mailboxes or hash of options if $status_opts argument
* is non-empty.
* @access public
*/
function listSubscribed($ref, $mailbox, $status_opts=array())
{
- return $this->_listMailboxes($ref, $mailbox, true, $status_opts);
+ return $this->_listMailboxes($ref, $mailbox, true, $status_opts, NULL);
}
/**
@@ -1860,12 +1861,15 @@ class rcube_imap_generic
* @param bool $subscribed Enables returning subscribed mailboxes only
* @param array $status_opts List of STATUS options (RFC5819: LIST-STATUS)
* Possible: MESSAGES, RECENT, UIDNEXT, UIDVALIDITY, UNSEEN
+ * @param array $select_opts List of selection options (RFC5258: LIST-EXTENDED)
+ * Possible: SUBSCRIBED, RECURSIVEMATCH, REMOTE
*
* @return array List of mailboxes or hash of options if $status_ops argument
* is non-empty.
* @access private
*/
- private function _listMailboxes($ref, $mailbox, $subscribed=false, $status_opts=array())
+ private function _listMailboxes($ref, $mailbox, $subscribed=false,
+ $status_opts=array(), $select_opts=array())
{
if (empty($mailbox)) {
$mailbox = '*';
@@ -1875,10 +1879,19 @@ class rcube_imap_generic
$ref = $this->prefs['rootdir'];
}
- $args = array($this->escape($ref), $this->escape($mailbox));
+ $args = array();
+
+ if (!empty($select_opts) && $this->getCapability('LIST-EXTENDED')) {
+ $select_opts = (array) $select_opts;
+
+ $args[] = '(' . implode(' ', $select_opts) . ')';
+ }
+
+ $args[] = $this->escape($ref);
+ $args[] = $this->escape($mailbox);
if (!empty($status_opts) && $this->getCapability('LIST-STATUS')) {
- $status_opts = array($status_opts);
+ $status_opts = (array) $status_opts;
$lstatus = true;
$args[] = 'RETURN (STATUS (' . implode(' ', $status_opts) . '))';
@@ -1894,6 +1907,7 @@ class rcube_imap_generic
if (!$lstatus || $cmd == 'LIST' || $cmd == 'LSUB') {
list($opts, $delim, $folder) = $this->tokenizeResponse($response, 3);
+ // Add to result array
if (!$lstatus) {
$folders[] = $folder;
}
@@ -1901,8 +1915,13 @@ class rcube_imap_generic
$folders[$folder] = array();
}
- if ($cmd == 'LIST') {
- $this->data['LIST'][$folder] = $opts;
+ // Add to options array
+ if (!empty($opts)) {
+ if (empty($this->data['LIST'][$folder]))
+ $this->data['LIST'][$folder] = $opts;
+ else
+ $this->data['LIST'][$folder] = array_unique(array_merge(
+ $this->data['LIST'][$folder], $opts));
}
}
// * STATUS <mailbox> (<result>)