* Mail: Add set flags action into mail filters

This commit is contained in:
Hadi Nategh 2021-10-15 17:23:36 +02:00
parent 33fcb4e657
commit 0dd215d340
3 changed files with 24 additions and 0 deletions

View File

@ -392,6 +392,9 @@ class Script
if (preg_match("/discard/i",$rule['action'])) { if (preg_match("/discard/i",$rule['action'])) {
$newruletext .= "discard;"; $newruletext .= "discard;";
} }
if (preg_match("/flags/i",$rule['action'])) {
$newruletext .= "addflag \"".$rule['action_arg']."\";";
}
if ($rule['keep']) $newruletext .= "\n\tkeep;"; if ($rule['keep']) $newruletext .= "\n\tkeep;";
if (!$rule['unconditional']) $newruletext .= "\n}"; if (!$rule['unconditional']) $newruletext .= "\n}";
@ -556,6 +559,8 @@ class Script
if ($this->extensions['body']) $newscripthead .= ",\"body\""; if ($this->extensions['body']) $newscripthead .= ",\"body\"";
if ($this->extensions['date']) $newscripthead .= ",\"date\""; if ($this->extensions['date']) $newscripthead .= ",\"date\"";
if ($this->extensions['relational']) $newscripthead .= ",\"relational\""; if ($this->extensions['relational']) $newscripthead .= ",\"relational\"";
if ($this->extensions['variables']) $newscripthead .= ",\"variables\"";
if ($this->extensions['imap4flags']) $newscripthead .= ",\"imap4flags\"";
if ($this->emailNotification && $this->emailNotification['status'] == 'on') $newscripthead .= ',"'.($this->extensions['enotify']?'e':'').'notify"'.($this->extensions['variables']?',"variables"':''); // Added email notifications if ($this->emailNotification && $this->emailNotification['status'] == 'on') $newscripthead .= ',"'.($this->extensions['enotify']?'e':'').'notify"'.($this->extensions['variables']?',"variables"':''); // Added email notifications
$newscripthead .= "];\n\n"; $newscripthead .= "];\n\n";
@ -566,6 +571,9 @@ class Script
{ {
$newscripthead .= "require [\"vacation\""; $newscripthead .= "require [\"vacation\"";
if ($this->extensions['regex'] && $regexused) $newscripthead .= ",\"regex\""; if ($this->extensions['regex'] && $regexused) $newscripthead .= ",\"regex\"";
if ($this->extensions['date']) $newscripthead .= ",\"date\"";
if ($this->extensions['relational']) $newscripthead .= ",\"relational\"";
$closeRequired=true; $closeRequired=true;
} }
if ($this->emailNotification && $this->emailNotification['status'] == 'on') if ($this->emailNotification && $this->emailNotification['status'] == 'on')

View File

@ -252,6 +252,10 @@ class mail_sieve
break; break;
case 'reject': case 'reject':
$content['action_reject_text'] = $rules['action_arg']; $content['action_reject_text'] = $rules['action_arg'];
break;
case 'flags':
$content['action_flags_list'] = explode(' ', $rules['action_arg']);
break;
} }
$content['anyof'] = $rules['anyof'] != 0?1:0; $content['anyof'] = $rules['anyof'] != 0?1:0;
} }
@ -302,10 +306,15 @@ class mail_sieve
break; break;
case 'reject': case 'reject':
$newRule['action_arg'] = $content['action_reject_text']; $newRule['action_arg'] = $content['action_reject_text'];
break;
case 'flags':
$newRule['action_arg'] = implode(' ', $content['action_flags_list']);
break;
} }
unset($newRule['action_folder_text']); unset($newRule['action_folder_text']);
unset($newRule['action_address_text']); unset($newRule['action_address_text']);
unset($newRule['action_reject_text']); unset($newRule['action_reject_text']);
unset($newRule['action_flags_list']);
$newRule['flg'] = 0 ; $newRule['flg'] = 0 ;
if( $newRule['continue'] ) { $newRule['flg'] += 1; } if( $newRule['continue'] ) { $newRule['flg'] += 1; }

View File

@ -98,6 +98,13 @@
<radio label="Discard message" id="action" options="discard"/> <radio label="Discard message" id="action" options="discard"/>
<description/> <description/>
</row> </row>
<row>
<radio label="set flags" id="action" options="flags"/>
<taglist id="action_flags_list">
<option value="\\Flagged">Flagged</option>
<option value="\\Deleted">Deleted</option>
</taglist>
</row>
<row> <row>
<description value="(*) Please consider, forward to multiple addresses will not work if number of addresses exceeds the Limit. For most mail Servers the limit is 4 by default, please contact your mail server administrator for further info."/> <description value="(*) Please consider, forward to multiple addresses will not work if number of addresses exceeds the Limit. For most mail Servers the limit is 4 by default, please contact your mail server administrator for further info."/>
</row> </row>