From 9f1fd396951dd1bf9a082422d0835ca1a229255d Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 15 Nov 2014 04:03:35 -0500
Subject: [PATCH] Fix issue where Archive folder wasn't protected in Folder Manager (#1490154)

---
 CHANGELOG                   |    1 +
 plugins/archive/archive.php |   16 ++++++++--------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index ca80cc3..88c9394 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
 ===========================
 
 - Disable TinyMCE contextmenu plugin as there are more cons than pros in using it (#1490118)
+- Fix issue where Archive folder wasn't protected in Folder Manager (#1490154)
 - Fix compatibility with PHP 5.2. in rcube_imap_generic (#1490115)
 - Fix setting flags on servers with no PERMANENTFLAGS response (#1490087)
 - Fix regression in SHAA password generation in ldap driver of password plugin (#1490094)
diff --git a/plugins/archive/archive.php b/plugins/archive/archive.php
index a0fd2ef..ed0141a 100644
--- a/plugins/archive/archive.php
+++ b/plugins/archive/archive.php
@@ -17,11 +17,17 @@
   function init()
   {
     $rcmail = rcmail::get_instance();
+    $archive_folder = $rcmail->config->get('archive_mbox');
+
+    // add archive folder to the list of default mailboxes
+    if (($default_folders = $rcmail->config->get('default_folders')) && !in_array($archive_folder, $default_folders)) {
+      $default_folders[] = $archive_folder;
+      $rcmail->config->set('default_folders', $default_folders);
+    }
 
     // There is no "Archived flags"
     // $GLOBALS['IMAP_FLAGS']['ARCHIVED'] = 'Archive';
-    if ($rcmail->task == 'mail' && ($rcmail->action == '' || $rcmail->action == 'show')
-        && ($archive_folder = $rcmail->config->get('archive_mbox'))) {
+    if ($archive_folder && $rcmail->task == 'mail' && ($rcmail->action == '' || $rcmail->action == 'show')) {
       $skin_path = $this->local_skin_path();
       if (is_file($this->home . "/$skin_path/archive.css"))
         $this->include_stylesheet("$skin_path/archive.css");
@@ -48,12 +54,6 @@
       // set env variables for client
       $rcmail->output->set_env('archive_folder', $archive_folder);
       $rcmail->output->set_env('archive_type', $rcmail->config->get('archive_type',''));
-
-      // add archive folder to the list of default mailboxes
-      if (($default_folders = $rcmail->config->get('default_folders')) && !in_array($archive_folder, $default_folders)) {
-        $default_folders[] = $archive_folder;
-        $rcmail->config->set('default_folders', $default_folders);
-      }
     }
     else if ($rcmail->task == 'mail') {
       // handler for ajax request

--
Gitblit v1.9.1