From 3d84dcc5127daa206c769642f320e289a6e2815b Mon Sep 17 00:00:00 2001 From: Thomas Minvielle Date: Sun, 3 Nov 2013 11:13:36 +0100 Subject: [PATCH] Automatically disables the 'send mail' function when reaching 1000 members. --- modules/xnetgrp.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 051b0da..9fab4ae 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -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 { -- 2.1.4