From 473dc0b86d6e1790945d48d6d5161b04e14575b8 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 02 Apr 2016 03:11:21 -0400
Subject: [PATCH] Fix so SPECIAL-USE assignments are forced only until user sets special folders (#4782)

---
 CHANGELOG                             |    1 +
 program/lib/Roundcube/rcube_imap.php  |    6 ++++++
 program/steps/settings/save_prefs.inc |    2 ++
 3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index b163b83..bdf48b7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
 - Protect download urls against CSRF using unique request tokens (#1490642)
 - newmail_notifier: Refactor desktop notifications
 - Fix so contactlist_fields option can be set via config file
+- Fix so SPECIAL-USE assignments are forced only until user sets special folders (#4782)
 
 RELEASE 1.1.4
 -------------
diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index b3322fc..ea5e717 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -3295,6 +3295,12 @@
     public function get_special_folders($forced = false)
     {
         $result = parent::get_special_folders();
+        $rcube  = rcube::get_instance();
+
+        // Lock SPECIAL-USE after user preferences change (#4782)
+        if ($rcube->config->get('lock_special_folders')) {
+            return $result;
+        }
 
         if (isset($this->icache['special-use'])) {
             return array_merge($result, $this->icache['special-use']);
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index 4ecaa70..7528fa8 100644
--- a/program/steps/settings/save_prefs.inc
+++ b/program/steps/settings/save_prefs.inc
@@ -123,6 +123,8 @@
 case 'folders':
     $a_user_prefs = array(
         'show_real_foldernames' => isset($_POST['_show_real_foldernames']) ? true : false,
+        // stop using SPECIAL-USE (#4782)
+        'lock_special_folders'  => !in_array('lock_special_folders', (array) $CONFIG['dont_override']),
     );
 
     foreach (rcube_storage::$folder_types as $type) {

--
Gitblit v1.9.1