X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=bin%2Fcron%2Fnotifs.send.php;h=8a873aa45e889ffc84753c81dc63a9eba264efe1;hb=3424387cde6c635ff16c3b5459c4caa88bb76e2e;hp=1d5ceca942d24036ef9c3678fbd101d9462f0658;hpb=8d84c630f353ef0534e02325507ed35cc2f0d28f;p=platal.git diff --git a/bin/cron/notifs.send.php b/bin/cron/notifs.send.php index 1d5ceca..8a873aa 100755 --- a/bin/cron/notifs.send.php +++ b/bin/cron/notifs.send.php @@ -1,7 +1,7 @@ #!/usr/bin/php5 -q fetchColumn()); -$mailer = new PlMailer('carnet/notif.mail.tpl'); -foreach ($all->_data as $u) { - $mailer = new PlMailer('carnet/notif.mail.tpl'); - $mailer->assign('u', $u); - $mailer->assign('week', date("W - Y")); - $mailer->assign('cats', $all->_cats); - $mailer->addTo('"' . $u['prenom'] . ' ' . $u['nom'] . '" <' . $u['bestalias'] . '@polytechnique.org>'); - $mailer->send($u['mail_fmt'] == 'html'); +while($user = $iterator->next()) { + $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->sendTo($user); + unset($mailer); + unset($notifs); + } + unset($watch); + unset($user); } -XDB::execute("DELETE FROM watch_profile - WHERE ts < DATE_SUB(CURRENT_DATE, INTERVAL 15 DAY)"); +XDB::execute("UPDATE watch_profile + SET ts = NOW() + WHERE field = 'broken'"); +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: ?>