rework XOrgDB -> XDB (shorter, easier to use).
[platal.git] / modules / stats.php
index fbfb2b4..c12eb97 100644 (file)
@@ -50,14 +50,12 @@ class StatsModule extends PLModule
     function handler_stats(&$page)
     {
         $page->changeTpl('stats/index.tpl');
-        return PL_OK;
     }
 
     function handler_evolution(&$page, $jours = 365)
     {
         $page->changeTpl('stats/evolution_inscrits.tpl');
         $page->assign('jours', $jours);
-        return PL_OK;
     }
 
     function handler_graph_evo(&$page, $jours = 365)
@@ -67,7 +65,7 @@ class StatsModule extends PLModule
         define('DUREEJOUR',24*3600);
 
         //recupere le nombre d'inscriptions par jour sur la plage concernée
-        $res = $globals->xdb->iterRow(
+        $res = XDB::iterRow(
                 "SELECT  IF( date_ins>DATE_SUB(NOW(),INTERVAL $jours DAY),
                              TO_DAYS(date_ins)-TO_DAYS(NOW()),
                             ".(-($jours+1)).") AS jour,
@@ -134,7 +132,7 @@ EOF2;
             $depart = 1920;
 
             //recupere le nombre d'inscriptions par jour sur la plage concernée
-            $res = $globals->xdb->iterRow(
+            $res = XDB::iterRow(
                     "SELECT  promo, SUM(perms IN ('admin', 'user')) / COUNT(*) * 100
                        FROM  auth_user_md5
                       WHERE  promo >= $depart AND deces = 0
@@ -181,7 +179,7 @@ EOF2;
             //nombre de jours sur le graph
             $jours = 365;
             define('DUREEJOUR',24*3600);
-            $res = $globals->xdb->query("SELECT min(TO_DAYS(date_ins)-TO_DAYS(now()))
+            $res = XDB::query("SELECT min(TO_DAYS(date_ins)-TO_DAYS(now()))
                                            FROM auth_user_md5
                                           WHERE promo = {?}
                                                 AND perms IN ('admin', 'user')",
@@ -189,7 +187,7 @@ EOF2;
             $jours = -$res->fetchOneCell();
 
             //recupere le nombre d'inscriptions par jour sur la plage concernée
-            $res = $globals->xdb->iterRow(
+            $res = XDB::iterRow(
                     "SELECT  IF( date_ins>DATE_SUB(NOW(),INTERVAL $jours DAY),
                                  TO_DAYS(date_ins)-TO_DAYS(NOW()),
                                 ".(-($jours+1)).") AS jour,
@@ -254,7 +252,7 @@ EOF2;
 
         $page->changeTpl('stats/nb_by_promo.tpl');
 
-        $res = $globals->xdb->iterRow(
+        $res = XDB::iterRow(
                 "SELECT  promo,COUNT(*)
                    FROM  auth_user_md5
                   WHERE  promo > 1900 AND perms IN ('admin','user')
@@ -274,8 +272,6 @@ EOF2;
         $page->assign('min', $min-$min % 10);
         $page->assign('max', $max+10-$max%10);
         $page->assign('promo', $promo);
-
-        return PL_OK;
     }
 
     function handler_coupures(&$page, $cp_id = null)
@@ -285,7 +281,7 @@ EOF2;
         $page->changeTpl('stats/coupure.tpl');
 
         if (!is_null($cp_id)) {
-            $res = $globals->xdb->query("SELECT  UNIX_TIMESTAMP(debut) AS debut,
+            $res = XDB::query("SELECT  UNIX_TIMESTAMP(debut) AS debut,
                                                  TIME_FORMAT(duree,'%kh%i') AS duree,
                                                  resume, description, services
                                            FROM  coupures
@@ -300,10 +296,8 @@ EOF2;
             $beginning_date = date("Ymd", time() - 3600*24*21) . "000000";
             $sql = "SELECT  id, UNIX_TIMESTAMP(debut) AS debut, resume, services
                       FROM  coupures where debut > '$beginning_date' order by debut desc";
-            $page->assign('coupures', $globals->xdb->iterator($sql));
+            $page->assign('coupures', XDB::iterator($sql));
         }
-
-        return PL_OK;
     }
 }