Adds email count in massmailer and displays it in the axletter notification email.
authorStéphane Jacob <sj@m4x.org>
Wed, 5 May 2010 07:39:41 +0000 (09:39 +0200)
committerStéphane Jacob <sj@m4x.org>
Wed, 5 May 2010 07:39:41 +0000 (09:39 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
bin/cron/axletter.send.php
include/massmailer.inc.php

index eabf91d..e6bbcda 100755 (executable)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once('./connect.db.inc.php');
-require_once("../../modules/axletter/axletter.inc.php");
+require_once './connect.db.inc.php';
+require_once '../../modules/axletter/axletter.inc.php';
 
 $al = AXLetter::toSend();
 if ($al) {
     echo "Envoi de la lettre \"{$al->title()}\"\n\n";
-    echo " " . date("H:i:s") . " -> début de l'envoi\n";
-    $al->sendToAll();
-    echo " " . date("H:i:s") . " -> fin de l'envoi\n";
+    echo ' ' . date("H:i:s") . " -> début de l'envoi\n";
+    $emailsCount = $al->sendToAll();
+    echo ' ' . date("H:i:s") . " -> fin de l'envoi\n\n";
+    echo $emailsCount . "emails ont été envoyés lors de cet envoi.\n";
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index f9cc381..3dde660 100644 (file)
@@ -204,14 +204,17 @@ abstract class MassMailer
     {
         $this->setSent();
         $query = XDB::format($this->getAllRecipients(), $this->id()) . ' LIMIT 60';
+        $emailsCount = 0;
+
         while (true) {
             $users = User::getBulkUsersWithUIDs(XDB::fetchColumn($query));
             if (count($users) == 0) {
-                return;
+                return $emailsCount;
             }
             foreach ($users as $user) {
                 $sent[] = XDB::format('uid = {?}', $user->id());
                 $this->sendTo($user, $hash);
+                ++$emailsCount;
             }
             XDB::execute("UPDATE  {$this->_subscriptionTable}
                              SET  last = {?}