summaryrefslogtreecommitdiff
path: root/plugins/managesieve/managesieve.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-06-11 13:46:18 +0200
committerAleksander Machniak <alec@alec.pl>2013-06-11 13:46:18 +0200
commita1679cb650d62bac957419d287c72ca59d800d5c (patch)
treeee86807fbb94f1ac976e95e0d9b7ae5351cd802b /plugins/managesieve/managesieve.php
parentb41c1d94985e4b47e6de8de98f013e9169bc80a8 (diff)
Use list input field for custom headers list
Diffstat (limited to 'plugins/managesieve/managesieve.php')
-rw-r--r--plugins/managesieve/managesieve.php26
1 files changed, 11 insertions, 15 deletions
diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php
index c7d5911e7..63ca97a70 100644
--- a/plugins/managesieve/managesieve.php
+++ b/plugins/managesieve/managesieve.php
@@ -765,7 +765,7 @@ class managesieve extends rcube_plugin
}
}
else {
- $cust_header = $headers = $this->strip_value($cust_headers[$idx]);
+ $cust_header = $headers = $this->strip_value(array_shift($cust_headers));
$mod = $this->strip_value($mods[$idx]);
$mod_type = $this->strip_value($mod_types[$idx]);
@@ -774,8 +774,6 @@ class managesieve extends rcube_plugin
$type = preg_replace('/^not/', '', $operator);
if ($header == '...') {
- $headers = preg_split('/[\s,]+/', $cust_header, -1, PREG_SPLIT_NO_EMPTY);
-
if (!count($headers))
$this->errors['tests'][$i]['header'] = $this->gettext('cannotbeempty');
else {
@@ -1336,22 +1334,20 @@ class managesieve extends rcube_plugin
$aout .= $select_header->show();
if (isset($rule['test']) && in_array($rule['test'], array('header', 'address', 'envelope'))) {
- if (is_array($rule['arg1']))
- $custom = implode(', ', $rule['arg1']);
- else if (!in_array($rule['arg1'], $this->headers))
- $custom = $rule['arg1'];
+ $custom = (array) $rule['arg1'];
+ if (count($custom) == 1 && isset($this->headers[strtolower($custom[0])])) {
+ unset($custom);
+ }
}
else if (isset($rule['test']) && $rule['test'] == 'exists') {
- if (is_array($rule['arg']))
- $custom = implode(', ', $rule['arg']);
- else if (!in_array($rule['arg'], $this->headers))
- $custom = $rule['arg'];
+ $custom = (array) $rule['arg'];
+ if (count($custom) == 1 && isset($this->headers[strtolower($custom[0])])) {
+ unset($custom);
+ }
}
- $tout = '<div id="custom_header' .$id. '" style="display:' .(isset($custom) ? 'inline' : 'none'). '">
- <input type="text" name="_custom_header[]" id="custom_header_i'.$id.'" '
- . $this->error_class($id, 'test', 'header', 'custom_header_i')
- .' value="' .rcube::Q($custom). '" size="15" />&nbsp;</div>' . "\n";
+ $tout = $this->list_input($id, 'custom_header', $custom, isset($custom),
+ $this->error_class($id, 'test', 'header', 'custom_header'), 15) . "\n";
// matching type select (operator)
$select_op = new html_select(array('name' => "_rule_op[]", 'id' => 'rule_op'.$id,