Notifies her contacts when a user looses her last redirection (Closes #1000).
authorStéphane Jacob <sj@m4x.org>
Sun, 8 Nov 2009 23:04:41 +0000 (00:04 +0100)
committerStéphane Jacob <sj@m4x.org>
Mon, 9 Nov 2009 14:50:50 +0000 (15:50 +0100)
ChangeLog
bin/cron/notifs.send.php
include/notifs.inc.php
modules/email.php

index f4d6fe3..b299888 100644 (file)
--- 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
index 1d5ceca..abaa47d 100755 (executable)
@@ -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:
 ?>
index 58d214c..5e835db 100644 (file)
@@ -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;
index fc76f01..7e35616 100644 (file)
@@ -913,6 +913,7 @@ L'équipe d'administration <support@" . $globals->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 <support@" . $globals->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), ';');