From 2af7775aa21ca20f422fe1ab2f9fef931668c182 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 15 Oct 2021 17:23:36 +0200 Subject: [PATCH] * Mail: Add set flags action into mail filters --- api/src/Mail/Script.php | 8 ++++++++ mail/inc/class.mail_sieve.inc.php | 9 +++++++++ mail/templates/default/sieve.edit.xet | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/api/src/Mail/Script.php b/api/src/Mail/Script.php index b113c17406..a70d00e9d4 100644 --- a/api/src/Mail/Script.php +++ b/api/src/Mail/Script.php @@ -392,6 +392,9 @@ class Script if (preg_match("/discard/i",$rule['action'])) { $newruletext .= "discard;"; } + if (preg_match("/flags/i",$rule['action'])) { + $newruletext .= "addflag \"".$rule['action_arg']."\";"; + } if ($rule['keep']) $newruletext .= "\n\tkeep;"; if (!$rule['unconditional']) $newruletext .= "\n}"; @@ -556,6 +559,8 @@ class Script if ($this->extensions['body']) $newscripthead .= ",\"body\""; if ($this->extensions['date']) $newscripthead .= ",\"date\""; 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 $newscripthead .= "];\n\n"; @@ -566,6 +571,9 @@ class Script { $newscripthead .= "require [\"vacation\""; if ($this->extensions['regex'] && $regexused) $newscripthead .= ",\"regex\""; + if ($this->extensions['date']) $newscripthead .= ",\"date\""; + if ($this->extensions['relational']) $newscripthead .= ",\"relational\""; + $closeRequired=true; } if ($this->emailNotification && $this->emailNotification['status'] == 'on') diff --git a/mail/inc/class.mail_sieve.inc.php b/mail/inc/class.mail_sieve.inc.php index 2a9896541e..ecd8d37f8f 100644 --- a/mail/inc/class.mail_sieve.inc.php +++ b/mail/inc/class.mail_sieve.inc.php @@ -252,6 +252,10 @@ class mail_sieve break; case 'reject': $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; } @@ -302,10 +306,15 @@ class mail_sieve break; case 'reject': $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_address_text']); unset($newRule['action_reject_text']); + unset($newRule['action_flags_list']); $newRule['flg'] = 0 ; if( $newRule['continue'] ) { $newRule['flg'] += 1; } diff --git a/mail/templates/default/sieve.edit.xet b/mail/templates/default/sieve.edit.xet index 44a9d2b194..80328aecda 100644 --- a/mail/templates/default/sieve.edit.xet +++ b/mail/templates/default/sieve.edit.xet @@ -98,6 +98,13 @@ + + + + + + +