Better counts of registered users with profiles.
authorStéphane Jacob <sj@m4x.org>
Sun, 5 Jun 2011 19:41:19 +0000 (21:41 +0200)
committerStéphane Jacob <sj@m4x.org>
Sun, 5 Jun 2011 19:41:19 +0000 (21:41 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/platalglobals.php.in

index d9151ae..8a29600 100644 (file)
@@ -77,11 +77,12 @@ class PlatalGlobals extends PlGlobals
 
     public function updateNbIns()
     {
-        $res = XDB::query("SELECT  COUNT(*)
-                             FROM  accounts
-                            WHERE  state = 'active'");
-        $cnt = $res->fetchOneCell();
-        $this->changeDynamicConfig(array('NbIns' => $cnt));
+        $count = XDB::rawFetchOneCell("SELECT  COUNT(*)
+                                         FROM  accounts         AS a
+                                   INNER JOIN  account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms))
+                                   INNER JOIN  profiles         AS p  ON (ap.pid = p.pid)
+                                        WHERE  a.state = 'active' AND p.deathdate IS NULL");
+        $this->changeDynamicConfig(array('NbIns' => $count));
     }
 
     public function updateNbValid()