Merge commit 'origin/master' into account
[platal.git] / include / massmailer.inc.php
index 939c7fb..a9269bd 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   *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
+// {{{ class MailNotFound
+
+class MailNotFound extends Exception {
+}
+
+// }}}
+
 // {{{ class MassMailer
 
 abstract class MassMailer
@@ -183,8 +190,7 @@ abstract class MassMailer
     protected function getAllRecipients()
     {
         global $globals;
-        return  "SELECT  a.uid, a.hruid, a.display_name, a.full_name, a.email_format,
-                         ni.hash AS hash
+        return  "SELECT  a.uid
                    FROM  {$this->_subscriptionTable}  AS ni
              INNER JOIN  accounts AS a ON (ni.user_id = a.uid)
               LEFT JOIN  email_options AS eo ON (eo.uid = a.uid)
@@ -199,12 +205,11 @@ abstract class MassMailer
         $this->setSent();
         $query = XDB::format($this->getAllRecipients(), $this->id()) . ' LIMIT 60';
         while (true) {
-            $res = XDB::iterRow($query);
-            if (!$res->total()) {
+            $users = User::getBulkUsersWithUIDs(XDB::fetchColumn($query));
+            if (count($users) == 0) {
                 return;
             }
-            while ($infos = $res->next()) {
-                $user = User::getSilentWithValues(null, $infos);
+            foreach ($users as $user) {
                 $sent[] = XDB::format('user_id = {?}', $user->id());
                 $this->sendTo($user, $hash);
             }