'%grp/events' => $this->make_hook('events', AUTH_MDP),
'%grp/events/sub' => $this->make_hook('sub', AUTH_MDP),
'%grp/events/csv' => $this->make_hook('csv', AUTH_MDP),
+ '%grp/events/ical' => $this->make_hook('ical', AUTH_MDP),
'%grp/events/edit' => $this->make_hook('edit', AUTH_MDP),
'%grp/events/admin' => $this->make_hook('admin', AUTH_MDP),
);
}
- function handler_events(&$page)
+ function handler_events(&$page, $archive = null)
{
global $globals;
- new_group_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'));
+ WHERE eid = {?} AND asso_id = {?}",
+ $eid, $globals->asso('id'));
$tmp = $res->fetchOneRow();
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.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 = {?}
- GROUP BY e.eid
- ORDER BY debut", S::v('uid'), $globals->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();
while ($e = $evenements->next()) {
+ $e['show_participants'] = ($e['show_participants'] && (is_member() || may_update()));
$res = XDB::query(
"SELECT titre, details, montant, ei.item_id, nb
FROM groupex.evenements_items AS ei
{
require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
- new_group_page('xnetevents/subscribe.tpl');
+ new_group_open_page('xnetevents/subscribe.tpl');
$evt = get_event_detail($eid);
if (!$evt) {
if (!$evt['inscr_open']) {
$page->kill('Les inscriptions pour cet événement sont closes');
}
+ if (!$evt['accept_nonmembre'] && !is_member() && !may_update()) {
+ $page->kill('Cet événement est fermé aux non-membres du groupe');
+ }
$page->assign('event', $evt);
$page->assign('tout', !Env::v('item_id', false));
}
+ function handler_ical(&$page, $eid = null)
+ {
+ global $globals;
+
+ require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+ $evt = get_event_detail($eid);
+ if (!$evt) {
+ return PL_NOT_FOUND;
+ }
+ $evt['debut'] = preg_replace('/(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/', "\\1\\2\\3T\\4\\5\\6", $evt['debut']);
+ $evt['fin'] = preg_replace('/(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/', "\\1\\2\\3T\\4\\5\\6", $evt['fin']);
+
+ foreach ($evt['moments'] as $m) {
+ $evt['descriptif'] .= "\n\n** " . $m['titre'] . " **\n" . $m['details'];
+ }
+
+ $page->changeTpl('xnetevents/calendar.tpl', NO_SKIN);
+
+ require_once('ical.inc.php');
+ $page->assign('asso', $globals->asso());
+ $page->assign('timestamp', time());
+ $page->assign('admin', may_update());
+
+ if (may_update()) {
+ $page->assign('participants', get_event_participants($evt, null, 'promo, nom, prenom'));
+ }
+ $page->register_function('display_ical', 'display_ical');
+ $page->assign_by_ref('e', $evt);
+
+ header('Content-Type: text/calendar; charset=utf-8');
+ }
+
function handler_edit(&$page, $eid = null)
{
global $globals;
$evt = array(
'eid' => $eid,
'asso_id' => $globals->asso('id'),
- 'organisateur_uid' => S::v('uid'),
'paiement_id' => Post::v('paiement_id') > 0 ? Post::v('paiement_id') : null,
'debut' => Post::v('deb_Year').'-'.Post::v('deb_Month')
.'-'.Post::v('deb_Day').' '.Post::v('deb_Hour')
);
$trivial = array('intitule', 'descriptif', 'noinvite',
- 'show_participants');
+ 'show_participants', 'accept_nonmembre', 'organisateur_uid');
foreach ($trivial as $k) {
$evt[$k] = Post::v($k);
}
+ if (!$eid) {
+ $evt['organisateur_uid'] = S::v('uid');
+ }
if (Post::v('deadline')) {
$evt['deadline_inscription'] = Post::v('inscr_Year').'-'
SET eid={?}, asso_id={?}, organisateur_uid={?}, intitule={?},
paiement_id = {?}, descriptif = {?}, debut = {?},
fin = {?}, show_participants = {?}, short_name = {?},
- deadline_inscription = {?}, noinvite = {?}',
+ deadline_inscription = {?}, noinvite = {?},
+ accept_nonmembre = {?}',
$evt['eid'], $evt['asso_id'], $evt['organisateur_uid'],
$evt['intitule'], $evt['paiement_id'], $evt['descriptif'],
$evt['debut'], $evt['fin'], $evt['show_participants'],
$evt['short_name'], $evt['deadline_inscription'],
- $evt['noinvite']);
+ $evt['noinvite'], $evt['accept_nonmembre']);
// if new event, get its id
if (!$eid) {
}
if (is_null($evt['eid'])) {
- pl_redirect('events/'.$eid);
+ pl_redirect('events');
}
}
// when modifying an old event retreive the old datas
if ($eid) {
$res = XDB::query(
- "SELECT eid, intitule, descriptif, debut, fin,
- show_participants, paiement_id, short_name,
- deadline_inscription, noinvite
+ "SELECT eid, intitule, descriptif, debut, fin, organisateur_uid,
+ show_participants, paiement_id, short_name,
+ deadline_inscription, noinvite, accept_nonmembre
FROM groupex.evenements
WHERE eid = {?}", $eid);
$evt = $res->fetchOneAssoc();