From: Nicolas Iooss Date: Sun, 16 Feb 2014 16:27:46 +0000 (+0100) Subject: Enfore non-empty email addresses at several locations X-Git-Tag: xorg/1.1.12~31 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=7fbaf66b976b77ec15bedb25ed3654928ae1b655;p=platal.git Enfore non-empty email addresses at several locations --- diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 7dd5bb3..ded8520 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -1231,6 +1231,12 @@ class NLIssue */ public function sendTo($user, $hash = null) { + // Don't send email to users without an address + // Note: this would never happen when using sendToAll + if (!$user->bestEmail()) { + return; + } + $this->fetchArticles(); if (is_null($hash)) { diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 5025181..cc39f46 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -725,7 +725,7 @@ class XnetGrpModule extends PLModule $this->removeSubscriptionRequest($user->id()); Group::subscribe($globals->asso('id'), $user->id()); - if (XDB::affectedRows() == 1) { + if (XDB::affectedRows() == 1 && $user->forlifeEmail()) { $mailer = new PlMailer(); $mailer->addTo($user->forlifeEmail()); $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>'); @@ -788,12 +788,14 @@ class XnetGrpModule extends PLModule S::assert_xsrf_token(); $this->removeSubscriptionRequest($user->id()); - $mailer = new PlMailer(); - $mailer->addTo($user->forlifeEmail()); - $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>'); - $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription annulée'); - $mailer->setTxtBody(Env::v('motif')); - $mailer->send(); + if ($user->forlifeEmail()) { + $mailer = new PlMailer(); + $mailer->addTo($user->forlifeEmail()); + $mailer->setFrom('"' . S::user()->fullName() . '" <' . S::user()->forlifeEmail() . '>'); + $mailer->setSubject('['.$globals->asso('nom').'] Demande d\'inscription annulée'); + $mailer->setTxtBody(Env::v('motif')); + $mailer->send(); + } $page->killSuccess("La demande de {$user->fullName()} a bien été refusée."); } else { $page->assign('show_form', true); @@ -1079,7 +1081,7 @@ class XnetGrpModule extends PLModule Group::subscribe($globals->asso('id'), $user->id()); $this->removeSubscriptionRequest($user->id()); - if ($user->isActive()) { + if ($user->isActive() && $user->bestEmail()) { $mailer = new PlMailer('xnetgrp/forced-subscription.mail.tpl'); $mailer->addTo($user->bestEmail()); $mailer->assign('group', $globals->asso('nom')); diff --git a/modules/xnetgrp/mail.inc.php b/modules/xnetgrp/mail.inc.php index 6ddfe50..473a931 100644 --- a/modules/xnetgrp/mail.inc.php +++ b/modules/xnetgrp/mail.inc.php @@ -123,6 +123,9 @@ function send_xnet_mails($from, $sujet, $body, $wiki, $tos, $replyto = null, $up } else { $email = $user; } + if (!$email) { + continue; + } if (!isset($sent[$email])) { _send_xnet_mail($user, $body, $wiki, $mailer, $replyto);