From: Stéphane Jacob Date: Tue, 22 Mar 2011 09:25:19 +0000 (+0100) Subject: Only notifies user about a broken redirection twice a month, fixes a few things. X-Git-Tag: xorg/1.1.0~18 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=dd092f56992ad4dd8a7189173878691522c5a0f1;p=platal.git Only notifies user about a broken redirection twice a month, fixes a few things. Signed-off-by: Stéphane Jacob --- diff --git a/include/emails.inc.php b/include/emails.inc.php index 5f0d72f..d4ddaca 100644 --- a/include/emails.inc.php +++ b/include/emails.inc.php @@ -140,7 +140,8 @@ function mark_broken_email($email, $admin = false) return; } - $user = XDB::fetchOneAssoc('SELECT r1.uid, r1.broken_level != 0 AS broken, a.hruid, COUNT(r2.uid) AS nb_mails, a.full_name, s.email AS alias + $user = XDB::fetchOneAssoc('SELECT r1.uid, r1.broken_level != 0 AS broken, COUNT(r2.uid) AS nb_mails, + s.email AS alias, DATE_ADD(r1.last, INTERVAL 14 DAY) < CURDATE() as notify FROM email_redirect_account AS r1 INNER JOIN accounts AS a ON (a.uid = r1.uid) INNER JOIN email_source_account AS s ON (a.uid = s.uid AND s.flags = \'bestalias\') diff --git a/modules/email.php b/modules/email.php index ece008d..d872eda 100644 --- a/modules/email.php +++ b/modules/email.php @@ -833,9 +833,10 @@ class EmailModule extends PLModule foreach ($broken_list as $email) { if ($user = mark_broken_email($email, true)) { - if ($user['nb_mails'] > 0) { + if ($user['nb_mails'] > 0 && $user['notify']) { $mail = new PlMailer('emails/broken.mail.tpl'); - $mail->addTo($user); + $dest = User::getSilentWithUID($user['uid']); + $mail->setTo($dest); $mail->assign('user', $user); $mail->assign('email', $email); $mail->send(); diff --git a/templates/emails/broken.mail.tpl b/templates/emails/broken.mail.tpl index 2ac35fd..4e4b35a 100644 --- a/templates/emails/broken.mail.tpl +++ b/templates/emails/broken.mail.tpl @@ -30,7 +30,7 @@ Bonjour ! Nous t'écrivons car lors de l'envoi de la lettre d'information mensuelle de Polytechnique.org à ton adresse polytechnicienne : - {$user->bestAlias()}, + {$user.alias}, l'adresse {$email}, sur laquelle tu rediriges tes emails, ne fonctionnait pas.