From e81a30752b244394b03cbcaa0df254c93b379782 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 17 Jan 2011 13:26:24 -0500
Subject: [PATCH] - Fix impossible to subscribe to protected folders (#1487656)

---
 program/steps/settings/folders.inc |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc
index ae8dddb..dcc3ce6 100644
--- a/program/steps/settings/folders.inc
+++ b/program/steps/settings/folders.inc
@@ -42,8 +42,16 @@
             }
         }
 
-        if ($result)
+        if ($result) {
+            // Handle subscription of protected folder (#1487656)
+            if ($CONFIG['protect_default_folders'] == true
+                && in_array($mbox, $CONFIG['default_imap_folders'])
+            ) {
+                $OUTPUT->command('disable_subscription', $mbox);
+            }
+
             $OUTPUT->show_message('foldersubscribed', 'confirmation');
+        }
         else
             rcmail_display_server_error('errorsaving');
     }
@@ -294,13 +302,16 @@
             $noselect = in_array('\\Noselect', $opts);
         }
 
+        $disabled = (($protected && $subscribed) || $noselect);
+
         $table->add_row(array('id' => 'rcmrow'.$idx, 'class' => join(' ', $classes)));
     
         $table->add('name', $display_folder);
         $table->add('subscribed', $checkbox_subscribe->show(($subscribed ? $folder_utf8 : ''),
-            array('value' => $folder_utf8, 'disabled' => ($protected || $noselect) ? 'disabled' : '')));
+            array('value' => $folder_utf8, 'disabled' => $disabled ? 'disabled' : '')));
 
-        $a_js_folders['rcmrow'.$idx] = array($folder_utf8, Q($display_folder), $protected || $folder['virtual']);
+        $a_js_folders['rcmrow'.$idx] = array($folder_utf8,
+            Q($display_folder), $protected || $folder['virtual']);
     }
 
     $RCMAIL->plugins->exec_hook('folders_list', array('table' => $table));

--
Gitblit v1.9.1