summaryrefslogtreecommitdiff
path: root/program/include/rcube_imap.php
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 09:19:51 +0200
commit996d75d5fa4a5052094a64cf82d78c4375a5e797 (patch)
treea6150487799b02c2cee18251358f44f274c46f94 /program/include/rcube_imap.php
parentbe98408f40b68b7f935821819d3a84156074e188 (diff)
Improved PERMANENTFLAGS checking code, added code for flags caching (currently commented out)
Diffstat (limited to 'program/include/rcube_imap.php')
-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 c3fb44871..bfa84b4e0 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -401,15 +401,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;
}