summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-03-07 14:22:11 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-03-07 14:22:11 +0000
commit7ac550ea8914f1d1cb72d6269d92b1d8f2b7eeec (patch)
tree9095378fc30173e8a0ea813274a6844a06f02469
parent4ae9a39aabee5816b6321d24e771ddb56d824ab7 (diff)
- Fix saving of a script using flags extension on servers with imap4flags support (#1487825)
git-svn-id: https://svn.roundcube.net/trunk@4596 208e9e7b-5314-0410-a742-e7e81cd9613c
-rw-r--r--plugins/managesieve/Changelog3
-rw-r--r--plugins/managesieve/lib/rcube_sieve.php9
-rw-r--r--plugins/managesieve/lib/rcube_sieve_script.php12
-rw-r--r--plugins/managesieve/managesieve.php7
4 files changed, 20 insertions, 11 deletions
diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog
index 9b54c5e42..8bbb12a90 100644
--- a/plugins/managesieve/Changelog
+++ b/plugins/managesieve/Changelog
@@ -1,8 +1,11 @@
+* version 4.1 [2011-03-07]
+-----------------------------------------------------------
- Fix fileinto target is always INBOX (#1487776)
- Fix escaping of backslash character in quoted strings (#1487780)
- Fix handling of non-safe characters (double-quote, backslash)
or UTF-8 characters (dovecot's implementation bug workaround)
in script names
+- Fix saving of a script using flags extension on servers with imap4flags support (#1487825)
* version 4.0 [2011-02-10]
-----------------------------------------------------------
diff --git a/plugins/managesieve/lib/rcube_sieve.php b/plugins/managesieve/lib/rcube_sieve.php
index a51671e88..d701095f2 100644
--- a/plugins/managesieve/lib/rcube_sieve.php
+++ b/plugins/managesieve/lib/rcube_sieve.php
@@ -31,6 +31,7 @@ class rcube_sieve
public $script; // rcube_sieve_script object
public $current; // name of currently loaded script
private $disabled; // array of disabled extensions
+ private $exts; // array of supported extensions
/**
@@ -73,6 +74,7 @@ class rcube_sieve
return $this->_set_error(SIEVE_ERROR_LOGIN);
}
+ $this->exts = $this->get_extensions();
$this->disabled = $disabled;
}
@@ -191,6 +193,9 @@ class rcube_sieve
*/
public function get_extensions()
{
+ if ($this->exts)
+ return $this->exts;
+
if (!$this->sieve)
return $this->_set_error(SIEVE_ERROR_INTERNAL);
@@ -280,12 +285,12 @@ class rcube_sieve
private function _parse($txt)
{
// try to parse from Roundcube format
- $script = new rcube_sieve_script($txt, $this->disabled);
+ $script = new rcube_sieve_script($txt, $this->disabled, $this->exts);
// ... else try to import from different formats
if (empty($script->content)) {
$script = $this->_import_rules($txt);
- $script = new rcube_sieve_script($script, $this->disabled);
+ $script = new rcube_sieve_script($script, $this->disabled, $this->exts);
}
// replace all elsif with if+stop, we support only ifs
diff --git a/plugins/managesieve/lib/rcube_sieve_script.php b/plugins/managesieve/lib/rcube_sieve_script.php
index 084540b60..48122525c 100644
--- a/plugins/managesieve/lib/rcube_sieve_script.php
+++ b/plugins/managesieve/lib/rcube_sieve_script.php
@@ -26,13 +26,16 @@ class rcube_sieve_script
// TODO: body, notify
);
+ private $capabilities;
+
/**
* Object constructor
*
* @param string Script's text content
- * @param array Disabled extensions
+ * @param array List of disabled extensions
+ * @param array List of capabilities supported by server
*/
- public function __construct($script, $disabled=null)
+ public function __construct($script, $disabled=null, $capabilities=null)
{
if (!empty($disabled)) {
// we're working on lower-cased names
@@ -44,7 +47,8 @@ class rcube_sieve_script
}
}
- $this->content = $this->_parse_text($script);
+ $this->capabilities = $capabilities;
+ $this->content = $this->_parse_text($script);
}
/**
@@ -216,7 +220,7 @@ class rcube_sieve_script
case 'addflag':
case 'setflag':
case 'removeflag':
- if (!empty($action['mode']) && strtolower($action['mode']) == 'imap4flags')
+ if (is_array($this->capabilities) && in_array('imap4flags', $this->capabilities))
array_push($exts, 'imap4flags');
else
array_push($exts, 'imapflags');
diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php
index 1b44562f8..0ec435d81 100644
--- a/plugins/managesieve/managesieve.php
+++ b/plugins/managesieve/managesieve.php
@@ -534,9 +534,6 @@ class managesieve extends rcube_plugin
}
}
$this->form['actions'][$i]['target'] = $_target;
- if (in_array('imap4flags', $this->exts)) {
- $this->form['actions'][$i]['mode'] = 'imap4flags';
- }
break;
case 'vacation':
@@ -1085,9 +1082,9 @@ class managesieve extends rcube_plugin
. (preg_match('/^(set|add|remove)flag$/', $action['type']) ? 'inline' : 'none') . '"'
. $this->error_class($id, 'action', 'flags', 'action_flags') . '>';
foreach ($flags as $fidx => $flag) {
- $out .= '<nobr><input type="checkbox" name="_action_flags[' .$id .'][]" value="' . $flag . '"'
+ $out .= '<input type="checkbox" name="_action_flags[' .$id .'][]" value="' . $flag . '"'
. (in_array_nocase($flag, $flags_target) ? 'checked="checked"' : '') . ' />'
- . Q($this->gettext('flag'.$fidx)) .'</nobr> ';
+ . Q($this->gettext('flag'.$fidx)) .'<br>';
}
$out .= '</div>';