Skip to content

Commit 55d2f26

Browse files
authored
Merge pull request #18 from josaphatim/finalize-rfcs-for-actions
Added support for multiple RFCs for actions that have it
2 parents 2731ca3 + 9a5797d commit 55d2f26

File tree

7 files changed

+79
-16
lines changed

7 files changed

+79
-16
lines changed

src/Filters/Actions/BaseFlagFilterAction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ abstract class BaseFlagFilterAction extends BaseSieveAction
88

99
public function getRequiredParams()
1010
{
11-
return ['list-of-flags'];
11+
return ['flags'];
1212
}
1313

1414
protected function getParamTypes() {
1515
return [
1616
'variablename' => 'string',
17-
'list-of-flags' => 'string-list'
17+
'flags' => 'string-list'
1818
];
1919
}
2020

@@ -26,7 +26,7 @@ public function parse() {
2626
if (!empty($this->params['variablename'])) {
2727
$script .= "\"{$this->params['variablename']}\"";
2828
}
29-
$script .= " [" . implode(', ', array_map(function($flag) { return "\"$flag\""; }, $this->params['list-of-flags'])) . "];\n";
29+
$script .= " [" . implode(', ', array_map(function($flag) { return "\"$flag\""; }, $this->params['flags'])) . "];\n";
3030

3131
return $script;
3232
}

src/Filters/Actions/EncloseFilterAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ protected function getParamTypes() {
2626
* @return string
2727
*/
2828
public function parse() {
29-
return "enclose :subject \"{$this->subject}\" :headers [\"" . implode('", "', $this->headers) . "\"] \"{$this->content}\";\n";
29+
return "enclose :subject \"{$this->params['subject']}\" :headers [\"" . implode('", "', $this->params['headers']) . "\"] \"{$this->params['content']}\";\n";
3030
}
3131
}

src/Filters/Actions/ExtractTextFilterAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function parse() {
3333
if (!empty($this->params['first'])) {
3434
$script .= " :first {$this->params['first']}";
3535
}
36-
$script .= " \"{$this->params['varName']}\";\n";
36+
$script .= " \"{$this->params['varname']}\";\n";
3737
return $script;
3838
}
3939
}

src/Filters/Actions/FileIntoFilterAction.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,42 @@ protected function getRequiredParams()
1212
}
1313

1414
protected function getParamTypes() {
15-
return ['mailbox' => 'string'];
15+
return [
16+
'mailbox' => 'string',
17+
'flags' => 'string-list',
18+
'copy' => 'bool',
19+
'mailboxid' => 'string',
20+
'create' => 'bool',
21+
'specialuse' => 'string',
22+
];
1623
}
1724

1825
/**
1926
* @return string
2027
*/
2128
public function parse() {
22-
return "fileinto \"{$this->params['mailbox']}\";\n";
29+
$script = "fileinto";
30+
if (!empty($this->params['special-use-attr'])) {
31+
$this->require[] = 'special-use';
32+
$script .= " :specialuse \"{$this->params['specialuse']}\"";
33+
}
34+
if (!empty($this->params['create'])) {
35+
$this->require[] = 'mailbox';
36+
$script .= " :create";
37+
}
38+
if (!empty($this->params['mailboxid'])) {
39+
$this->require[] = 'mailboxid';
40+
$script .= " :mailboxid \"{$this->params['mailboxid']}\"";
41+
}
42+
if (!empty($this->params['copy'])) {
43+
$this->require[] = 'copy';
44+
$script .= " :copy";
45+
}
46+
if (!empty($this->params['flags'])) {
47+
$this->require[] = 'imap4flags';
48+
$script .= " :flags \"" . implode('", "', $this->params['flags']) . "\"";
49+
}
50+
$script .= " \"{$this->params['mailbox']}\";\n";
51+
return $script;
2352
}
2453
}

src/Filters/Actions/KeepFilterAction.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44

55
class KeepFilterAction extends BaseSieveAction
66
{
7-
/**
8-
* @return string
9-
*/
10-
public function parse() {
11-
return "keep;\n";
12-
}
7+
public $require = [];
138

149
public function getRequiredParams()
1510
{
@@ -18,6 +13,18 @@ public function getRequiredParams()
1813

1914
public function getParamTypes()
2015
{
21-
return [];
16+
return ['flags' => 'string-list'];
17+
}
18+
19+
/**
20+
* @return string
21+
*/
22+
public function parse() {
23+
$flags = '';
24+
if (!empty($this->params['flags'])) {
25+
$this->require[] = 'imap4flags';
26+
$flags = " :flags \"" . implode('", "', $this->params['flags']) . "\"";
27+
}
28+
return "keep{$flags};\n";
2229
}
2330
}

src/Filters/Actions/NotifyFilterAction.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ protected function getParamTypes() {
2020
'importance' => 'int',
2121
'options' => 'string-list',
2222
'message' => 'string',
23+
'fcc' => 'string',
2324
'method' => 'string',
2425
];
2526
}
@@ -38,6 +39,10 @@ public function parse() {
3839
if (!empty($this->params['options'])) {
3940
$script .= " :options [\"" . implode('", "', $this->params['options']) . "\"]";
4041
}
42+
if (!empty($this->params['fcc'])) {
43+
$this->require[] = 'fcc';
44+
$script .= " :fcc \"{$this->params['fcc']}\"";
45+
}
4146
if (!empty($this->params['message'])) {
4247
$script .= " :message \"{$this->params['message']}\"";
4348
}

src/Filters/Actions/RedirectFilterAction.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,41 @@
44

55
class RedirectFilterAction extends BaseSieveAction
66
{
7+
public $require = [];
8+
79
protected function getRequiredParams()
810
{
911
return ['address'];
1012
}
1113

1214
protected function getParamTypes() {
13-
return ['address' => 'string'];
15+
return [
16+
'address' => 'string',
17+
'copy' => 'bool',
18+
'notify' => 'string',
19+
'ret' => 'string',
20+
];
1421
}
1522

1623
/**
1724
* @return string
1825
*/
1926
public function parse() {
20-
return "redirect \"{$this->params['address']}\";\n";
27+
$script = "redirect";
28+
if (!empty($this->params['copy'])) {
29+
$this->require[] = 'copy';
30+
$script .= " :copy";
31+
}
32+
if (isset($this->params['notify']) || isset($this->params['notify'])) {
33+
$this->require[] = 'redirect-dsn';
34+
}
35+
if (!empty($this->params['notify'])) {
36+
$script .= " :notify \"{$this->params['notify']}\"";
37+
}
38+
if (!empty($this->params['ret'])) {
39+
$script .= " :ret \"{$this->params['ret']}\"";
40+
}
41+
$script .= " \"{$this->params['address']}\";\n";
42+
return $script;
2143
}
2244
}

0 commit comments

Comments
 (0)