);
}
- function handler_events(&$page)
+ function handler_events(&$page, $archive = null)
{
global $globals;
- new_group_open_page('xnetevents/index.tpl');
+ if ($archive == 'archive') {
+ $archive = true;
+ new_groupadmin_page('xnetevents/index.tpl');
+ } else {
+ $archive = false;
+ new_group_open_page('xnetevents/index.tpl');
+ }
+ $action = null;
if (Post::has('del')) {
+ $action = 'del';
+ $eid = Post::v('del');
+ } elseif (Post::has('archive')) {
+ $action = 'archive';
+ $eid = Post::v('archive');
+ } elseif (Post::has('unarchive')) {
+ $action = 'unarchive';
+ $eid = Post::v('unarchive');
+ }
+
+ if (!is_null($action)) {
if (!may_update()) {
return PL_NOT_ALLOWED;
}
- $eid = Post::v('del');
-
$res = XDB::query("SELECT asso_id, short_name FROM groupex.evenements
WHERE eid = {?} AND asso_id = {?}",
$eid, $globals->asso('id'));
if (!$tmp) {
return PL_NOT_ALLOWED;
}
+ }
+ if ($action == 'del') {
// deletes the event mailing aliases
if ($tmp[1]) {
XDB::execute(
PayReq::same_event($eid, $globals->asso('id')));
}
+ if ($action == 'archive') {
+ XDB::execute("UPDATE groupex.evenements
+ SET archive = 1
+ WHERE eid = {?} AND asso_id = {?}",
+ $eid, $globals->asso('id'));
+ }
+
+ if ($action == 'unarchive') {
+ XDB::execute("UPDATE groupex.evenements
+ SET archive = 0
+ WHERE eid = {?} AND asso_id = {?}",
+ $eid, $globals->asso('id'));
+ }
+
+ $page->assign('archive', $archive);
$page->assign('admin', may_update());
$evenements = XDB::iterator(
INNER JOIN x4dat.auth_user_md5 AS u ON u.user_id = e.organisateur_uid
INNER JOIN x4dat.aliases AS a ON (a.type = 'a_vie' AND a.id = u.user_id)
LEFT JOIN groupex.evenements_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?})
- WHERE asso_id = {?}"
+ 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'));
{* *}
{**************************************************************************}
+{if !$admin}
<h1>{$asso.nom} : Evénements</h1>
+{else}
+<h1>
+ {$asso.nom} :
+ {if $archive}[<a href="{$platal->ns}events">Evénements</a>] {else}Evénements {/if}
+ {if $archive}Archives {else}[<a href="{$platal->ns}events/archive">Archives</a>] {/if}
+</h1>
-{if $admin}
<p class="center">
[<a href="{$platal->ns}events/edit">Annoncer un nouvel événement</a>]
</p>
[<a href="{$platal->ns}events/edit/{$e.eid}">
modifier
{icon name=date_edit title="Edition de l'événement"}</a>]
-
+
+ [<a href="javascript:dynpostkv('{$platal->pl_self()}', {if !$archive}'archive'{else}'unarchive'{/if}, {$e.eid})">
+ {if !$archive}
+ archiver
+ {icon name=package_add title="Archivage"}</a>]
+ {else}
+ désarchiver
+ {icon name=package_delete title="Désarchivage"}</a>]
+ {/if}
+
[<a href="javascript:dynpostkv('{$platal->ns}events', 'del', {$e.eid})"
onclick="return confirm('Supprimer l\'événement effacera la liste des inscrits et des paiements.\n Es-tu sûr de vouloir supprimer l\'événement ?')">
supprimer