X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=bin%2Fcron%2Fcron_validations.php;h=4cab46718ed01ace2d4aafc3a2ab91dcf6b87208;hb=b9ad087851ce4a09236f64f67d15fdaf29e38cf0;hp=1e00a1614b535c46127bf6c5d50d1dcc6bc168a4;hpb=50a40a33a496131e817df875607ea5542d096a64;p=platal.git diff --git a/bin/cron/cron_validations.php b/bin/cron/cron_validations.php index 1e00a16..4cab467 100755 --- a/bin/cron/cron_validations.php +++ b/bin/cron/cron_validations.php @@ -1,7 +1,7 @@ -#!/usr/bin/php4 -q +#!/usr/bin/php5 -q xdb->query("SELECT count(stamp), sum(stamp < NOW() - $M_PERIOD), sum(stamp < NOW() - $R_PERIOD) FROM x4dat.requests"); +$res = XDB::query("SELECT count(stamp), sum(stamp < NOW() - $M_PERIOD), sum(stamp < NOW() - $R_PERIOD) FROM x4dat.requests"); list($nb,$nbold,$nbveryold) = $res->fetchOneRow(); if (empty($nb)) { exit; } -$mymail = new HermesMailer(); -$mymail->setFrom('validation@polytechnique.org'); -$mymail->addTo("validation@polytechnique.org"); -$mymail->setSubject((empty($nbveryold)?"":"[urgent] ")."il y a $nb validations non effectuées"); +$plural = $nb == 1 ? "" : "s"; + +$mymail = new PlMailer(); +$mymail->setFrom('validation@' . $globals->mail->domain); +$mymail->addTo("validation@" . $globals->mail->domain); +$mymail->setSubject((empty($nbveryold)?"":"[urgent] ")."il y a $nb validation$plural non effectuée$plural"); $message = - "il y a $nb validation à effectuer \n" + "il y a $nb validation$plural à effectuer \n" .(empty($nbold)?"":"dont $nbold depuis le dernier mail !!!\n") - .(empty($nbveryold)?"":"et dont *$nbveryold* sont en retard de plus de 6h !!!") + .(empty($nbveryold)?"":"et dont *$nbveryold* ".($nbveryold == 1 ? "est" : "sont")." en retard de plus de 6h !!!") ."\n" - ."https://www.polytechnique.org/admin/valider.php\n"; + ."https://www.polytechnique.org/admin/validate\n\n" + ."Par catégorie :\n"; +$res = XDB::iterRow("SELECT type, count(*) + FROM x4dat.requests + GROUP BY type + ORDER BY type"); +while (list($type, $nb) = $res->next()) { + $message .= "- $type: $nb\n"; +} -$message = wordwrap($message,78); +$message = wordwrap($message,78); $mymail->setTxtBody($message); $mymail->send(); +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>