From 7ae5432fbfc0e923f2fe8dc62ff77afb8ecc80cf Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 30 May 2012 04:42:27 -0400
Subject: [PATCH] Abbreviate long attachment file names with ellipsis (#1488499)
---
program/include/rcube_imap.php | 73 +++++++++++++++++++++++++++---------
1 files changed, 55 insertions(+), 18 deletions(-)
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 2fb1ff8..419e26c 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);
}
@@ -2879,11 +2916,11 @@
// get list of subscribed folders
if ((strpos($folder, '%') === false) && (strpos($folder, '*') === false)) {
- $a_subscribed = $this->_list_folders_subscribed('', $folder . $delm . '*');
+ $a_subscribed = $this->list_folders_subscribed('', $folder . $delm . '*');
$subscribed = $this->folder_exists($folder, true);
}
else {
- $a_subscribed = $this->_list_folders_subscribed();
+ $a_subscribed = $this->list_folders_subscribed();
$subscribed = in_array($folder, $a_subscribed);
}
--
Gitblit v1.9.1