From 25e6a0f11043537e9ea2950398f916d4db96a235 Mon Sep 17 00:00:00 2001 From: alecpl Date: Thu, 23 Jun 2011 17:43:44 +0000 Subject: - Add rcube_imap::mailbox_info() --- program/include/rcube_imap.php | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'program/include/rcube_imap.php') diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 31f196d4a..e1da538da 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -3488,6 +3488,62 @@ class rcube_imap } + /** + * Returns extended information about the folder + * + * @param string $mailbox Folder name + * + * @return array Data + */ + function mailbox_info($mailbox) + { + $acl = $this->get_capability('ACL'); + $namespace = $this->get_namespace(); + $options = array(); + + // check if the folder is a namespace prefix + if (!empty($namespace)) { + $mbox = $mailbox . $this->delimiter; + foreach ($namespace as $ns) { + foreach ($ns as $item) { + if ($item[0] === $mbox) { + $options['is_root'] = true; + break; + } + } + } + } + + $options['name'] = $mailbox; + $options['options'] = $this->mailbox_options($mailbox, true); + $options['namespace'] = $this->mailbox_namespace($mailbox); + $options['rights'] = $acl && !$options['is_root'] ? (array)$this->my_rights($mailbox) : array(); + $options['special'] = in_array($mailbox, $this->default_folders); + + if (is_array($options['options'])) { + foreach ($options['options'] as $opt) { + $opt = strtolower($opt); + if ($opt == '\noselect' || $opt == '\nonexistent') { + $options['noselect'] = true; + } + } + } + else { + $options['noselect'] = true; + } + + if (!empty($options['rights'])) { + $options['norename'] = !in_array('x', $options['rights']) && + (!in_array('c', $options['rights']) || !in_array('d', $options['rights'])); + if (!$options['noselect']) { + $options['noselect'] = !in_array('r', $options['rights']); + } + } + + return $options; + } + + /** * Get message header names for rcube_imap_generic::fetchHeader(s) * -- cgit v1.2.3