From b866a27364a66c436156732553b1fa638e046b8b Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 28 Jun 2012 04:43:50 -0400
Subject: [PATCH] Fix handling of MYRIGHTS on private namespace roots - fixes issue where in ACL plugin it wasn't possible to share INBOX folder (when it was a namespace prefix).

---
 program/include/rcube_imap.php |   15 ++++++++++++---
 plugins/acl/acl.php            |   16 ++++------------
 plugins/acl/package.xml        |    4 ++--
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php
index ab981ab..8709f0b 100644
--- a/plugins/acl/acl.php
+++ b/plugins/acl/acl.php
@@ -128,8 +128,10 @@
      */
     function folder_form($args)
     {
-        // Edited folder name (empty in create-folder mode)
         $mbox_imap = $args['options']['name'];
+        $myrights  = $args['options']['rights'];
+
+        // Edited folder name (empty in create-folder mode)
         if (!strlen($mbox_imap)) {
             return $args;
         }
@@ -139,18 +141,8 @@
             return $args;
         }
 */
-        // Namespace root
-        if ($args['options']['is_root']) {
-            return $args;
-        }
-
         // Get MYRIGHTS
-        if (!($myrights = $args['options']['rights'])) {
-            return $args;
-        }
-
-        // Do nothing if no ACL support
-        if (!$this->rc->storage->get_capability('ACL')) {
+        if (empty($myrights)) {
             return $args;
         }
 
diff --git a/plugins/acl/package.xml b/plugins/acl/package.xml
index 7ea0f32..5f86384 100644
--- a/plugins/acl/package.xml
+++ b/plugins/acl/package.xml
@@ -13,9 +13,9 @@
 		<email>alec@alec.pl</email>
 		<active>yes</active>
 	</lead>
-	<date>2012-03-13</date>
+	<date>2012-06-28</date>
 	<version>
-		<release>0.8</release>
+		<release>0.9</release>
 		<api>0.7</api>
 	</version>
 	<stability>
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 57b85c3..94200b7 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -3229,8 +3229,9 @@
         $cache_key = 'mailboxes.folder-info.' . $folder;
         $cached = $this->get_cache($cache_key);
 
-        if (is_array($cached))
+        if (is_array($cached)) {
             return $cached;
+        }
 
         $acl       = $this->get_capability('ACL');
         $namespace = $this->get_namespace();
@@ -3267,10 +3268,9 @@
         $options['name']       = $folder;
         $options['attributes'] = $this->folder_attributes($folder, true);
         $options['namespace']  = $this->folder_namespace($folder);
-        $options['rights']     = $acl && !$options['is_root'] ? (array)$this->my_rights($folder) : array();
         $options['special']    = in_array($folder, $this->default_folders);
 
-        // Set 'noselect' and 'norename' flags
+        // Set 'noselect' flag
         if (is_array($options['attributes'])) {
             foreach ($options['attributes'] as $attrib) {
                 $attrib = strtolower($attrib);
@@ -3283,6 +3283,15 @@
             $options['noselect'] = true;
         }
 
+        // Get folder rights (MYRIGHTS)
+        if ($acl && !$options['noselect']) {
+            // skip shared roots
+            if (!$options['is_root'] || $options['namespace'] == 'personal') {
+                $options['rights'] =  (array)$this->my_rights($folder);
+            }
+        }
+
+        // Set 'norename' flag
         if (!empty($options['rights'])) {
             $options['norename'] = !in_array('x', $options['rights']) && !in_array('d', $options['rights']);
 

--
Gitblit v1.9.1