From: Anne Limoges Date: Tue, 12 Feb 2013 08:12:15 +0000 (+0100) Subject: Adds a choice for events order for group animators. X-Git-Tag: xorg/1.1.7~10 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=30002fc80a520ff66029f5171582717d664037f6;p=platal.git Adds a choice for events order for group animators. --- diff --git a/modules/xnetevents.php b/modules/xnetevents.php index dfa76b2..feb9d7f 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -144,18 +144,46 @@ class XnetEventsModule extends PLModule } $page->assign('archive', $archive); - $evenements = XDB::iterator('SELECT e.*, LEFT(e.debut, 10) AS first_day, LEFT(e.fin, 10) AS last_day, - IF(e.deadline_inscription, - e.deadline_inscription >= LEFT(NOW(), 10), - 1) AS inscr_open, - e.deadline_inscription, - MAX(ep.nb) IS NOT NULL AS inscrit, MAX(ep.paid) AS paid - FROM group_events AS e - LEFT JOIN group_event_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?}) - WHERE asso_id = {?} AND archive = {?} - GROUP BY e.eid - ORDER BY inscr_open DESC, debut DESC', - S::i('uid'), $globals->asso('id'), $archive ? 1 : 0); + + if (Post::has('order')) { + $order = Post::v('order'); + XDB::execute("UPDATE groups + SET event_order = {?} + WHERE id = {?}", + $order, $globals->asso('id')); + } else { + $order = XDB::fetchOneCell("SELECT event_order FROM groups + WHERE id = {?}", + $globals->asso('id')); + } + if ($order == 'desc') { + $evenements = XDB::iterator('SELECT e.*, LEFT(e.debut, 10) AS first_day, LEFT(e.fin, 10) AS last_day, + IF(e.deadline_inscription, + e.deadline_inscription >= LEFT(NOW(), 10), + 1) AS inscr_open, + e.deadline_inscription, + MAX(ep.nb) IS NOT NULL AS inscrit, MAX(ep.paid) AS paid + FROM group_events AS e + LEFT JOIN group_event_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?}) + WHERE asso_id = {?} AND archive = {?} + GROUP BY e.eid + ORDER BY inscr_open DESC, debut DESC', + S::i('uid'), $globals->asso('id'), $archive ? 1 : 0); + } else { + $evenements = XDB::iterator('SELECT e.*, LEFT(e.debut, 10) AS first_day, LEFT(e.fin, 10) AS last_day, + IF(e.deadline_inscription, + e.deadline_inscription >= LEFT(NOW(), 10), + 1) AS inscr_open, + e.deadline_inscription, + MAX(ep.nb) IS NOT NULL AS inscrit, MAX(ep.paid) AS paid + FROM group_events AS e + LEFT JOIN group_event_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?}) + WHERE asso_id = {?} AND archive = {?} + GROUP BY e.eid + ORDER BY inscr_open DESC, debut ASC', + S::i('uid'), $globals->asso('id'), $archive ? 1 : 0); + } + $page->assign('order', $order); $evts = array(); $undisplayed_events = 0; diff --git a/templates/xnetevents/index.tpl b/templates/xnetevents/index.tpl index 79e1fe5..380e7b7 100644 --- a/templates/xnetevents/index.tpl +++ b/templates/xnetevents/index.tpl @@ -20,6 +20,24 @@ {* *} {**************************************************************************} +{if $is_admin} + + + + + + +
Choisis l'ordre d'affichage des événements pour ton groupe : +
+ +
+
Attention, ton choix s'appliquera à tous les utilisateurs !
+
+{/if} + {if !$is_admin}

{$asso->nom} : Événements

{else}