Automatically disables the 'send mail' function when reaching 1000 members.
authorThomas Minvielle <thomas.minvielle@polytechnique.org>
Sun, 3 Nov 2013 10:13:36 +0000 (11:13 +0100)
committerThomas Minvielle <thomas.minvielle@polytechnique.org>
Wed, 6 Nov 2013 19:01:17 +0000 (20:01 +0100)
modules/xnetgrp.php

index 051b0da..9fab4ae 100644 (file)
@@ -1079,6 +1079,20 @@ class XnetGrpModule extends PLModule
 
             Group::subscribe($globals->asso('id'), $user->id());
             $this->removeSubscriptionRequest($user->id());
+            
+            // Check if the group has more than 1000 members, if so, disable the "send mail" function.
+            $full_count = XDB::fetchOneCell('SELECT COUNT(*)
+                                               FROM group_members
+                                              WHERE asso_id = {?}',
+                                $globals->asso('id'));
+            if ($full_count > 999) {
+                XDB::execute(
+                    "UPDATE groups
+                    SET disable_mails = 1
+                    WHERE id = {?}",
+                    $globals->asso('id')); 
+            }
+            
             if ($suggest_account_activation) {
                 pl_redirect('member/suggest/' . $user->login() . '/' . $email . '/' . $globals->asso('nom'));
             } else {