From 8e528fd7bf2e2bd1e20c7e7de5eefb26bf6b19d9 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 23 May 2012 14:09:57 -0400
Subject: [PATCH] hide_blockquote - a new plugin for hiding citation blocks
---
program/include/rcube_imap.php | 69 ++++++++++++++++++++++++++--------
1 files changed, 53 insertions(+), 16 deletions(-)
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 2fb1ff8..3b44da3 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -404,15 +404,56 @@
*/
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);
- if ($this->folder !== null) {
- $this->check_connection();
+ 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();
}
- // @TODO: cache permanent flags (?)
+/*
+ Checking PERMANENTFLAGS is rather rare, so we disable caching of it
+ Re-think when we'll use it for more than only MDNSENT flag
- return (in_array_nocase($imap_flag, $this->conn->data['PERMANENTFLAGS']));
+ $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->conn->select($folder)) {
+ $permflags = $this->conn->data['PERMANENTFLAGS'];
+ }
+ else {
+ return array();
+ }
+
+ if (!is_array($permflags)) {
+ $permflags = array();
+ }
+/*
+ // Store permflags as string to limit cached object size
+ $this->update_cache($cache_key, implode(' ', $permflags));
+*/
+ return $permflags;
}
@@ -2539,11 +2580,8 @@
return array();
}
- // #1486796: some server configurations doesn't
- // return folders in all namespaces, we'll try to detect that situation
- // and ask for these namespaces separately
- // @TODO: make this optional
- if ($root == '' && $name == '*') {
+ // #1486796: some server configurations doesn't return folders in all namespaces
+ if ($root == '' && $name == '*' && $config->get('imap_force_ns')) {
$this->list_folders_update($a_folders, ($list_extended ? 'ext-' : '') . 'subscribed');
}
@@ -2673,11 +2711,10 @@
return array();
}
- // #1486796: some server configurations doesn't
- // return folders in all namespaces, we'll try to detect that situation
- // and ask for these namespaces separately
- // @TODO: make this optional
- if ($root == '' && $name == '*') {
+ $config = rcmail::get_instance()->config;
+
+ // #1486796: some server configurations doesn't return folders in all namespaces
+ if ($root == '' && $name == '*' && $config->get('imap_force_ns')) {
$this->list_folders_update($result);
}
--
Gitblit v1.9.1