Uses new dynamic config to store number of subscribers so we don't
authorPascal Corpet <pascal.corpet@m4x.org>
Sun, 28 Oct 2007 22:58:58 +0000 (23:58 +0100)
committerPascal Corpet <pascal.corpet@m4x.org>
Sun, 28 Oct 2007 23:04:36 +0000 (00:04 +0100)
recalculate it on each page.

include/xorg.misc.inc.php
modules/admin.php
plugins/insert.getNbIns.php

index 2ecaab8..7c75cba 100644 (file)
@@ -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:
 ?>
index 7b97b37..9327f8a 100644 (file)
@@ -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'));
index f19ff89..b12c73f 100644 (file)
  * 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: