Handles canceled payment transactions.
[platal.git] / bin / cron / notifs.send.php
index 939b558..8a873aa 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -23,6 +23,7 @@
 require_once 'connect.db.inc.php';
 require_once 'plmailer.php';
 require_once 'notifs.inc.php';
+ini_set('memory_limit', '128M');
 
 $uids = XDB::query('SELECT  uid
                       FROM  watch
@@ -30,18 +31,20 @@ $uids = XDB::query('SELECT  uid
                   ORDER BY  uid');
 $iterator = User::iterOverUIDs($uids->fetchColumn());
 
-$mailer = new PlMailer('carnet/notif.mail.tpl');
 while($user = $iterator->next()) {
-    if (Watch::getCount($user) > 0) {
-        $notifs = Watch::getEvents($user, time() - (7 * 86400));
-        $mailer->assign('sex', $user->profile()->isFemale());
-        $mailer->assign('yourself', $user->profile()->yourself);
+    $watch = new Watch($user);
+    if ($watch->count() > 0) {
+        $notifs = $watch->events();
+        $mailer = new PlMailer('carnet/notif.mail.tpl');
+        $mailer->assign('sex', $user->isFemale());
+        $mailer->assign('yourself', $user->display_name);
         $mailer->assign('week', date('W - Y'));
         $mailer->assign('notifs', $notifs);
-        $mailer->addTo('"' . $user->full_name . '" <' . $user->bestalias . '>');
-        $mailer->send($user->email_format == 'html');
+        $mailer->sendTo($user);
+        unset($mailer);
         unset($notifs);
     }
+    unset($watch);
     unset($user);
 }
 
@@ -51,5 +54,5 @@ XDB::execute("UPDATE  watch_profile
 XDB::execute('DELETE FROM  watch_profile
                     WHERE  ts < DATE_SUB(CURRENT_DATE, INTERVAL 15 DAY)');
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>