summaryrefslogtreecommitdiff
path: root/plugins/managesieve/lib
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-01-23 10:35:29 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-01-23 10:35:29 +0000
commit8148ffbbc015f3aeccfe1c7b6c460c5866f513c5 (patch)
tree5ecf884c5174a98d524d84751b12ab2d9da99ae5 /plugins/managesieve/lib
parent6fe2e9bb18c88740a4cfb70c8b84cce394997898 (diff)
- More tests + some script output improvments
git-svn-id: https://svn.roundcube.net/trunk@4451 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/managesieve/lib')
-rw-r--r--plugins/managesieve/lib/rcube_sieve.php34
1 files changed, 23 insertions, 11 deletions
diff --git a/plugins/managesieve/lib/rcube_sieve.php b/plugins/managesieve/lib/rcube_sieve.php
index 7389470ec..4fde86a53 100644
--- a/plugins/managesieve/lib/rcube_sieve.php
+++ b/plugins/managesieve/lib/rcube_sieve.php
@@ -538,17 +538,26 @@ class rcube_sieve_script
$i++;
}
-// $script .= ($idx>0 ? 'els' : '').($rule['join'] ? 'if allof (' : 'if anyof (');
// disabled rule: if false #....
- $script .= 'if' . ($rule['disabled'] ? ' false #' : '');
- $script .= $rule['join'] ? ' allof (' : ' anyof (';
- if (sizeof($tests) > 1)
- $script .= implode(", ", $tests);
- else if (sizeof($tests))
- $script .= $tests[0];
- else
- $script .= 'true';
- $script .= ")\n{\n";
+ $script .= 'if ' . ($rule['disabled'] ? 'false # ' : '');
+
+ if (empty($tests)) {
+ $tests_str = 'true';
+ }
+ else if (count($tests) > 1) {
+ $tests_str = implode(', ', $tests);
+ }
+ else {
+ $tests_str = $tests[0];
+ }
+
+ if ($rule['join'] || count($tests) > 1) {
+ $script .= sprintf('%s (%s)', $rule['join'] ? 'allof' : 'anyof', $tests_str);
+ }
+ else {
+ $script .= $tests_str;
+ }
+ $script .= "\n{\n";
// action(s)
foreach ($rule['actions'] as $action) {
@@ -879,12 +888,15 @@ class rcube_sieve_script
*/
static function escape_string($str)
{
- if (is_array($str)) {
+ if (is_array($str) && count($str) > 1) {
foreach($str as $idx => $val)
$str[$idx] = self::escape_string($val);
return '[' . implode(',', $str) . ']';
}
+ else if (is_array($str)) {
+ $str = array_pop($str);
+ }
// multi-line string
if (preg_match('/[\r\n\0]/', $str)) {