summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-05-23 09:19:51 +0200
committerAleksander Machniak <alec@alec.pl>2012-05-23 20:06:57 +0200
commit82a1417af89cabf48dffb4900067b0c6cf41aa6a (patch)
tree4617981acdc7198a3cfe5a57b4707df9f78a629d /program
parentda19e0ee7c5656feb49553c398fdb94e3f618c26 (diff)
Improved PERMANENTFLAGS checking code, added code for flags caching (currently commented out)
Diffstat (limited to 'program')
-rw-r--r--program/include/rcube_imap.php53
1 files changed, 47 insertions, 6 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 5ead4668a..3b44da376 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -404,15 +404,56 @@ class rcube_imap extends rcube_storage
*/
public function check_permflag($flag)
{
- $flag = strtoupper($flag);
- $imap_flag = $this->conn->flags[$flag];
+ $flag = strtoupper($flag);
+ $imap_flag = $this->conn->flags[$flag];
+ $perm_flags = $this->get_permflags($this->folder);
+
+ return in_array_nocase($imap_flag, $perm_flags);
+ }
+
+
+ /**
+ * Returns PERMANENTFLAGS of the specified folder
+ *
+ * @param string $folder Folder name
+ *
+ * @return array Flags
+ */
+ public function get_permflags($folder)
+ {
+ if (!strlen($folder)) {
+ return array();
+ }
+/*
+ Checking PERMANENTFLAGS is rather rare, so we disable caching of it
+ Re-think when we'll use it for more than only MDNSENT flag
+
+ $cache_key = 'mailboxes.permanentflags.' . $folder;
+ $permflags = $this->get_cache($cache_key);
+
+ if ($permflags !== null) {
+ return explode(' ', $permflags);
+ }
+*/
+ if (!$this->check_connection()) {
+ return array();
+ }
- if ($this->folder !== null) {
- $this->check_connection();
+ if ($this->conn->select($folder)) {
+ $permflags = $this->conn->data['PERMANENTFLAGS'];
+ }
+ else {
+ return array();
}
- // @TODO: cache permanent flags (?)
- return (in_array_nocase($imap_flag, $this->conn->data['PERMANENTFLAGS']));
+ if (!is_array($permflags)) {
+ $permflags = array();
+ }
+/*
+ // Store permflags as string to limit cached object size
+ $this->update_cache($cache_key, implode(' ', $permflags));
+*/
+ return $permflags;
}