From d8008fe3a99f2358e48517323d32f121e6968259 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 21 Aug 2012 08:23:43 -0400
Subject: [PATCH] Merge branch 'master' of github.com:roundcube/roundcubemail

---
 CHANGELOG                          |    1 +
 program/steps/settings/folders.inc |    8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 4d18f64..784bbc8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix so subscribed non-existing/non-accessible shared folder can be unsubscribed
 - Added session_path config option and unified cookies settings in javascript
 - Added "Undeleted" option to messages list filter
 - Rewritten test scripts for PHPUnit
diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc
index 2691a6e..2c2cbdc 100644
--- a/program/steps/settings/folders.inc
+++ b/program/steps/settings/folders.inc
@@ -44,8 +44,8 @@
 
         if ($result) {
             // Handle subscription of protected folder (#1487656)
-            if ($CONFIG['protect_default_folders'] == true
-                && in_array($mbox, $CONFIG['default_folders'])
+            if ($RCMAIL->config->get('protect_default_folders')
+                && in_array($mbox, (array)$RCMAIL->config->get('default_folders'))
             ) {
                 $OUTPUT->command('disable_subscription', $mbox);
             }
@@ -321,8 +321,8 @@
                 }
             }
         }
-        // check if the folder is shared, then disable subscription option on it
-        if (!$disabled && $folder['virtual'] && !empty($namespace)) {
+        // check if the folder is shared, then disable subscription option on it (if not subscribed already)
+        if (!$disabled && !$subscribed && $folder['virtual'] && !empty($namespace)) {
             $tmp_ns = array_merge((array)$namespace['other'], (array)$namespace['shared']);
             foreach ($tmp_ns as $item) {
                 if (strpos($folder['id'], $item[0]) === 0) {

--
Gitblit v1.9.1