diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-03-16 16:29:17 +0100 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-03-16 16:29:17 +0100 |
commit | b6fa7d54b852df88de1fa1b36d6221b143e85835 (patch) | |
tree | 4e49e0f1300a6924846af9cf7bfe76c7f370d629 /plugins/managesieve/lib | |
parent | bb080af14d285361ee078514a1d995c096e0f790 (diff) |
Add vacation-seconds extension support (RFC 6131)
Diffstat (limited to 'plugins/managesieve/lib')
-rw-r--r-- | plugins/managesieve/lib/Roundcube/rcube_sieve.php | 2 | ||||
-rw-r--r-- | plugins/managesieve/lib/Roundcube/rcube_sieve_script.php | 41 |
2 files changed, 22 insertions, 21 deletions
diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve.php b/plugins/managesieve/lib/Roundcube/rcube_sieve.php index 736f73146..a04e3c2a4 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve.php @@ -84,7 +84,7 @@ class rcube_sieve return $this->_set_error(SIEVE_ERROR_LOGIN); } - $this->exts = $this->get_extensions(); + $this->exts = $this->get_extensions(); // disable features by config if (!empty($disabled)) { diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php index 36eb1bcf8..80f590f4b 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php @@ -33,6 +33,7 @@ class rcube_sieve_script 'ereject', // RFC5429 'copy', // RFC3894 'vacation', // RFC5230 + 'vacation-seconds', // RFC6131 'relational', // RFC3431 'regex', // draft-ietf-sieve-regex-01 'imapflags', // draft-melnikov-sieve-imapflags-06 @@ -447,8 +448,13 @@ class rcube_sieve_script case 'vacation': array_push($exts, 'vacation'); $action_script .= 'vacation'; - if (!empty($action['days'])) - $action_script .= " :days " . $action['days']; + if (isset($action['seconds'])) { + array_push($exts, 'vacation-seconds'); + $action_script .= " :seconds " . intval($action['seconds']); + } + else if (!empty($action['days'])) { + $action_script .= " :days " . intval($action['days']); + } if (!empty($action['addresses'])) $action_script .= " :addresses " . self::escape_string($action['addresses']); if (!empty($action['subject'])) @@ -477,8 +483,15 @@ class rcube_sieve_script } // requires - if (!empty($exts)) - $output = 'require ["' . implode('","', array_unique($exts)) . "\"];\n" . $output; + if (!empty($exts)) { + $exts = array_unique($exts); + + if (in_array('vacation-seconds', $exts) && ($key = array_search('vacation', $exts)) !== false) { + unset($exts[$key]); + } + + $output = 'require ["' . implode('","', $exts) . "\"];\n" . $output; + } if (!empty($this->prefix)) { $output = $this->prefix . "\n\n" . $output; @@ -816,24 +829,12 @@ class rcube_sieve_script for ($i=0, $len=count($tokens); $i<$len; $i++) { $tok = strtolower($tokens[$i]); - if ($tok == ':days') { - $vacation['days'] = $tokens[++$i]; - } - else if ($tok == ':subject') { - $vacation['subject'] = $tokens[++$i]; - } - else if ($tok == ':addresses') { - $vacation['addresses'] = $tokens[++$i]; - } - else if ($tok == ':handle') { - $vacation['handle'] = $tokens[++$i]; - } - else if ($tok == ':from') { - $vacation['from'] = $tokens[++$i]; - } - else if ($tok == ':mime') { + if ($tok == ':mime') { $vacation['mime'] = true; } + else if ($tok[0] == ':') { + $vacation[substr($tok, 1)] = $tokens[++$i]; + } } $result[] = $vacation; |