From a9a1639abe6a0e2281e83ccd77499e01a6a516bb Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Fri, 26 Aug 2011 23:22:36 +0200 Subject: [PATCH] Add new method to check subscription state of a Kolab folder --- plugins/kolab_core/rcube_kolab.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/plugins/kolab_core/rcube_kolab.php b/plugins/kolab_core/rcube_kolab.php index d5b87c51..ef74d361 100644 --- a/plugins/kolab_core/rcube_kolab.php +++ b/plugins/kolab_core/rcube_kolab.php @@ -187,6 +187,32 @@ class rcube_kolab return self::$ready ? $kolab->getFolder($folder) : null; } + /** + * Checks if the given folder is subscribed. + * Much nicer would be if the Kolab_Folder object could tell this information + * + * @param string Full IMAP folder name + * @return boolean True if in the list of subscribed folders, False if not + */ + public static function is_subscribed($folder) + { + static $subscribed; // local cache + + if (!$subscribed) { + $rcmail = rcmail::get_instance(); + // try without connection first (list could be served from cache) + $subscribed = $rcmail->imap->list_mailboxes(); + + // now really get the list from the IMAP server + if (empty($subscribed) || $subscribed == array('INBOX')) { + $rcmail->imap_connect(); + $subscribed = $rcmail->imap->list_mailboxes(); + } + } + + return in_array($folder, $subscribed); + } + /** * Get storage object for read/write access to the Kolab backend *