X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fmassmailer.inc.php;h=a6dc702e79f3d56b22903a2c4ecca70bca8bb9e6;hb=23ba40c466e05d369cd9e2a96107f38e309b767a;hp=939c7fb0015b5d7ffc879288b6632c38a05c44f4;hpb=be638e733bce413df4324d985297d9a4d94dcbca;p=platal.git diff --git a/include/massmailer.inc.php b/include/massmailer.inc.php index 939c7fb..a6dc702 100644 --- a/include/massmailer.inc.php +++ b/include/massmailer.inc.php @@ -1,6 +1,6 @@ _subscriptionTable} - WHERE user_id = {?}", $user->id()); + WHERE uid = {?}", $user->id()); } if (is_null($hash)) { $hash = $this->createHash(array($user->displayName(), $user->fullName(), @@ -166,7 +173,7 @@ abstract class MassMailer rand(), "X.org rulez")); XDB::execute("UPDATE {$this->_subscriptionTable} as ni SET ni.hash = {?} - WHERE ni.user_id != {?}", + WHERE ni.uid != {?}", $hash, $user->id()); } @@ -183,10 +190,9 @@ 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) + INNER JOIN accounts AS a ON (ni.uid = a.uid) LEFT JOIN email_options AS eo ON (eo.uid = a.uid) LEFT JOIN emails AS e ON (e.uid = a.uid AND e.flags='active') WHERE ni.last < {?} AND ({$this->subscriptionWhere()}) AND @@ -198,15 +204,17 @@ abstract class MassMailer { $this->setSent(); $query = XDB::format($this->getAllRecipients(), $this->id()) . ' LIMIT 60'; + $emailsCount = 0; + while (true) { - $res = XDB::iterRow($query); - if (!$res->total()) { - return; + $users = User::getBulkUsersWithUIDs(XDB::fetchColumn($query)); + if (count($users) == 0) { + return $emailsCount; } - while ($infos = $res->next()) { - $user = User::getSilentWithValues(null, $infos); - $sent[] = XDB::format('user_id = {?}', $user->id()); + foreach ($users as $user) { + $sent[] = XDB::format('uid = {?}', $user->id()); $this->sendTo($user, $hash); + ++$emailsCount; } XDB::execute("UPDATE {$this->_subscriptionTable} SET last = {?} @@ -214,6 +222,7 @@ abstract class MassMailer sleep(60); } + return $emailsCount; } abstract protected function assignData(&$smarty);