X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fmassmailer.inc.php;h=c866f90f7310443535bb80a9b9be267b1a40f095;hb=ddc4c64239397960c7c95aad9153009b986038bb;hp=95748f6714863a140ad0121c62548562bc774032;hpb=6d1747b3dbcf944c995dc2d87e8561c7a66f3aa6;p=platal.git diff --git a/include/massmailer.inc.php b/include/massmailer.inc.php index 95748f6..c866f90 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(), @@ -173,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()); } @@ -190,12 +190,13 @@ 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') + LEFT JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms)) + LEFT JOIN profile_display AS pd ON (ap.pid = pd.pid) WHERE ni.last < {?} AND ({$this->subscriptionWhere()}) AND (e.email IS NOT NULL OR FIND_IN_SET('googleapps', eo.storage)) GROUP BY a.uid"; @@ -204,16 +205,18 @@ abstract class MassMailer public function sendToAll() { $this->setSent(); - $query = XDB::format($this->getAllRecipients(), $this->id()) . ' LIMIT 60'; + $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 = {?} @@ -221,6 +224,7 @@ abstract class MassMailer sleep(60); } + return $emailsCount; } abstract protected function assignData(&$smarty);