summaryrefslogtreecommitdiff
path: root/plugins/managesieve/managesieve.php
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-10-10 10:27:39 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-10-10 10:27:39 +0000
commit2ee1e3cb017419a6df8341cfeabe47b074285c35 (patch)
tree3ef01dfdce5497e643c862c710c1ed252dda0c1f /plugins/managesieve/managesieve.php
parent86ffed7da35f05874943d198e34711921de06c6f (diff)
- Support relational operators and i;ascii-numeric comparator (RFC3431)
git-svn-id: https://svn.roundcube.net/trunk@4068 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/managesieve/managesieve.php')
-rw-r--r--plugins/managesieve/managesieve.php26
1 files changed, 22 insertions, 4 deletions
diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php
index 81e6eb7f9..b959c3c93 100644
--- a/plugins/managesieve/managesieve.php
+++ b/plugins/managesieve/managesieve.php
@@ -383,14 +383,14 @@ class managesieve extends rcube_plugin
$this->form['tests'][0]['test'] = 'true';
}
else {
- foreach($headers as $idx => $header) {
+ foreach ($headers as $idx => $header) {
$header = $this->strip_value($header);
$target = $this->strip_value($targets[$idx], true);
$op = $this->strip_value($ops[$idx]);
// normal header
if (in_array($header, $this->headers)) {
- if(preg_match('/^not/', $op))
+ if (preg_match('/^not/', $op))
$this->form['tests'][$i]['not'] = true;
$type = preg_replace('/^not/', '', $op);
@@ -406,6 +406,8 @@ class managesieve extends rcube_plugin
if ($target == '')
$this->errors['tests'][$i]['target'] = $this->gettext('cannotbeempty');
+ else if (preg_match('/^(value|count)-/', $type) && !preg_match('/[0-9]+/', $target))
+ $this->errors['tests'][$i]['target'] = $this->gettext('forbiddenchars');
}
}
else
@@ -425,7 +427,7 @@ class managesieve extends rcube_plugin
case '...':
$cust_header = $headers = $this->strip_value($cust_headers[$idx]);
- if(preg_match('/^not/', $op))
+ if (preg_match('/^not/', $op))
$this->form['tests'][$i]['not'] = true;
$type = preg_replace('/^not/', '', $op);
@@ -458,6 +460,8 @@ class managesieve extends rcube_plugin
if ($target == '')
$this->errors['tests'][$i]['target'] = $this->gettext('cannotbeempty');
+ else if (preg_match('/^(value|count)-/', $type) && !preg_match('/[0-9]+/', $target))
+ $this->errors['tests'][$i]['target'] = $this->gettext('forbiddenchars');
}
break;
}
@@ -888,6 +892,20 @@ class managesieve extends rcube_plugin
$select_op->add(Q($this->gettext('filternotexists')), 'notexists');
// $select_op->add(Q($this->gettext('filtermatches')), 'matches');
// $select_op->add(Q($this->gettext('filternotmatches')), 'notmatches');
+ if (in_array('relational', $this->exts)) {
+ $select_op->add(Q($this->gettext('countisgreaterthan')), 'count-gt');
+ $select_op->add(Q($this->gettext('countisgreaterthanequal')), 'count-ge');
+ $select_op->add(Q($this->gettext('countislessthan')), 'count-lt');
+ $select_op->add(Q($this->gettext('countislessthanequal')), 'count-le');
+ $select_op->add(Q($this->gettext('countequals')), 'count-eq');
+ $select_op->add(Q($this->gettext('countnotequals')), 'count-ne');
+ $select_op->add(Q($this->gettext('valueisgreaterthan')), 'value-gt');
+ $select_op->add(Q($this->gettext('valueisgreaterthanequal')), 'value-ge');
+ $select_op->add(Q($this->gettext('valueislessthan')), 'value-lt');
+ $select_op->add(Q($this->gettext('valueislessthanequal')), 'value-le');
+ $select_op->add(Q($this->gettext('valueequals')), 'value-eq');
+ $select_op->add(Q($this->gettext('valuenotequals')), 'value-ne');
+ }
// target input (TODO: lists)
@@ -897,7 +915,7 @@ class managesieve extends rcube_plugin
}
else if ($rule['test'] == 'size') {
$out .= $select_op->show();
- if(preg_match('/^([0-9]+)(K|M|G)*$/', $rule['arg'], $matches)) {
+ if (preg_match('/^([0-9]+)(K|M|G)*$/', $rule['arg'], $matches)) {
$sizetarget = $matches[1];
$sizeitem = $matches[2];
}