And so on.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 12 Feb 2009 21:54:31 +0000 (22:54 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 12 Feb 2009 21:54:31 +0000 (22:54 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/massmailer.inc.php
modules/axletter/axletter.inc.php

index 95748f6..decda36 100644 (file)
@@ -190,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)
@@ -206,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);
             }
index 385365e..7cf486e 100644 (file)
@@ -96,26 +96,6 @@ class AXLetter extends MassMailer
                        WHERE  id={?}", $this->_id);
     }
 
-    protected function getAllRecipients()
-    {
-        global $globals;
-        return "SELECT  ni.user_id, IF(ni.user_id = 0, NULL, u.hruid) AS hruid,
-                        IF(ni.user_id = 0, ni.email, CONCAT(a.alias, '@{$globals->mail->domain}')) AS alias,
-                        IF(ni.user_id = 0, ni.prenom, u.prenom) AS prenom,
-                        IF(ni.user_id = 0, ni.nom, IF(u.nom_usage='', u.nom, u.nom_usage)) AS nom,
-                        FIND_IN_SET('femme', IF(ni.user_id = 0, ni.flag, u.flags)) AS sexe,
-                        IF(ni.user_id = 0, 'html', q.core_mail_fmt) AS pref,
-                        IF(ni.user_id = 0, ni.hash, 0) AS hash
-                  FROM  axletter_ins  AS ni
-             LEFT JOIN  auth_user_md5   AS u  USING(user_id)
-             LEFT JOIN  auth_user_quick AS q  ON(q.user_id = u.user_id)
-             LEFT JOIN  aliases         AS a  ON(u.user_id=a.id AND FIND_IN_SET('bestalias',a.flags))
-             LEFT JOIN  emails          AS e  ON(e.uid=u.user_id AND e.flags='active')
-                 WHERE  ni.last < {?} AND {$this->subscriptionWhere()}
-                        AND (e.email IS NOT NULL OR FIND_IN_SET('googleapps', u.mail_storage) OR ni.user_id = 0)
-              GROUP BY  u.user_id";
-    }
-
     static public function subscriptionState($uid = null)
     {
         $user = is_null($uid) ? S::v('uid') : $uid;