From 328d2791ab0bb840365ba3e89aa0f424618ad593 Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Sun, 28 Oct 2007 23:58:58 +0100 Subject: [PATCH] Uses new dynamic config to store number of subscribers so we don't recalculate it on each page. --- include/xorg.misc.inc.php | 9 +++++++++ modules/admin.php | 5 +++++ plugins/insert.getNbIns.php | 9 +++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/xorg.misc.inc.php b/include/xorg.misc.inc.php index 2ecaab8..7c75cba 100644 --- a/include/xorg.misc.inc.php +++ b/include/xorg.misc.inc.php @@ -315,5 +315,14 @@ function send_warning_mail($title) $mailer->send(); } + +function update_NbIns() +{ + global $globals; + $res = XDB::query("SELECT COUNT(*) FROM auth_user_md5 WHERE perms IN ('admin','user') AND deces=0"); + $cnt = $res->fetchOneCell(); + $globals->change_dynamic_config(array('NbIns' => $cnt)); +} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?> diff --git a/modules/admin.php b/modules/admin.php index 7b97b37..9327f8a 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -558,6 +558,9 @@ class AdminModule extends PLModule $mailer->assign('old', $old_fields); $mailer->assign('new', $new_fields); $mailer->send(); + + // update number of subscribers (perms or deceased may have changed) + update_NbIns(); $page->trig("updaté correctement."); } @@ -581,6 +584,8 @@ class AdminModule extends PLModule // DELETE FROM auth_user_md5 case "u_kill": user_clear_all_subs($mr['user_id']); + // update number of subscribers (perms or deceased may have changed) + update_NbIns(); $page->trig("'{$mr['user_id']}' a été désinscrit !"); $mailer = new PlMailer("admin/mail_intervention.tpl"); $mailer->assign("user", S::v('forlife')); diff --git a/plugins/insert.getNbIns.php b/plugins/insert.getNbIns.php index f19ff89..b12c73f 100644 --- a/plugins/insert.getNbIns.php +++ b/plugins/insert.getNbIns.php @@ -28,10 +28,15 @@ * Purpose: * ------------------------------------------------------------- */ + function smarty_insert_getNbIns($params, &$smarty) { - $res = XDB::query("SELECT COUNT(*) FROM auth_user_md5 WHERE perms IN ('admin','user') AND deces=0"); - $cnt = $res->fetchOneCell(); + global $globals; + $cnt = $globals->core->NbIns; + if ($cnt == 0) { + update_NbIns(); + $cnt = $globals->core->NbIns; + } return number_format($cnt, 0, ",", "."); } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -- 2.1.4