Only notifies animators who should be notified.
authorStéphane Jacob <sj@m4x.org>
Wed, 2 Nov 2011 13:11:22 +0000 (14:11 +0100)
committerStéphane Jacob <sj@m4x.org>
Wed, 2 Nov 2011 13:11:22 +0000 (14:11 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/group.php
modules/xnetgrp.php

index 846f2b2..58b35ba 100644 (file)
@@ -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)) {
index 21e2002..e70899a 100644 (file)
@@ -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);
             }