From ae6cd6338aef84c1ea54c6cc149567d4de377f56 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 9 Nov 2009 00:04:41 +0100 Subject: [PATCH] Notifies her contacts when a user looses her last redirection (Closes #1000). --- ChangeLog | 1 + bin/cron/notifs.send.php | 7 +++++-- include/notifs.inc.php | 29 +++++++++++++++-------------- modules/email.php | 4 ++++ 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index f4d6fe3..b299888 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ Bug/Wish: * Carnet: - #975: Cleans up watch_nonins when someone dies -JAC + - #1000: Notifies her contacts when a user has no redirection left -JAC * Core: - #984: Properly upper/lowercases accented letters when necessary -JAC diff --git a/bin/cron/notifs.send.php b/bin/cron/notifs.send.php index 1d5ceca..abaa47d 100755 --- a/bin/cron/notifs.send.php +++ b/bin/cron/notifs.send.php @@ -36,8 +36,11 @@ foreach ($all->_data as $u) { $mailer->send($u['mail_fmt'] == 'html'); } -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: ?> diff --git a/include/notifs.inc.php b/include/notifs.inc.php index 58d214c..5e835db 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -146,21 +146,22 @@ function select_notifs($mail, $uid=null, $last=null, $iterator=true) // {{{ global $prf_desc; -$prf_desc = array('nom' => 'Son patronyme', - 'freetext' => 'Le texte libre', - 'mobile' => 'Son numéro de téléphone portable', +$prf_desc = array('nom' => 'Son patronyme', + 'freetext' => 'Le texte libre', + 'mobile' => 'Son numéro de téléphone portable', 'nationalite' => 'Sa nationalité', - 'nick' => 'Son surnom', - 'web' => 'L\'adresse de son site web', - 'appli1' => 'Son école d\'application', - 'appli2' => 'Son école de post-application', - 'addresses' => 'Ses adresses', - 'section' => 'Sa section sportive', - 'binets' => 'La liste de ses binets', - 'medals' => 'Ses décorations', - 'cv' => 'Son Curriculum Vitae', - 'jobs' => 'Ses informations professionnelles', - 'photo' => 'Sa photographie'); + 'nick' => 'Son surnom', + 'web' => "L'adresse de son site web", + 'appli1' => "Son école d'application", + 'appli2' => 'Son école de post-application', + 'addresses' => 'Ses adresses', + 'section' => 'Sa section sportive', + 'binets' => 'La liste de ses binets', + 'medals' => 'Ses décorations', + 'cv' => 'Son curriculum vitae', + 'jobs' => 'Ses informations professionnelles', + 'photo' => 'Sa photographie', + 'broken' => "Il n'a plus d'adresse de redirection valide"); function get_profile_change_details($event, $limit) { global $prf_desc; diff --git a/modules/email.php b/modules/email.php index fc76f01..7e35616 100644 --- a/modules/email.php +++ b/modules/email.php @@ -913,6 +913,7 @@ L'équipe d'administration mail->domain . '>'; // Output the list of users with recently broken addresses, // along with the count of valid redirections. + require_once 'include/notifs.inc.php'; pl_content_headers("text/x-csv"); $csv = fopen('php://output', 'w'); @@ -928,6 +929,9 @@ L'équipe d'administration mail->domain . '>'; GROUP BY u.user_id", $alias); if ($x = $sel->fetchOneAssoc()) { + if ($x['nb_mails'] == 0) { + register_profile_update($x['user_id'], 'broken'); + } fputcsv($csv, array($x['nom'], $x['prenom'], $x['promo'], $alias, join(',', $mails), $x['nb_mails'], 'https://www.polytechnique.org/marketing/broken/' . $alias), ';'); -- 2.1.4