From f798aa098a52e1fb7d9c8d0e91b072f74e677d6b Mon Sep 17 00:00:00 2001 From: Falko Timme <ft@falkotimme.com> Date: Wed, 12 Feb 2014 10:10:10 -0500 Subject: [PATCH] - Implemented FS#3310 - add support for multiple email addresses in send copy to field (patch). --- interface/lib/classes/tform.inc.php | 2 +- server/conf/sieve_filter.master | 4 +++- server/conf/sieve_filter_1.2.master | 4 +++- interface/web/mailuser/mail_user_spamfilter_edit.php | 3 ++- interface/web/mail/lib/lang/de_mail_user.lng | 1 + interface/web/mail/lib/lang/en_mail_user.lng | 1 + interface/web/mail/form/mail_user.tform.php | 2 +- interface/web/mailuser/lib/lang/en_mail_user_cc.lng | 2 ++ interface/web/mailuser/form/mail_user_cc.tform.php | 3 ++- server/plugins-available/maildrop_plugin.inc.php | 6 +++++- interface/web/mailuser/lib/lang/de_mail_user_cc.lng | 2 ++ server/plugins-available/maildeliver_plugin.inc.php | 7 +++++++ interface/web/mail/templates/mail_user_mailbox_edit.htm | 2 +- interface/web/mailuser/templates/mail_user_cc_edit.htm | 2 +- 14 files changed, 32 insertions(+), 9 deletions(-) diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php index 2604036..5fc0627 100644 --- a/interface/lib/classes/tform.inc.php +++ b/interface/lib/classes/tform.inc.php @@ -1302,7 +1302,7 @@ $perm = $app->db->quote($perm); $table = $app->db->quote($table); - if($_SESSION["s"]["user"]["typ"] == 'admin') { + if($_SESSION["s"]["user"]["typ"] == 'admin' || $_SESSION['s']['user']['mailuser_id'] > 0) { return '1'; } else { if ($table != ''){ diff --git a/interface/web/mail/form/mail_user.tform.php b/interface/web/mail/form/mail_user.tform.php index b6f8dfa..66bc8e3 100644 --- a/interface/web/mail/form/mail_user.tform.php +++ b/interface/web/mail/form/mail_user.tform.php @@ -160,7 +160,7 @@ 'type' => 'TOLOWER') ), 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}$/i', + 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}(,\s*\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,}$/i', 'errmsg'=> 'cc_error_isemail'), ), 'default' => '', diff --git a/interface/web/mail/lib/lang/de_mail_user.lng b/interface/web/mail/lib/lang/de_mail_user.lng index b5bdc59..cd8928a 100644 --- a/interface/web/mail/lib/lang/de_mail_user.lng +++ b/interface/web/mail/lib/lang/de_mail_user.lng @@ -48,4 +48,5 @@ $wb['password_mismatch_txt'] = 'Die Passwörter stimmen nicht überein.'; $wb['password_match_txt'] = 'Die Passwörter stimmen überein.'; $wb['email_error_isascii'] = 'Bitte verwenden Sie keine Umlaute im Passwort. Dies kann zu Problemen mit Ihrem E-Mail-Programm führen.'; +$wb['cc_note_txt'] = '(Mehrere E-Mail-Adressen mit Kommas trennen)'; ?> \ No newline at end of file diff --git a/interface/web/mail/lib/lang/en_mail_user.lng b/interface/web/mail/lib/lang/en_mail_user.lng index 81301db..7c80c76 100644 --- a/interface/web/mail/lib/lang/en_mail_user.lng +++ b/interface/web/mail/lib/lang/en_mail_user.lng @@ -48,4 +48,5 @@ $wb['password_mismatch_txt'] = 'The passwords do not match.'; $wb['password_match_txt'] = 'The passwords do match.'; $wb['email_error_isascii'] = 'Please do not use special unicode characters for your password. This could lead to problems with your mail client.'; +$wb['cc_note_txt'] = '(Separate multiple email addresses with commas)'; ?> diff --git a/interface/web/mail/templates/mail_user_mailbox_edit.htm b/interface/web/mail/templates/mail_user_mailbox_edit.htm index 0460bc6..f946502 100644 --- a/interface/web/mail/templates/mail_user_mailbox_edit.htm +++ b/interface/web/mail/templates/mail_user_mailbox_edit.htm @@ -42,7 +42,7 @@ </div> <div class="ctrlHolder"> <label for="name">{tmpl_var name='cc_txt'}</label> - <input name="cc" id="cc" value="{tmpl_var name='cc'}" size="30" maxlength="255" type="text" class="textInput" /> {tmpl_var name='name_optional_txt'} + <input name="cc" id="cc" value="{tmpl_var name='cc'}" size="30" maxlength="255" type="text" class="textInput" /> {tmpl_var name='name_optional_txt'} {tmpl_var name='cc_note_txt'} </div> <div class="ctrlHolder"> <label for="policy">{tmpl_var name='policy_txt'}</label> diff --git a/interface/web/mailuser/form/mail_user_cc.tform.php b/interface/web/mailuser/form/mail_user_cc.tform.php index 6458bb7..5f1d9ef 100644 --- a/interface/web/mailuser/form/mail_user_cc.tform.php +++ b/interface/web/mailuser/form/mail_user_cc.tform.php @@ -69,7 +69,8 @@ 'type' => 'TOLOWER') ), 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\w+\.[a-z\-]{2,10}){0,1}$/i', + //'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\w+\.[a-z\-]{2,10}){0,1}$/i', + 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}(,\s*\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,}$/i', 'errmsg'=> 'cc_error_isemail'), ), 'default' => '', diff --git a/interface/web/mailuser/lib/lang/de_mail_user_cc.lng b/interface/web/mailuser/lib/lang/de_mail_user_cc.lng index f39785b..cfb1ab3 100644 --- a/interface/web/mailuser/lib/lang/de_mail_user_cc.lng +++ b/interface/web/mailuser/lib/lang/de_mail_user_cc.lng @@ -4,4 +4,6 @@ $wb['email_txt'] = 'E-Mail'; $wb['cc_error_isemail'] = 'E-Mail Adresse ungültig im -Kopie senden an- Feld'; $wb['email_is_cc_error'] = 'E-Mail Adresse und '; +$wb['name_optional_txt'] = '(optional)'; +$wb['cc_note_txt'] = '(Mehrere E-Mail-Adressen mit Kommas trennen)'; ?> \ No newline at end of file diff --git a/interface/web/mailuser/lib/lang/en_mail_user_cc.lng b/interface/web/mailuser/lib/lang/en_mail_user_cc.lng index 0073c71..3437d50 100644 --- a/interface/web/mailuser/lib/lang/en_mail_user_cc.lng +++ b/interface/web/mailuser/lib/lang/en_mail_user_cc.lng @@ -4,4 +4,6 @@ $wb["email_txt"] = 'Email'; $wb["cc_error_isemail"] = 'Email address invalid in -Send copy to- field'; $wb["email_is_cc_error"] = 'Email address and send copy to address can not be the same.'; +$wb["name_optional_txt"] = '(Optional)'; +$wb['cc_note_txt'] = '(Separate multiple email addresses with commas)'; ?> \ No newline at end of file diff --git a/interface/web/mailuser/mail_user_spamfilter_edit.php b/interface/web/mailuser/mail_user_spamfilter_edit.php index dfc397d..3ea2aa5 100644 --- a/interface/web/mailuser/mail_user_spamfilter_edit.php +++ b/interface/web/mailuser/mail_user_spamfilter_edit.php @@ -51,7 +51,8 @@ class page_action extends tform_actions { function onShow() { - + global $app; + $this->id = $app->functions->intval($_SESSION['s']['user']['mailuser_id']); parent::onShow(); diff --git a/interface/web/mailuser/templates/mail_user_cc_edit.htm b/interface/web/mailuser/templates/mail_user_cc_edit.htm index ba715c8..3b82c46 100644 --- a/interface/web/mailuser/templates/mail_user_cc_edit.htm +++ b/interface/web/mailuser/templates/mail_user_cc_edit.htm @@ -11,7 +11,7 @@ </div> <div class="ctrlHolder"> <label for="name">{tmpl_var name='cc_txt'}</label> - <input name="cc" id="cc" value="{tmpl_var name='cc'}" size="30" maxlength="255" type="text" class="textInput" /> {tmpl_var name='name_optional_txt'} + <input name="cc" id="cc" value="{tmpl_var name='cc'}" size="30" maxlength="255" type="text" class="textInput" /> {tmpl_var name='name_optional_txt'} {tmpl_var name='cc_note_txt'} </div> </fieldset> diff --git a/server/conf/sieve_filter.master b/server/conf/sieve_filter.master index 09d7fa9..e161a9f 100644 --- a/server/conf/sieve_filter.master +++ b/server/conf/sieve_filter.master @@ -2,7 +2,9 @@ <tmpl_if name="cc"> # Send a copy of email to -redirect "<tmpl_var name='cc'>"; +<tmpl_loop name="ccloop"> +redirect "<tmpl_var name='address'>"; +</tmpl_loop> </tmpl_if> <tmpl_if name="move_junk" op="==" value="y"> diff --git a/server/conf/sieve_filter_1.2.master b/server/conf/sieve_filter_1.2.master index a88dc2d..08473e6 100644 --- a/server/conf/sieve_filter_1.2.master +++ b/server/conf/sieve_filter_1.2.master @@ -2,7 +2,9 @@ <tmpl_if name="cc"> # Send a copy of email to -redirect "<tmpl_var name='cc'>"; +<tmpl_loop name="ccloop"> +redirect "<tmpl_var name='address'>"; +</tmpl_loop> </tmpl_if> <tmpl_if name="move_junk" op="==" value="y"> diff --git a/server/plugins-available/maildeliver_plugin.inc.php b/server/plugins-available/maildeliver_plugin.inc.php index 16e3e73..e3799d7 100644 --- a/server/plugins-available/maildeliver_plugin.inc.php +++ b/server/plugins-available/maildeliver_plugin.inc.php @@ -120,7 +120,14 @@ $tpl->newTemplate($filter_file_template); // cc Field + $tmp_mails_arr = explode(',',$data["new"]["cc"]); + $tmp_addresses_arr = array(); + foreach($tmp_mails_arr as $address) { + if(trim($address) != '') $tmp_addresses_arr[] = array('address' => trim($address)); + } + $tpl->setVar('cc', $data["new"]["cc"]); + $tpl->setLoop('ccloop', $tmp_addresses_arr); // Custom filters $tpl->setVar('custom_mailfilter', $data["new"]["custom_mailfilter"]); diff --git a/server/plugins-available/maildrop_plugin.inc.php b/server/plugins-available/maildrop_plugin.inc.php index 73bace8..37b0306 100644 --- a/server/plugins-available/maildrop_plugin.inc.php +++ b/server/plugins-available/maildrop_plugin.inc.php @@ -192,7 +192,11 @@ $mailfilter_content = ''; if($data["new"]["cc"] != '') { - $mailfilter_content .= "cc \"!".$data["new"]["cc"]."\"\n"; + $tmp_mails_arr = explode(',',$data["new"]["cc"]); + foreach($tmp_mails_arr as $address) { + if(trim($address) != '') $mailfilter_content .= "cc \"!".trim($address)."\"\n"; + } + //$mailfilter_content .= "cc \"!".$data["new"]["cc"]."\"\n"; $app->log("Added CC address ".$data["new"]["cc"].' to mailfilter file.', LOGLEVEL_DEBUG); } -- Gitblit v1.9.1