Happy New Year!
[platal.git] / modules / xnetevents.php
index 10d7259..3cacb71 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   *
@@ -183,9 +183,18 @@ class XnetEventsModule extends PLModule
         $page->changeTpl('xnetevents/subscribe.tpl');
 
         $evt = get_event_detail($eid);
-        if (!$evt) {
+        if (is_null($evt)) {
             return PL_NOT_FOUND;
         }
+        if ($evt === false) {
+            global $globals, $platal;
+            $url = $globals->asso('sub_url');
+            if (empty($url)) {
+                $url = $platal->ns . 'subscribe';
+            }
+            $page->kill('Cet événement est reservé aux membres du groupe ' . $globals->asso('nom') .
+                        '. Pour devenir membre, rends-toi sur la page de <a href="' . $url . '">demande d\'inscripton</a>.');
+        }
 
         if (!$evt['inscr_open']) {
             $page->kill('Les inscriptions pour cet événement sont closes');
@@ -259,6 +268,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));
@@ -443,7 +453,7 @@ class XnetEventsModule extends PLModule
             // request for a new payment
             if (Post::v('paiement_id') == -1 && $money_defaut >= 0) {
                 require_once 'validations.inc.php';
-                $p = new PayReq(S::v('uid'),
+                $p = new PayReq(S::user(),
                                 Post::v('intitule')." - ".$globals->asso('nom'),
                                 Post::v('site'), $money_defaut,
                                 Post::v('confirmation'), 0, 999,
@@ -643,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);
         }