Prevents joins in merge.php.
[platal.git] / modules / xnetgrp / mail.inc.php
index 8edc98f..eadeb16 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2010 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -29,7 +29,7 @@ function get_all_redirects($membres, $mls, &$client)
 
     // TODO: add more filters to choose users
     if (!empty($membres)) {
-        $uf = new UserFilter(new UFC_Group($globals->asso('id')))
+        $uf = new UserFilter(new UFC_Group($globals->asso('id')));
         $tos = $uf->getUsers();
     }
 
@@ -56,18 +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 = str_ireplace(array('<cher>', '<nom>', '<prenom>'),
-                         array($cher, $nom, $pnom), $body);
-    $mailer->addTo($user);
+                         array($dear, $lastname, $firstname), $body);
+    $mailer->setTo($user);
     if ($replyto) {
         $mailer->addHeader('Reply-To', $replyto);
     }
@@ -100,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;
     }
 }