Add new method to check subscription state of a Kolab folder

This commit is contained in:
Thomas Bruederli 2011-08-26 23:22:36 +02:00
parent 5b24abd33f
commit a9a1639abe

View file

@ -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
*