X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fxnetgrp.php;h=53ebb12429ecbce7c0cd9afcf72f23d5c5b70f02;hb=1aff3b59c0f46dafe3396c1123a252645805e233;hp=50251811dd853d90ca1e20cc85e961f38d2197d6;hpb=73317355964c4cd538157f8b281a1384b7e38e4d;p=platal.git diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 5025181..53ebb12 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); @@ -918,7 +920,11 @@ class XnetGrpModule extends PLModule break; } } - http_redirect($_SERVER['HTTP_REFERER']); + if (!empty($_SERVER['HTTP_REFERER'])) { + http_redirect($_SERVER['HTTP_REFERER']); + } else { + pl_redirect(''); + } } function handler_admin_annuaire($page) @@ -1079,7 +1085,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')); @@ -1220,6 +1226,11 @@ class XnetGrpModule extends PLModule $mailer->send(); } + $nl = Newsletter::forGroup($globals->asso('shortname')); + if (!is_null($nl)) { + $nl->unsubscribe(null, S::i('uid')); + } + $domain = $globals->asso('mail_domain'); if (!$domain) { return true;