X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetevents.php;h=21d8435eafaab998348fbcfcf6c14ad6d1f087f1;hb=efe597c5795234724bc3df508bd628f9860a9c32;hp=3910dbcfb61f213f7d83a78b87ce1f701e125bdd;hpb=ebd515f95f03f8a87f9b846d65e179b39a535222;p=platal.git diff --git a/modules/xnetevents.php b/modules/xnetevents.php index 3910dbc..21d8435 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -58,6 +58,7 @@ class XnetEventsModule extends PLModule if (!may_update()) { return PL_FORBIDDEN; } + S::assert_xsrf_token(); $res = XDB::query("SELECT asso_id, short_name FROM groupex.evenements WHERE eid = {?} AND asso_id = {?}", @@ -97,7 +98,7 @@ class XnetEventsModule extends PLModule XDB::execute("DELETE FROM requests WHERE type = 'paiements' AND data LIKE {?}", PayReq::same_event($eid, $globals->asso('id'))); - update_NbValid(); + $globals->updateNbValid(); } if ($action == 'archive') { @@ -127,13 +128,18 @@ class XnetEventsModule extends PLModule LEFT JOIN groupex.evenements_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?}) WHERE asso_id = {?} AND archive = " . ($archive ? "1 " : "0 ") - . (is_member() || may_update() ? "" : " AND accept_nonmembre != 0 ") . "GROUP BY e.eid ORDER BY inscr_open DESC, debut DESC", S::v('uid'), $globals->asso('id')); $evts = array(); + $undisplayed_events = 0; while ($e = $evenements->next()) { + if (!is_member() && !may_update() && !$e['accept_nonmembre']) { + $undisplayed_events ++; + continue; + } + $e['show_participants'] = ($e['show_participants'] && (is_member() || may_update())); $res = XDB::query( "SELECT titre, details, montant, ei.item_id, nb, ep.paid @@ -168,17 +174,27 @@ class XnetEventsModule extends PLModule } $page->assign('evenements', $evts); + $page->assign('undisplayed_events', $undisplayed_events); } function handler_sub(&$page, $eid = null) { - require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php'; + $this->load('xnetevents.inc.php'); $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 demande d\'inscripton.'); + } if (!$evt['inscr_open']) { $page->kill('Les inscriptions pour cet événement sont closes'); @@ -196,6 +212,8 @@ class XnetEventsModule extends PLModule if (!Post::has('submit')) { return; + } else { + S::assert_xsrf_token(); } $moments = Post::v('moment', array()); @@ -210,7 +228,7 @@ class XnetEventsModule extends PLModule if (!isset($pers[$j]) || !is_numeric($pers[$j]) || $pers[$j] < 0) { - $page->trig('Tu dois choisir un nombre d\'invités correct !'); + $page->trigError('Tu dois choisir un nombre d\'invités correct !'); return; } $subs[$j] = 1 + $pers[$j]; @@ -219,11 +237,11 @@ class XnetEventsModule extends PLModule // impossible to unsubscribe if you already paid sthing if (!array_sum($subs) && $evt['paid'] != 0) { - $page->trig("Impossible de te désinscrire complètement ". - "parce que tu as fait un paiement par ". - "chèque ou par liquide. Contacte un ". - "administrateur du groupe si tu es sûr de ". - "ne pas venir"); + $page->trigError("Impossible de te désinscrire complètement ". + "parce que tu as fait un paiement par ". + "chèque ou par liquide. Contacte un ". + "administrateur du groupe si tu es sûr de ". + "ne pas venir"); return; } @@ -250,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)); @@ -257,7 +276,7 @@ class XnetEventsModule extends PLModule function handler_csv(&$page, $eid = null, $item_id = null) { - require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php'; + $this->load('xnetevents.inc.php'); if (!is_numeric($item_id)) { $item_id = null; @@ -292,7 +311,7 @@ class XnetEventsModule extends PLModule { global $globals; - require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php'; + $this->load('xnetevents.inc.php'); $evt = get_event_detail($eid); if (!$evt) { return PL_FORBIDDEN; @@ -355,7 +374,9 @@ class XnetEventsModule extends PLModule $page->assign('moments', $moments); if (Post::v('intitule')) { - require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php'; + S::assert_xsrf_token(); + + $this->load('xnetevents.inc.php'); $short_name = event_change_shortname($page, $eid, $infos['short_name'], Env::v('short_name', '')); @@ -432,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, @@ -506,7 +527,7 @@ class XnetEventsModule extends PLModule { global $globals; - require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php'; + $this->load('xnetevents.inc.php'); $evt = get_event_detail($eid, $item_id); if (!$evt) { @@ -519,9 +540,11 @@ class XnetEventsModule extends PLModule } if (may_update() && Post::v('adm')) { + S::assert_xsrf_token(); + $member = get_infos(Post::v('mail')); if (!$member) { - $page->trig("Membre introuvable"); + $page->trigError("Membre introuvable"); } // change the price paid by a participant @@ -630,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); }