Start porting carnet to UserFilter.
[platal.git] / modules / xnetevents.php
index 91aa302..f5cd0f4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -117,7 +117,7 @@ class XnetEventsModule extends PLModule
 
         $page->assign('archive', $archive);
         $evenements = XDB::iterator(
-                "SELECT  e.*, LEFT(10, e.debut) AS debut_day, LEFT(10, e.fin) AS fin_day,
+                "SELECT  e.*, LEFT(10, e.debut) AS first_day, LEFT(10, e.fin) AS last_day,
                          IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10),
                             1) AS inscr_open, e.deadline_inscription,
                          u.nom, u.prenom, u.promo, a.alias,
@@ -133,6 +133,7 @@ class XnetEventsModule extends PLModule
 
         $evts = array();
         $undisplayed_events = 0;
+        $this->load('xnetevents.inc.php');
 
         while ($e = $evenements->next()) {
             if (!is_member() && !may_update() && !$e['accept_nonmembre']) {
@@ -167,6 +168,8 @@ class XnetEventsModule extends PLModule
                 $e['paid'] += trim($p);
             }
 
+            make_event_date($e);
+
             if (Env::has('updated') && $e['eid'] == Env::i('updated')) {
                 $page->assign('updated', $e);
             }
@@ -268,6 +271,7 @@ class XnetEventsModule extends PLModule
             $total += $nb;
         }
         if ($updated !== false) {
+            $page->trigSuccess('Ton inscription à l\'événement a été mise à jour avec succès.');
             subscribe_lists_event($total, S::i('uid'), $evt);
         }
         $page->assign('event', get_event_detail($eid));
@@ -652,19 +656,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);
         }