From 674333e7f1f4ad1e06626c16138eeb4b755f9f7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Wed, 2 Nov 2011 14:11:22 +0100 Subject: [PATCH] Only notifies animators who should be notified. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- classes/group.php | 11 +++++++++++ modules/xnetgrp.php | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/classes/group.php b/classes/group.php index 846f2b2..58b35ba 100644 --- a/classes/group.php +++ b/classes/group.php @@ -94,6 +94,17 @@ class Group return $uf->iterUsers($limit); } + public function iterToNotify() + { + if ($this->data['notify_all']) { + $condition = UFC_Group::BOTH; + } else { + $condition = UFC_Group::NOTIFIED; + } + $uf = New UserFilter(New UFC_Group($this->id, true, $condition)); + return $uf->iterUsers(); + } + public function getLogo($fallback = true) { if (!empty($this->logo)) { diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 21e2002..e70899a 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -737,8 +737,7 @@ class XnetGrpModule extends PLModule XDB::execute('DELETE FROM group_former_members WHERE uid = {?} AND asso_id = {?}', S::i('uid'), $globals->asso('id')); - $uf = New UserFilter(New UFC_Group($globals->asso('id'), true)); - $admins = $uf->iterUsers(); + $admins = $globals->asso()->iterToNotify(); $admin = $admins->next(); $to = $admin->bestEmail(); while ($admin = $admins->next()) { @@ -1072,7 +1071,7 @@ class XnetGrpModule extends PLModule if ($globals->asso('notif_unsub')) { $mailer = new PlMailer('xnetgrp/unsubscription-notif.mail.tpl'); - $admins = $globals->asso()->iterAdmins(); + $admins = $globals->asso()->iterToNotify(); while ($admin = $admins->next()) { $mailer->addTo($admin); } -- 2.1.4