From 501cdd651e31508a075deeb002037624b69a07c6 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 14 Jan 2015 10:25:57 -0500
Subject: [PATCH] Fix bug where vacation rule was saved to wrong script if managesieve_kolab_master=true

---
 plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
index 035b267..506484c 100644
--- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
+++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
@@ -227,7 +227,7 @@
 
         if ($script_name === null || $script_name === '') {
             // get (first) active script
-            if (!empty($this->active[0])) {
+            if (!empty($this->active)) {
                $script_name = $this->active[0];
             }
             else if ($list) {
@@ -2078,7 +2078,6 @@
 
         // Handle active script(s) and list of scripts according to Kolab's KEP:14
         if ($this->rc->config->get('managesieve_kolab_master')) {
-
             // Skip protected names
             foreach ((array)$this->list as $idx => $name) {
                 $_name = strtoupper($name);
@@ -2140,6 +2139,11 @@
             }
         }
 
+        // reindex
+        if (!empty($this->list)) {
+            $this->list = array_values($this->list);
+        }
+
         return $this->list;
     }
 

--
Gitblit v1.9.1