X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=bin%2Fcron%2Fnotifs.send.php;h=8a873aa45e889ffc84753c81dc63a9eba264efe1;hb=3424387cde6c635ff16c3b5459c4caa88bb76e2e;hp=b48682f2b14e8ed545e8ebd869f89fc6ac53d800;hpb=c4b7c2d0c741e95bb1a6992cc0e0cc371b8c1e11;p=platal.git diff --git a/bin/cron/notifs.send.php b/bin/cron/notifs.send.php index b48682f..8a873aa 100755 --- a/bin/cron/notifs.send.php +++ b/bin/cron/notifs.send.php @@ -1,7 +1,7 @@ #!/usr/bin/php5 -q _data as $u) { - $week = date("W - Y"); - - $text = " ".($u['sexe'] ? 'Chère' : 'Cher')." {$u['prenom']},\n\n" - . " Voici les événements survenus dans la semaine écoulée,\n" - . "et depuis ta dernière visite sur le site.\n\n" - . "Tu trouveras les mêmes informations sur la page :\n" - . " https://www.polytechnique.org/carnet/panel\n\n" - . "------------------------------------------------------------------------\n\n"; - - $html = << - - Notifications de la semaine $week - - -

Voici les événements survenus dans la semaine écoulée, et depuis ta dernière visite sur le site.

-

Tu trouveras les mêmes informations sur cette page

-EOF; - - foreach($u['data'] as $cid=>$d) { - $text .= " {$all->_cats[$cid][(count($d)==1)?'mail_sg':'mail']} :\n\n"; - $html .= "

{$all->_cats[$cid][(count($d)==1)?'mail_sg':'mail']} :

\n\n"; +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 + WHERE FIND_IN_SET(\'mail\', flags) + ORDER BY uid'); +$iterator = User::iterOverUIDs($uids->fetchColumn()); + +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); } - - $text .= "-- \n" - . "L'équipe de Polytechnique.org\n\n" - . "------------------------------------------------------------------------\n\n" - . "Tu recois ce mail car tu as activé la notification automatique \n" - . "par mail des événements que tu surveilles.\n\n" - . "Tu peux changer cette option sur :\n" - . " https://www.polytechnique.org/carnet/notifs"; - $html .= << -

L'équipe de Polytechnique.org

-
-

- Tu recois ce mail car tu as activé la notification automatique par mail des événements que tu surveilles. -

-

Tu peux changer cette option sur la page - de configuration des notifications -

- - -EOF; - - global $globals; - $mailer = new PlMailer(); - $mailer->setFrom('Carnet Polytechnicien mail->domain . '>'); - $mailer->addTo("\"{$u['prenom']} {$u['nom']}\" <{$u['bestalias']}@" . $globals->mail->domain . '>'); - $mailer->setSubject("Notifications de la semaine $week"); - $mailer->setTxtBody($text); - if ($u['mail_fmt'] == 'html') { $mailer->setHtmlBody($html); } - $mailer->send(); + unset($watch); + unset($user); } -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +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 fenc=utf-8: ?>