X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetgrp%2Fmail.inc.php;h=eadeb167a0eb80c4cc27e02333d67cd8ccb4fe4f;hb=4810af1eeced1975f74f2231cd119978561dd572;hp=2b66a8e08f0f090453a1a76a8a32f18760ad67e6;hpb=22c8c0c3bed472a0ba9043e34bed52f104ee9f56;p=platal.git diff --git a/modules/xnetgrp/mail.inc.php b/modules/xnetgrp/mail.inc.php index 2b66a8e..eadeb16 100644 --- a/modules/xnetgrp/mail.inc.php +++ b/modules/xnetgrp/mail.inc.php @@ -1,6 +1,6 @@ asso('id'))) + $uf = new UserFilter(new UFC_Group($globals->asso('id'))); $tos = $uf->getUsers(); } @@ -56,21 +56,18 @@ function get_all_redirects($membres, $mls, &$client) function _send_xnet_mail($user, $body, $wiki, $mailer, $replyto = null) { if ($user instanceof PlUser) { - $cher = $user->isFemale() ? 'Chère' : 'Cher'; - $nom = $user->displayName(); - $pnom = ''; + $dear = $user->isFemale() ? 'Chère' : 'Cher'; + $lastname = $user->lastName(); + $firstname = $user->firstName(); } else { - $cher = 'Cher(e)'; - $nom = $user; - $pnom = ''; + $dear = 'Cher(e)'; + $lastname = ''; + $firstname = $user; } - $text = $body; - $text = preg_replace('!!i', $cher, $text); - $text = preg_replace('!!i', $nom, $text); - $text = preg_replace('!!i', $pnom, $text); - - $mailer->addTo($user); + $text = str_ireplace(array('', '', ''), + array($dear, $lastname, $firstname), $body); + $mailer->setTo($user); if ($replyto) { $mailer->addHeader('Reply-To', $replyto); } @@ -103,11 +100,11 @@ function send_xnet_mails($from, $sujet, $body, $wiki, $tos, $replyto = null, $up } else { $email = $user; } - if ($sent[$email]) { - continue; + + if (!isset($sent[$email])) { + _send_xnet_mail($user, $body, $wiki, $mailer, $replyto); + $sent[$email] = true; } - _send_xnet_mail($user, $body, $wiki, $mailer, $replyto); - $sent[$email] = true; } }