From 9b22f58d4ebc54a251941c48b15e9d9d71a54205 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 02 Dec 2013 07:24:52 -0500
Subject: [PATCH] Merge branch 'master' of github.com:roundcube/roundcubemail

---
 CHANGELOG                            |    4 ++++
 program/lib/Roundcube/rcube_imap.php |    9 +++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 3eca150..ee80c55 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,10 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix performance of listing writeable folders (#1489451)
+
+RELEASE 1.0-beta
+----------------
 - Fix handling of invalid closing tags in HTML messages (#1489446)
 - Set real content-type for file downloads (#1489439)
 - Update TinyMCE to version 3.5.10 (#1489442)
diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index fdda1d4..dc53058 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -2843,12 +2843,21 @@
 
     /**
      * Filter the given list of folders according to access rights
+     *
+     * For performance reasons we assume user has full rights
+     * on all personal folders.
      */
     protected function filter_rights($a_folders, $rights)
     {
         $regex = '/('.$rights.')/';
+
         foreach ($a_folders as $idx => $folder) {
+            if ($this->folder_namespace($folder) == 'personal') {
+                continue;
+            }
+
             $myrights = join('', (array)$this->my_rights($folder));
+
             if ($myrights !== null && !preg_match($regex, $myrights)) {
                 unset($a_folders[$idx]);
             }

--
Gitblit v1.9.1