From 552607f5affe961d6c771f38a8eba32044f710b1 Mon Sep 17 00:00:00 2001 From: alec Date: Thu, 10 Feb 2011 08:13:13 +0000 Subject: - Added setflag/addflag/removeflag support (#1487449) git-svn-id: https://svn.roundcube.net/trunk@4522 208e9e7b-5314-0410-a742-e7e81cd9613c --- plugins/managesieve/Changelog | 1 + plugins/managesieve/lib/rcube_sieve.php | 27 +++++- plugins/managesieve/localization/en_US.inc | 8 ++ plugins/managesieve/localization/pl_PL.inc | 8 ++ plugins/managesieve/managesieve.php | 50 ++++++++++- .../skins/default/templates/filteredit.html | 98 +++++++++------------- 6 files changed, 133 insertions(+), 59 deletions(-) (limited to 'plugins') diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index 1a8d3df61..5f7672da3 100644 --- a/plugins/managesieve/Changelog +++ b/plugins/managesieve/Changelog @@ -1,5 +1,6 @@ - Fix STARTTLS for timsieved < 2.3.10 - Added :regex and :matches support (#1487746) +- Added setflag/addflag/removeflag support (#1487449) * version 3.0 [2011-02-01] ----------------------------------------------------------- diff --git a/plugins/managesieve/lib/rcube_sieve.php b/plugins/managesieve/lib/rcube_sieve.php index 1ed0da9ab..be9c75496 100644 --- a/plugins/managesieve/lib/rcube_sieve.php +++ b/plugins/managesieve/lib/rcube_sieve.php @@ -406,7 +406,9 @@ class rcube_sieve_script 'vacation', // RFC5230 'relational', // RFC3431 'regex', // draft-ietf-sieve-regex-01 - // TODO: (most wanted first) body, imapflags, notify + 'imapflags', + 'imap4flags', // RFC5232 + // TODO: (most wanted first) body, notify ); /** @@ -569,6 +571,7 @@ class rcube_sieve_script // action(s) foreach ($rule['actions'] as $action) { switch ($action['type']) { + case 'fileinto': array_push($exts, 'fileinto'); $script .= "\tfileinto "; @@ -578,6 +581,7 @@ class rcube_sieve_script } $script .= self::escape_string($action['target']) . ";\n"; break; + case 'redirect': $script .= "\tredirect "; if ($action['copy']) { @@ -586,17 +590,29 @@ class rcube_sieve_script } $script .= self::escape_string($action['target']) . ";\n"; break; + case 'reject': case 'ereject': array_push($exts, $action['type']); $script .= "\t".$action['type']." " . self::escape_string($action['target']) . ";\n"; break; + + case 'addflag': + case 'setflag': + case 'removeflag': + $imapflags = strtolower($action['mode']) == 'imap4flags' ? 'imap4flags' : 'imapflags'; + array_push($exts, $imapflags); + $script .= "\t".$action['type']." " + . self::escape_string($action['target']) . ";\n"; + break; + case 'keep': case 'discard': case 'stop': $script .= "\t" . $action['type'] .";\n"; break; + case 'vacation': array_push($exts, 'vacation'); $script .= "\tvacation"; @@ -879,6 +895,15 @@ class rcube_sieve_script $result[] = $vacation; break; + + case 'setflag': + case 'addflag': + case 'removeflag': + $result[] = array('type' => $token, + // Flags list: last token (skip optional variable) + 'target' => $tokens[count($tokens)-1] + ); + break; } } diff --git a/plugins/managesieve/localization/en_US.inc b/plugins/managesieve/localization/en_US.inc index 3da594f8a..48a0cbbe9 100644 --- a/plugins/managesieve/localization/en_US.inc +++ b/plugins/managesieve/localization/en_US.inc @@ -68,6 +68,14 @@ $labels['valueislessthan'] = 'value is less than'; $labels['valueislessthanequal'] = 'value is less than or equal to'; $labels['valueequals'] = 'value is equal to'; $labels['valuenotequals'] = 'value does not equal'; +$labels['setflags'] = 'Set flags to the message'; +$labels['addflags'] = 'Add flags to the message'; +$labels['removeflags'] = 'Remove flags from the message'; +$labels['flagread'] = 'Read'; +$labels['flagdeleted'] = 'Deleted'; +$labels['flaganswered'] = 'Answered'; +$labels['flagflagged'] = 'Flagged'; +$labels['flagdraft'] = 'Draft'; $messages = array(); $messages['filterunknownerror'] = 'Unknown server error'; diff --git a/plugins/managesieve/localization/pl_PL.inc b/plugins/managesieve/localization/pl_PL.inc index f988d8f0b..fa09b39eb 100644 --- a/plugins/managesieve/localization/pl_PL.inc +++ b/plugins/managesieve/localization/pl_PL.inc @@ -69,6 +69,14 @@ $labels['valueislessthan'] = 'wartość jest mniejsza od'; $labels['valueislessthanequal'] = 'wartość jest równa lub mniejsza od'; $labels['valueequals'] = 'wartość jest równa'; $labels['valuenotequals'] = 'wartość jest różna od'; +$labels['setflags'] = 'Ustaw flagi wiadomości'; +$labels['addflags'] = 'Dodaj flagi do wiadomości'; +$labels['removeflags'] = 'Usuń flagi wiadomości'; +$labels['flagread'] = 'Przeczytana'; +$labels['flagdeleted'] = 'Usunięta'; +$labels['flaganswered'] = 'Z odpowiedzią'; +$labels['flagflagged'] = 'Oflagowana'; +$labels['flagdraft'] = 'Szkic'; $messages = array(); $messages['filterunknownerror'] = 'Nieznany błąd serwera'; diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index d986141cd..9b3aac18f 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -360,6 +360,7 @@ class managesieve extends rcube_plugin $reasons = $_POST['_action_reason']; $addresses = $_POST['_action_addresses']; $days = $_POST['_action_days']; + $flags = $_POST['_action_flags']; // we need a "hack" for radiobuttons foreach ($sizeitems as $item) @@ -373,12 +374,13 @@ class managesieve extends rcube_plugin if ($name == '') $this->errors['name'] = $this->gettext('cannotbeempty'); - else + else { foreach($this->script as $idx => $rule) if($rule['name'] == $name && $idx != $fid) { $this->errors['name'] = $this->gettext('ruleexist'); break; } + } $i = 0; // rules @@ -481,6 +483,7 @@ class managesieve extends rcube_plugin $target = $this->strip_value($act_targets[$idx]); switch ($type) { + case 'fileinto': case 'fileinto_copy': $mailbox = $this->strip_value($mailboxes[$idx]); @@ -490,6 +493,7 @@ class managesieve extends rcube_plugin $this->form['actions'][$i]['copy'] = true; } break; + case 'reject': case 'ereject': $target = $this->strip_value($area_targets[$idx]); @@ -498,6 +502,7 @@ class managesieve extends rcube_plugin // if ($target == '') // $this->errors['actions'][$i]['targetarea'] = $this->gettext('cannotbeempty'); break; + case 'redirect': case 'redirect_copy': $this->form['actions'][$i]['target'] = $target; @@ -512,6 +517,25 @@ class managesieve extends rcube_plugin $this->form['actions'][$i]['copy'] = true; } break; + + case 'addflag': + case 'setflag': + case 'removeflag': + $_target = array(); + if (empty($flags[$idx])) { + $this->errors['actions'][$i]['target'] = $this->gettext('noflagset'); + } + else { + foreach ($flags[$idx] as $flag) { + $_target[] = $this->strip_value($flag); + } + } + $this->form['actions'][$i]['target'] = $_target; + if (in_array('imap4flags', $this->exts)) { + $this->form['actions'][$i]['mode'] = 'imap4flags'; + } + break; + case 'vacation': $reason = $this->strip_value($reasons[$idx]); $this->form['actions'][$i]['reason'] = str_replace("\r\n", "\n", $reason); @@ -995,6 +1019,11 @@ class managesieve extends rcube_plugin if (in_array('vacation', $this->exts)) $select_action->add(Q($this->gettext('messagereply')), 'vacation'); $select_action->add(Q($this->gettext('messagedelete')), 'discard'); + if (in_array('imapflags', $this->exts) || in_array('imap4flags', $this->exts)) { + $select_action->add(Q($this->gettext('setflags')), 'setflag'); + $select_action->add(Q($this->gettext('addflags')), 'addflag'); + $select_action->add(Q($this->gettext('removeflags')), 'removeflag'); + } $select_action->add(Q($this->gettext('rulestop')), 'stop'); $select_type = $action['type']; @@ -1034,6 +1063,25 @@ class managesieve extends rcube_plugin . $this->error_class($id, 'action', 'days', 'action_days') .' />'; $out .= ''; + // flags + $flags = array( + 'read' => '\\\\Seen', + 'answered' => '\\\\Answered', + 'flagged' => '\\\\Flagged', + 'deleted' => '\\\\Deleted', + 'draft' => '\\\\Draft', + ); + $action['target'] = (array)$action['target']; + $out .= '
error_class($id, 'action', 'flags', 'action_flags') . '>'; + foreach ($flags as $fidx => $flag) { + $out .= '' + . Q($this->gettext('flag'.$fidx)) .' '; + } + $out .= '
'; + // mailbox select $out .= '