Rewrite xnetevents and removes anim notification when the subscription is not changed.
[platal.git] / modules / xnetevents / xnetevents.inc.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
c441aabe 3 * Copyright (C) 2003-2014 Polytechnique.org *
0337d704 4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
aa3ef74f
AL
22// {{{ function get_event_order()
23/* get the order to paste the events
24 * @param $asso_id: group's id
25 */
26function get_event_order($asso_id)
27{
28 $order = XDB::fetchOneCell('SELECT g.event_order
29 FROM groups as g
30 WHERE id = {?}',
31 $asso_id);
32 return $order;
33}
34// }}}
35
36// {{{ function get_events()
37/* get the events of the given group ordered by the standard order for the group
38 * @param $asso_id: group's id
39 * @param $order: order to paste the events (asc or desc)
40 */
41function get_events($asso_id, $order)
42{
43 if ($order != 'asc' && $order != 'desc') {
44 $order = 'desc';
45 }
46 $evts = XDB::fetchAllAssoc('eid', "SELECT ge.eid, ge.uid, ge.intitule, ge.debut, ge.fin, ge.show_participants, ge.deadline_inscription, ge.accept_nonmembre
47 FROM group_events as ge
48 WHERE asso_id = {?}
49 ORDER BY ge.debut $order",
50 $asso_id);
51 return $evts;
52}
53// }}}
54
55// {{{ function get_event() (detail, for subs page only for now)
56/* get event details
57 * @param $eid: event's id
58 */
59function get_event($eid)
60{
61 $evt = XDB::fetchOneAssoc('SELECT ge.uid, ge.intitule, ge.descriptif, ge.debut, ge.fin, ge.deadline_inscription, ge.accept_nonmembre
62 FROM group_events as ge
63 WHERE eid = {?}',
64 $eid);
65 if (!is_null($evt['deadline_inscription']) && strtotime($evt['deadline_inscription']) < time()) {
66 $evt['inscr_open'] = false;
67 } else {
68 $evt['inscr_open'] = true;
69 }
70 $evt['organizer'] = User::getSilent($evt['uid'])->profile();
71 $evt['date'] = make_event_date($evt['debut'], $evt['fin']);
72
73 return $evt;
74}
75// }}}
76
77// {{{ function get_event_items()
78/** get items of the given event
79 *
80 * @param $eid : event's id
81 *
82 */
83function get_event_items($eid)
84{
85 $evt = XDB::fetchAllAssoc('item_id', 'SELECT gei.item_id, gei.titre, gei.details, gei.montant
86 FROM group_event_items as gei
87 WHERE eid = {?}',
88 $eid);
89 return $evt;
90}
91// }}}
92
93// {{{ function get_event_subscription()
94/* get all participations if uid is not specified, only the user's participation if uid specified
95 * @param $eid: event's id
96 * @param $uid: user's id
97 */
98function get_event_subscription($eid, $uid = null)
99{
100 if (!is_null($uid)) {
101 $where = ' and gep.uid = '.$uid;
102 }
103 else {
104 $where = '';
105 }
106 $sub = XDB::fetchAllAssoc('item_id','SELECT gep.item_id, gep.nb, gep.paid FROM group_event_participants as gep
107 WHERE gep.eid = {?}'.$where,
108 $eid);
109 return $sub;
110}
111// }}}
112
113// {{{ function get_event_telepaid()
114/* get the total payments made by a user for an event
115 * @param $eid: event's id
116 * @param $uid: user's id
117 */
118function get_event_telepaid($eid, $uid)
119{
120 $telepaid = XDB::fetchOneCell('SELECT SUM(pt.amount)
121 FROM payment_transactions AS pt
122 LEFT JOIN group_events as ge ON (ge.paiement_id = pt.ref)
123 WHERE ge.eid = {?} AND pt.uid = {?}',
124 $eid, $uid);
125 return $telepaid;
126}
127// }}}
128
0337d704 129// {{{ function get_event_detail()
d6d580ec 130
2ac0bcee 131function get_event_detail($eid, $item_id = false, $asso_id = null)
d6d580ec 132{
0337d704 133 global $globals;
2ac0bcee
FB
134 if (is_null($asso_id)) {
135 $asso_id = $globals->asso('id');
136 }
3092eea7
SJ
137 if (!$item_id) {
138 $where = '';
139 $group_by = 'e.eid';
140 } else {
141 $where = XDB::format(' AND ei.item_id = {?}', $item_id);
142 $group_by = 'ei.item_id';
143 }
e48b1c76 144 $evt = XDB::fetchOneAssoc('SELECT SUM(nb) AS nb_tot, COUNT(DISTINCT ep.uid) AS nb, e.*, SUM(IF(nb > 0, 1, 0)) AS user_count,
7852229b
SJ
145 IF(e.deadline_inscription,
146 e.deadline_inscription >= LEFT(NOW(), 10),
147 1) AS inscr_open,
0ea9f32b 148 LEFT(e.debut, 10) AS first_day, LEFT(e.fin, 10) AS last_day,
7852229b
SJ
149 LEFT(NOW(), 10) AS now,
150 ei.titre, e.subscription_notification
151 FROM group_events AS e
152 INNER JOIN group_event_items AS ei ON (e.eid = ei.eid)
153 LEFT JOIN group_event_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
3092eea7
SJ
154 WHERE (e.eid = {?} OR e.short_name = {?}) AND e.asso_id = {?}' . $where . '
155 GROUP BY ' . $group_by,
156 $eid, $eid, $asso_id);
d6d580ec 157
df1cf596 158 if (!$evt) {
d6d580ec 159 return null;
160 }
df1cf596
FB
161 if ($GLOBALS['IS_XNET_SITE'] && $evt['accept_nonmembre'] == 0 && !is_member() && !may_update()) {
162 return false;
163 }
0337d704 164
0337d704 165 if (!$item_id) {
f9e8637a
FB
166 /* Don't try to be to smart here, in case we're getting the global summary, we cannot have
167 * a general formula to estimate the total number of comers since 'moments' may (or may not be)
168 * disjuncted. As a consequence, we can only provides the number of user having fullfiled the
169 * registration procedure.
170 */
171 $evt['user_count'] = $evt['nb_tot'] = $evt['nb'];
0337d704 172 $evt['titre'] = '';
173 $evt['item_id'] = 0;
80575e7c
SJ
174 $evt['csv_name'] = urlencode($evt['intitule']);
175 } else {
176 $evt['csv_name'] = urlencode($evt['intitule'] . '.' . $evt['titre']);
0337d704 177 }
d6d580ec 178
07eb5b0e
FB
179 $evt['moments'] = XDB::fetchAllAssoc('SELECT titre, details, montant, ei.item_id, nb,
180 ep.paid, FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment
eb41eda9
FB
181 FROM group_event_items AS ei
182 LEFT JOIN group_event_participants AS ep ON (ep.eid = ei.eid AND ep.item_id = ei.item_id
07eb5b0e
FB
183 AND uid = {?})
184 WHERE ei.eid = {?}',
185 S::i('uid'), $evt['eid']);
d6d580ec 186 $evt['topay'] = 0;
98a7e9dc 187 $evt['paid'] = 0;
2ac0bcee 188 $evt['notify_payment'] = false;
d6d580ec 189 foreach ($evt['moments'] as $m) {
190 $evt['topay'] += $m['nb'] * $m['montant'];
98a7e9dc 191 if ($m['montant']) {
54ac7230 192 $evt['money'] = true;
98a7e9dc 193 }
51f1911c 194 $evt['paid'] += $m['paid'];
2ac0bcee 195 $evt['notify_payment'] = $evt['notify_payment'] || $m['notify_payment'];
d6d580ec 196 }
197
a7c0d514 198 $montant = XDB::fetchOneCell('SELECT SUM(amount) AS sum_amount
b3cd1320 199 FROM payment_transactions AS t
07eb5b0e
FB
200 WHERE ref = {?} AND uid = {?}',
201 $evt['paiement_id'], S::v('uid'));
a7c0d514
DB
202 $evt['telepaid'] = $montant;
203 $evt['paid'] += $montant;
ed996b5a 204 $evt['organizer'] = User::getSilent($evt['uid']);
d6d580ec 205
aa3ef74f 206 $evt['date'] = make_event_date($evt);
20c5c7e6 207
b6f69874 208 $evt['show_participants'] = ($evt['show_participants'] && $GLOBALS['IS_XNET_SITE'] && (is_member() || may_update()));
5a6bcfb7 209
0337d704 210 return $evt;
211}
d6d580ec 212
0337d704 213// }}}
214
215// {{{ function get_event_participants()
8270d13a 216function get_event_participants(&$evt, $item_id, array $tri = array(), $limit = null, $offset = 0)
07eb5b0e 217{
0337d704 218 global $globals;
ed21e24a 219
ed21e24a 220 $eid = $evt['eid'];
2ac0bcee 221 $money = $evt['money'] && (function_exists('may_update')) && may_update();
ed21e24a 222 $pay_id = $evt['paiement_id'];
223
c81e03c0 224 $append = $item_id ? XDB::format(' AND ep.item_id = {?}', $item_id) : '';
07eb5b0e
FB
225 $query = XDB::fetchAllAssoc('uid', 'SELECT ep.uid, SUM(ep.paid) AS paid, SUM(ep.nb) AS nb,
226 FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment
eb41eda9 227 FROM group_event_participants AS ep
07eb5b0e
FB
228 WHERE ep.eid = {?} AND nb > 0 ' . $append . '
229 GROUP BY ep.uid', $eid);
c8763ca3 230 $uf = new UserFilter(new PFC_True(), $tri);
8270d13a 231 $users = User::getBulkUsersWithUIDs($uf->filter(array_keys($query), new PlLimit($limit, $offset)));
07eb5b0e
FB
232 $tab = array();
233 foreach ($users as $user) {
234 $uid = $user->id();
235 $tab[$uid] = $query[$uid];
236 $tab[$uid]['user'] = $user;
237 }
ed21e24a 238
0337d704 239 if ($item_id) {
07eb5b0e 240 return $tab;
0337d704 241 }
ed21e24a 242
e01ebe65
FB
243 $evt['adminpaid'] = 0;
244 $evt['telepaid'] = 0;
245 $evt['topay'] = 0;
246 $evt['paid'] = 0;
07eb5b0e 247 foreach ($tab as $uid=>&$u) {
5dcca1b1 248 $u['adminpaid'] = (float)$u['paid'];
0337d704 249 $u['montant'] = 0;
2ac0bcee 250 if ($money && $pay_id) {
a7c0d514 251 $montant = XDB::fetchOneCell('SELECT SUM(amount)
b3cd1320 252 FROM payment_transactions AS t
07eb5b0e
FB
253 WHERE ref = {?} AND uid = {?}',
254 $pay_id, $uid);
a7c0d514 255 $u['paid'] += $montant;
2ac0bcee 256 }
58591700 257 $u['telepayment'] = $u['paid'] - $u['adminpaid'];
07eb5b0e 258 $res_ = XDB::iterator('SELECT ep.nb, ep.item_id, ei.montant
eb41eda9
FB
259 FROM group_event_participants AS ep
260 INNER JOIN group_event_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
07eb5b0e
FB
261 WHERE ep.eid = {?} AND ep.uid = {?}',
262 $eid, $uid);
0337d704 263 while ($i = $res_->next()) {
264 $u[$i['item_id']] = $i['nb'];
f9e8637a 265 $u['montant'] += $i['montant'] * $i['nb'];
0337d704 266 }
e01ebe65
FB
267 $evt['telepaid'] += $u['telepayment'];
268 $evt['adminpaid'] += $u['adminpaid'];
269 $evt['paid'] += $u['paid'];
270 $evt['topay'] += $u['montant'];
0337d704 271 }
272 return $tab;
273}
274// }}}
275
aa3ef74f
AL
276// {{{ function subscribe()
277/** set or update the user's subscription
278 *
279 * @param $uid: user's id
280 * @param $eid: event's id
281 * @param $subs: user's new subscription
282 *
283 */
284function subscribe($uid, $eid, $subs = array())
285{
286 global $globals;
287 // get items
288 $items = get_event_items($eid);
289 // get previous subscription
290 $old_subs = get_event_subscription($eid, $uid);
291 $participate = false;
292 $updated = false;
293 // for each item of the event
294 foreach ($items as $item_id => $details) {
295 // check if there is an old subscription
296 if (array_key_exists($item_id, $old_subs)) {
297 echo 'prev exists ';
298 // compares new and old subscription
299 if ($old_subs[$item_id]['nb'] != $subs[$item_id]) {
300 echo 'different ';
301 if ($subs[$item_id] != 0) {
302 echo "je m'inscris ";
303 XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
304 VALUES ({?}, {?}, {?}, {?}, {?}, {?})
305 ON DUPLICATE KEY UPDATE nb = VALUES(nb), flags = VALUES(flags), paid = VALUES(paid)',
306 $eid, $uid, $item_id, $subs[$item_id],(Env::has('notify_payment') ? 'notify_payment' : ''), 0);
307 $participate = true;
308 } else { // we do not store non-subscription to event items
309 echo "je me desinscris ";
310 XDB::execute('DELETE FROM group_event_participants
311 WHERE eid = {?} AND uid = {?} AND item_id = {?}',
312 $eid, $uid, $item_id);
313 }
314 $updated = true;
315 }
316 } else { // if no old subscription
317 echo 'no prev ';
318 if ($subs[$item_id] != 0) {
319 echo 'subscribe ';
320 XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
321 VALUES ({?}, {?}, {?}, {?}, {?}, {?})',
322 $eid, $uid, $item_id, $subs[$item_id], '', 0);
323 $participate = true;
324 $updated = true;
325 }
326 }
327 }
328 // item 0 stores whether the user participates globally or not, if he has to be notified when payment is created and his manual payment
329 if (array_key_exists(0, $old_subs)) {
330 XDB::execute('UPDATE group_event_participants
331 SET nb = {?}
332 WHERE eid = {?}, uid = {?}, item_id = 0',
333 ($participate ? 1 : 0), $eid, $uid);
334 } else {
335 XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
336 VALUES ({?}, {?}, {?}, {?}, {?}, {?})',
337 $eid, $uid, 0, ($participate ? 1 : 0), (Env::has('notify_payment') ? 'notify_payment' : ''), 0);
338 }
339 // if subscription is updated, we have to update the event aliases
340 if ($updated) {
341 echo "inscription mise a jour ";
342 $short_name = get_event_detail($eid)['short_name'];
343 subscribe_lists_event($uid, $short_name, ($participate ? 1 : -1), 0);
344 }
345 return $updated;
346}
347// }}}
348
349// {{{ function add_manual_payment()
350// deal with manual payments : add them on item_id = 0 (so that it's not dependant on what items the user registers)
351/*
352 *
353 */
354function add_manual_payment($newly_paid)
355{
356 $old_subs = get_event_subscription($eid, $uid);
357 if ($newly_paid != 0) {
358 if (array_key_exists(0, $old_subs)) {
359 echo "update paiement liquide ";
360 XDB::execute('UPDATE group_event_participants
361 SET paid = {?}
362 WHERE eid = {?}, uid = {?}, item_id = 0',
363 $old_subs[0]['paid'] + $newly_paid, $eid, $uid);
364 } else {
365 echo "on ne devrait pas passer ici car on a deja un moment 0 des qu'on est ajoute comme participant ";
366 XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
367 VALUES ({?}, {?}, 0, 0, "", {?})',
368 $eid, $uid, $newly_paid);
369 }
370 }
371}
372// }}}
373// TODO : correct this function to be compatible with subscribe() (use $eid, remove useless argument)
374// TODO : correct other calls
375
0337d704 376// {{{ function subscribe_lists_event()
50208d22
SJ
377/** Subscribes user to various event related mailing lists.
378 *
379 * @param $uid: user's id.
7852229b 380 * @param short_name: event's short_name, which corresponds to the beginning of the emails.
50208d22
SJ
381 * @param participate: indicates if the user takes part at the event or not;
382 * -1 means he did not answer, 0 means no, and 1 means yes.
383 * @param paid: has the user already payed anything?
384 * 0 means no, a positive amount means yes.
385 * @param payment: is this function called from a payment page?
386 * If true, only payment related lists should be updated.
387 */
7852229b 388function subscribe_lists_event($uid, $short_name, $participate, $paid, $payment = false)
9193e8f7 389{
7852229b
SJ
390 global $globals;
391 require_once 'emails.inc.php';
0337d704 392
7852229b
SJ
393 if (is_null($short_name)) {
394 return;
0337d704 395 }
396
50208d22
SJ
397 /** If $payment is not null, we do not retrieve the value of $participate,
398 * thus we do not alter participant and absent lists.
399 */
400 if ($payment === true) {
401 if ($paid > 0) {
7e82b545
SJ
402 delete_from_list_alias($uid, $short_name . $globals->xnet->unpayed_list, $globals->xnet->evts_domain, 'event');
403 add_to_list_alias($uid, $short_name . $globals->xnet->payed_list, $globals->xnet->evts_domain, 'event');
50208d22
SJ
404 }
405 } else {
406 switch ($participate) {
407 case -1:
7e82b545
SJ
408 delete_from_list_alias($uid, $short_name . $globals->xnet->participant_list, $globals->xnet->evts_domain, 'event');
409 delete_from_list_alias($uid, $short_name . $globals->xnet->unpayed_list, $globals->xnet->evts_domain, 'event');
410 delete_from_list_alias($uid, $short_name . $globals->xnet->payed_list, $globals->xnet->evts_domain, 'event');
411 add_to_list_alias($uid, $short_name . $globals->xnet->absent_list, $globals->xnet->evts_domain, 'event');
50208d22
SJ
412 break;
413 case 0:
7e82b545
SJ
414 delete_from_list_alias($uid, $short_name . $globals->xnet->participant_list, $globals->xnet->evts_domain, 'event');
415 delete_from_list_alias($uid, $short_name . $globals->xnet->absent_list, $globals->xnet->evts_domain, 'event');
416 delete_from_list_alias($uid, $short_name . $globals->xnet->unpayed_list, $globals->xnet->evts_domain, 'event');
417 delete_from_list_alias($uid, $short_name . $globals->xnet->payed_list, $globals->xnet->evts_domain, 'event');
50208d22
SJ
418 break;
419 case 1:
7e82b545
SJ
420 add_to_list_alias($uid, $short_name . $globals->xnet->participant_list, $globals->xnet->evts_domain, 'event');
421 delete_from_list_alias($uid, $short_name . $globals->xnet->absent_list, $globals->xnet->evts_domain, 'event');
50208d22 422 if ($paid > 0) {
7e82b545
SJ
423 delete_from_list_alias($uid, $short_name . $globals->xnet->unpayed_list, $globals->xnet->evts_domain, 'event');
424 add_to_list_alias($uid, $short_name . $globals->xnet->payed_list, $globals->xnet->evts_domain, 'event');
50208d22 425 } else {
7e82b545
SJ
426 add_to_list_alias($uid, $short_name . $globals->xnet->unpayed_list, $globals->xnet->evts_domain, 'event');
427 delete_from_list_alias($uid, $short_name . $globals->xnet->payed_list, $globals->xnet->evts_domain, 'event');
50208d22
SJ
428 }
429 break;
1cf7d38b 430 }
9193e8f7 431 }
0337d704 432}
433// }}}
434
20c5c7e6 435// {{{ function event_change_shortname()
26ba053e 436function event_change_shortname($page, $eid, $old, $new)
5070a22d 437{
438 global $globals;
7852229b 439 require_once 'emails.inc.php';
5070a22d 440
f56e5e53 441 if (is_null($old)) {
442 $old = '';
443 }
a7de4ef7 444 // Quelques vérifications sur l'alias (caractères spéciaux)
2179ffa2 445 if ($new && !preg_match( "/^[a-zA-Z0-9\-.]{3,20}$/", $new)) {
a7d35093 446 $page->trigError("Le raccourci demandé n'est pas valide.
a7de4ef7 447 Vérifie qu'il comporte entre 3 et 20 caractères
448 et qu'il ne contient que des lettres non accentuées,
449 des chiffres ou les caractères - et .");
5070a22d 450 return $old;
4aae4d2c 451 } elseif ($new && (is_int($new) || ctype_digit($new))) {
940ae3a0
SJ
452 $page->trigError("Le raccourci demandé ne peut être accepté car il
453 ne contient que des chiffres. Rajoute-lui par exemple
454 une lettre.");
455 return $old;
5070a22d 456 }
457
a7de4ef7 458 //vérifier que l'alias n'est pas déja pris
5070a22d 459 if ($new && $old != $new) {
9193e8f7 460 $res = XDB::query('SELECT COUNT(*)
eb41eda9 461 FROM group_events
9193e8f7 462 WHERE short_name = {?}',
463 $new);
5070a22d 464 if ($res->fetchOneCell() > 0) {
a7d35093 465 $page->trigError("Le raccourci demandé est déjà utilisé. Choisis en un autre.");
5070a22d 466 return $old;
467 }
468 }
469
470 if ($old == $new) {
471 return $new;
472 }
473
474 if ($old && $new) {
475 // if had a previous shortname change the old lists
7852229b
SJ
476 foreach (explode(',', $globals->xnet->event_lists) as $suffix) {
477 XDB::execute('UPDATE email_virtual
478 SET email = {?}
479 WHERE type = \'event\' AND email = {?}',
480 $new . $suffix, $old . $suffix);
5070a22d 481 }
7852229b 482
5070a22d 483 return $new;
484 }
485
486 if (!$old && $new) {
487 // if we have a first new short_name create the lists
9ff5b337
SJ
488 $lastid = array();
489 $where = array(
2335f07e
SJ
490 $globals->xnet->participant_list => 'g.nb > 0',
491 $globals->xnet->payed_list => '(g.paid > 0 OR p.amount > 0)',
492 $globals->xnet->unpayed_list => 'g.nb > 0 AND g.paid = 0 AND p.amount IS NULL'
9ff5b337
SJ
493 );
494
7852229b 495 foreach (array($globals->xnet->participant_list, $globals->xnet->payed_list, $globals->xnet->unpayed_list) as $suffix) {
2335f07e
SJ
496 $uids = XDB::fetchColumn('SELECT g.uid
497 FROM group_event_participants AS g
498 INNER JOIN group_events AS e ON (g.eid = e.eid)
499 LEFT JOIN payment_transactions AS p ON (e.paiement_id = p.ref AND g.uid = p.uid)
500 WHERE g.eid = {?} AND ' . $where[$suffix],
7852229b 501 $eid);
7e82b545
SJ
502 foreach ($uids as $uid) {
503 add_to_list_alias($uid, $new . $suffix, $globals->xnet->evts_domain, 'event');
7852229b 504 }
9ff5b337 505 }
2335f07e 506
7852229b
SJ
507 $uids = XDB::fetchColumn('SELECT m.uid
508 FROM group_members AS m
509 LEFT JOIN group_event_participants AS e ON (e.uid = m.uid AND e.eid = {?})
510 WHERE m.asso_id = {?} AND e.uid IS NULL',
511 $eid, $globals->asso('id'));
7e82b545
SJ
512 foreach ($uids as $uid) {
513 add_to_list_alias($uid, $new . $globals->xnet->absent_list, $globals->xnet->evts_domain, 'event');
9ff5b337 514 }
5070a22d 515
516 return $new;
517 }
518
519 if ($old && !$new) {
520 // if we delete the old short name, delete the lists
7852229b
SJ
521 foreach (explode(',', $globals->xnet->event_lists) as $suffix) {
522 delete_list_alias($old . $suffix, $globals->xnet->evts_domain);
5070a22d 523 }
7852229b 524
5070a22d 525 return $new;
526 }
527
528 // cannot happen
529 return $old;
530}
20c5c7e6
SJ
531// }}}
532
533// {{{ function make_event_date()
aa3ef74f 534function make_event_date($debut, $fin)
20c5c7e6 535{
aa3ef74f
AL
536 $start = strtotime($debut);
537 $end = strtotime($fin);
538// $first_day = $e['first_day'];
539// $last_day = $e['last_day'];
540 $first_day = strftime("%d %B %Y", $start);
541 $last_day = strftime("%d %B %Y", $end);
20c5c7e6
SJ
542 $date = "";
543 if ($start && $end != $start) {
544 if ($first_day == $last_day) {
545 $date .= "le " . strftime("%d %B %Y", $start) . " de "
546 . strftime("%H:%M", $start) . " à " . strftime("%H:%M", $end);
547 } else {
548 $date .= "du " . strftime("%d %B %Y à %H:%M", $start)
549 . "\nau " . strftime("%d %B %Y à %H:%M", $end);
550 }
551 } else {
552 $date .= "le " . strftime("%d %B %Y à %H:%M", $start);
553 }
aa3ef74f 554 return $date;
20c5c7e6
SJ
555}
556// }}}
5070a22d 557
448c8cdc 558// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
0337d704 559?>