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 = {?}",
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') {
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
}
$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 <a href="' . $url . '">demande d\'inscripton</a>.');
+ }
if (!$evt['inscr_open']) {
$page->kill('Les inscriptions pour cet événement sont closes');
if (!Post::has('submit')) {
return;
+ } else {
+ S::assert_xsrf_token();
}
$moments = Post::v('moment', array());
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];
// 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;
}
XDB::execute(
"DELETE FROM groupex.evenements_participants
WHERE eid = {?} AND uid = {?} AND item_id = {?}",
- $eid, S::v("uid"), $j);
+ $eid, S::v("uid"), $j);
$updated = $eid;
}
$total += $nb;
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;
{
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;
$page->assign('moments', $moments);
if (Post::v('intitule')) {
- require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
- $short_name = event_change_shortname($page, $infos['short_name'],
+ S::assert_xsrf_token();
+
+ $this->load('xnetevents.inc.php');
+ $short_name = event_change_shortname($page, $eid,
+ $infos['short_name'],
Env::v('short_name', ''));
if ($short_name != Env::v('short_name')) {
$error = true;
// 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,
{
global $globals;
- require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+ $this->load('xnetevents.inc.php');
$evt = get_event_detail($eid, $item_id);
if (!$evt) {
}
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
GROUP BY uid",
$member['uid'], $evt['eid']);
$u = $res->fetchOneAssoc();
- $u = $u['cnt'] ? null : $u['nb'];
+ $u = $u['cnt'] ? $u['nb'] : null;
subscribe_lists_event($u, $member['uid'], $evt);
}