diff --git a/src/Filters/Actions/BaseFlagFilterAction.php b/src/Filters/Actions/BaseFlagFilterAction.php index 1cea89b..8f83218 100644 --- a/src/Filters/Actions/BaseFlagFilterAction.php +++ b/src/Filters/Actions/BaseFlagFilterAction.php @@ -8,13 +8,13 @@ abstract class BaseFlagFilterAction extends BaseSieveAction public function getRequiredParams() { - return ['list-of-flags']; + return ['flags']; } protected function getParamTypes() { return [ 'variablename' => 'string', - 'list-of-flags' => 'string-list' + 'flags' => 'string-list' ]; } @@ -26,7 +26,7 @@ public function parse() { if (!empty($this->params['variablename'])) { $script .= "\"{$this->params['variablename']}\""; } - $script .= " [" . implode(', ', array_map(function($flag) { return "\"$flag\""; }, $this->params['list-of-flags'])) . "];\n"; + $script .= " [" . implode(', ', array_map(function($flag) { return "\"$flag\""; }, $this->params['flags'])) . "];\n"; return $script; } diff --git a/src/Filters/Actions/EncloseFilterAction.php b/src/Filters/Actions/EncloseFilterAction.php index 3b22fb6..2d3ed48 100644 --- a/src/Filters/Actions/EncloseFilterAction.php +++ b/src/Filters/Actions/EncloseFilterAction.php @@ -26,6 +26,6 @@ protected function getParamTypes() { * @return string */ public function parse() { - return "enclose :subject \"{$this->subject}\" :headers [\"" . implode('", "', $this->headers) . "\"] \"{$this->content}\";\n"; + return "enclose :subject \"{$this->params['subject']}\" :headers [\"" . implode('", "', $this->params['headers']) . "\"] \"{$this->params['content']}\";\n"; } } \ No newline at end of file diff --git a/src/Filters/Actions/ExtractTextFilterAction.php b/src/Filters/Actions/ExtractTextFilterAction.php index 4239e9d..8ab3ad2 100644 --- a/src/Filters/Actions/ExtractTextFilterAction.php +++ b/src/Filters/Actions/ExtractTextFilterAction.php @@ -33,7 +33,7 @@ public function parse() { if (!empty($this->params['first'])) { $script .= " :first {$this->params['first']}"; } - $script .= " \"{$this->params['varName']}\";\n"; + $script .= " \"{$this->params['varname']}\";\n"; return $script; } } \ No newline at end of file diff --git a/src/Filters/Actions/FileIntoFilterAction.php b/src/Filters/Actions/FileIntoFilterAction.php index 4b5b6ec..a76123e 100644 --- a/src/Filters/Actions/FileIntoFilterAction.php +++ b/src/Filters/Actions/FileIntoFilterAction.php @@ -12,13 +12,42 @@ protected function getRequiredParams() } protected function getParamTypes() { - return ['mailbox' => 'string']; + return [ + 'mailbox' => 'string', + 'flags' => 'string-list', + 'copy' => 'bool', + 'mailboxid' => 'string', + 'create' => 'bool', + 'specialuse' => 'string', + ]; } /** * @return string */ public function parse() { - return "fileinto \"{$this->params['mailbox']}\";\n"; + $script = "fileinto"; + if (!empty($this->params['special-use-attr'])) { + $this->require[] = 'special-use'; + $script .= " :specialuse \"{$this->params['specialuse']}\""; + } + if (!empty($this->params['create'])) { + $this->require[] = 'mailbox'; + $script .= " :create"; + } + if (!empty($this->params['mailboxid'])) { + $this->require[] = 'mailboxid'; + $script .= " :mailboxid \"{$this->params['mailboxid']}\""; + } + if (!empty($this->params['copy'])) { + $this->require[] = 'copy'; + $script .= " :copy"; + } + if (!empty($this->params['flags'])) { + $this->require[] = 'imap4flags'; + $script .= " :flags \"" . implode('", "', $this->params['flags']) . "\""; + } + $script .= " \"{$this->params['mailbox']}\";\n"; + return $script; } } \ No newline at end of file diff --git a/src/Filters/Actions/KeepFilterAction.php b/src/Filters/Actions/KeepFilterAction.php index 51ee508..ba556fb 100644 --- a/src/Filters/Actions/KeepFilterAction.php +++ b/src/Filters/Actions/KeepFilterAction.php @@ -4,12 +4,7 @@ class KeepFilterAction extends BaseSieveAction { - /** - * @return string - */ - public function parse() { - return "keep;\n"; - } + public $require = []; public function getRequiredParams() { @@ -18,6 +13,18 @@ public function getRequiredParams() public function getParamTypes() { - return []; + return ['flags' => 'string-list']; + } + + /** + * @return string + */ + public function parse() { + $flags = ''; + if (!empty($this->params['flags'])) { + $this->require[] = 'imap4flags'; + $flags = " :flags \"" . implode('", "', $this->params['flags']) . "\""; + } + return "keep{$flags};\n"; } } \ No newline at end of file diff --git a/src/Filters/Actions/NotifyFilterAction.php b/src/Filters/Actions/NotifyFilterAction.php index de3f1d3..66579e3 100644 --- a/src/Filters/Actions/NotifyFilterAction.php +++ b/src/Filters/Actions/NotifyFilterAction.php @@ -20,6 +20,7 @@ protected function getParamTypes() { 'importance' => 'int', 'options' => 'string-list', 'message' => 'string', + 'fcc' => 'string', 'method' => 'string', ]; } @@ -38,6 +39,10 @@ public function parse() { if (!empty($this->params['options'])) { $script .= " :options [\"" . implode('", "', $this->params['options']) . "\"]"; } + if (!empty($this->params['fcc'])) { + $this->require[] = 'fcc'; + $script .= " :fcc \"{$this->params['fcc']}\""; + } if (!empty($this->params['message'])) { $script .= " :message \"{$this->params['message']}\""; } diff --git a/src/Filters/Actions/RedirectFilterAction.php b/src/Filters/Actions/RedirectFilterAction.php index de0de50..1940e8f 100644 --- a/src/Filters/Actions/RedirectFilterAction.php +++ b/src/Filters/Actions/RedirectFilterAction.php @@ -4,19 +4,41 @@ class RedirectFilterAction extends BaseSieveAction { + public $require = []; + protected function getRequiredParams() { return ['address']; } protected function getParamTypes() { - return ['address' => 'string']; + return [ + 'address' => 'string', + 'copy' => 'bool', + 'notify' => 'string', + 'ret' => 'string', + ]; } /** * @return string */ public function parse() { - return "redirect \"{$this->params['address']}\";\n"; + $script = "redirect"; + if (!empty($this->params['copy'])) { + $this->require[] = 'copy'; + $script .= " :copy"; + } + if (isset($this->params['notify']) || isset($this->params['notify'])) { + $this->require[] = 'redirect-dsn'; + } + if (!empty($this->params['notify'])) { + $script .= " :notify \"{$this->params['notify']}\""; + } + if (!empty($this->params['ret'])) { + $script .= " :ret \"{$this->params['ret']}\""; + } + $script .= " \"{$this->params['address']}\";\n"; + return $script; } } \ No newline at end of file