Should fix the calculation of the number of pages on X.net events admin page (Closes...
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 16 Nov 2008 19:45:55 +0000 (20:45 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 16 Nov 2008 19:45:55 +0000 (20:45 +0100)
Grumpf, obfuscated code! (not sure this fix all cases, please test if possible).

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
ChangeLog
modules/xnetevents.php

index 05b5bb4..07f081b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,9 @@ Bug/Wish:
     * Lists:
         - #927: Can export the list of members as a CSV file               -FRU
 
+    * XnetEvents:
+        - #751: Fix calculation of the number of pages                     -FRU
+
     * XnetList:
         - #914: Adds a toggle button in the ML/directory sync. page        -JAC
 
index 69f0b28..21d8435 100644 (file)
@@ -653,19 +653,19 @@ class XnetEventsModule extends PLModule
                                 ORDER BY  nom, prenom, promo", $evt['eid']);
 
         $ofs   = Env::i('offset');
-        $tot   = (Env::v('initiale') ? $tot : $nb_tot) - $absents->total();
-        $nbp   = intval(($tot-1)/NB_PER_PAGE);
-        $links = array();
-        if ($ofs) {
-            $links['précédent'] = $ofs-1;
-        }
-        for ($i = 0; $i <= $nbp; $i++) {
-            $links[(string)($i+1)] = $i;
-        }
-        if ($ofs < $nbp) {
-            $links['suivant'] = $ofs+1;
-        }
-        if (count($links)>1) {
+        $tot   = (Env::v('initiale') ? $tot : $nb_tot);
+        $nbp   = ceil($tot / NB_PER_PAGE);
+        if ($nbp > 1) {
+            $links = array();
+            if ($ofs) {
+                $links['précédent'] = $ofs - 1;
+            }
+            for ($i = 1 ; $i <= $nbp; $i++) {
+                $links[(string)$i] = $i - 1;
+            }
+            if ($ofs < $nbp) {
+                $links['suivant'] = $ofs+1;
+            }
             $page->assign('links', $links);
         }