<?php
/***************************************************************************
- * Copyright (C) 2003-2009 Polytechnique.org *
+ * Copyright (C) 2003-2010 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
1) AS inscr_open,
LEFT(10, e.debut) AS start_day, LEFT(10, e.fin) AS last_day,
LEFT(NOW(), 10) AS now,
- ei.titre, al.vid AS absent_list, pl.vid AS participant_list
- FROM groupex.evenements AS e
- INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
- LEFT JOIN groupex.evenements_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
+ ei.titre, al.vid AS absent_list, pl.vid AS participant_list,
+ pyl.vid AS payed_list, bl.vid AS booked_unpayed_list
+ FROM group_events AS e
+ INNER JOIN group_event_items AS ei ON (e.eid = ei.eid)
+ LEFT JOIN group_event_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
LEFT JOIN virtual AS al ON(al.type = \'evt\' AND al.alias = CONCAT(short_name, {?}))
LEFT JOIN virtual AS pl ON(pl.type = \'evt\' AND pl.alias = CONCAT(short_name, {?}))
+ LEFT JOIN virtual AS pyl ON(pyl.type = \'evt\' AND pyl.alias = CONCAT(short_name, {?}))
+ LEFT JOIN virtual AS bl ON(bl.type = \'evt\' AND bl.alias = CONCAT(short_name, {?}))
WHERE (e.eid = {?} OR e.short_name = {?}) AND ei.item_id = {?} AND e.asso_id = {?}
GROUP BY ei.item_id',
'-absents@'.$globals->xnet->evts_domain,
// smart calculation of the total number
if (!$item_id) {
$res = XDB::query('SELECT MAX(nb)
- FROM groupex.evenements AS e
- INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
- LEFT JOIN groupex.evenements_participants AS ep ON (e.eid = ep.eid AND ei.item_id = ep.item_id)
+ FROM group_events AS e
+ INNER JOIN group_event_items AS ei ON (e.eid = ei.eid)
+ LEFT JOIN group_event_participants AS ep ON (e.eid = ep.eid AND ei.item_id = ep.item_id)
WHERE e.eid = {?}
GROUP BY ep.uid', $evt['eid']);
$evt['nb_tot'] = array_sum($res->fetchColumn());
$evt['moments'] = XDB::fetchAllAssoc('SELECT titre, details, montant, ei.item_id, nb,
ep.paid, FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment
- FROM groupex.evenements_items AS ei
- LEFT JOIN groupex.evenements_participants AS ep ON (ep.eid = ei.eid AND ep.item_id = ei.item_id
+ FROM group_event_items AS ei
+ LEFT JOIN group_event_participants AS ep ON (ep.eid = ei.eid AND ep.item_id = ei.item_id
AND uid = {?})
WHERE ei.eid = {?}',
S::i('uid'), $evt['eid']);
$evt['notify_payment'] = $evt['notify_payment'] || $m['notify_payment'];
}
- $montants = XDB::fetchColumn('SELECT montant
- FROM ' . $globals->money->mpay_tprefix . 'transactions AS t
+ $montants = XDB::fetchColumn('SELECT amount
+ FROM payment_transactions AS t
WHERE ref = {?} AND uid = {?}',
$evt['paiement_id'], S::v('uid'));
$evt['telepaid'] = 0;
$money = $evt['money'] && (function_exists('may_update')) && may_update();
$pay_id = $evt['paiement_id'];
- $append = $item_id ? XDB::foramt(' AND ep.item_id = {?}', $item_id) : '';
+ $append = $item_id ? XDB::format(' AND ep.item_id = {?}', $item_id) : '';
$query = XDB::fetchAllAssoc('uid', 'SELECT ep.uid, SUM(ep.paid) AS paid, SUM(ep.nb) AS nb,
FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment
- FROM groupex.evenements_participants AS ep
+ FROM group_event_participants AS ep
WHERE ep.eid = {?} AND nb > 0 ' . $append . '
GROUP BY ep.uid', $eid);
- $uf = new UserFilter(new UFC_True(), $tri);
- $users = User::getBulkUsersWithUIDs($uf->filter(array_keys($query), $count, $offset));
+ $uf = new UserFilter(new PFC_True(), $tri);
+ $users = User::getBulkUsersWithUIDs($uf->filter(array_keys($query), new PlLimit($count, $offset)));
$tab = array();
foreach ($users as $user) {
$uid = $user->id();
$u['adminpaid'] = $u['paid'];
$u['montant'] = 0;
if ($money && $pay_id) {
- $montants = XDB::fetchColumn('SELECT montant
- FROM ' . $globals->money->mpay_tprefix . 'transactions AS t
+ $montants = XDB::fetchColumn('SELECT amount
+ FROM payment_transactions AS t
WHERE ref = {?} AND uid = {?}',
$pay_id, $uid);
foreach ($montants as $m) {
}
$u['telepayment'] = $u['paid'] - $u['adminpaid'];
$res_ = XDB::iterator('SELECT ep.nb, ep.item_id, ei.montant
- FROM groupex.evenements_participants AS ep
- INNER JOIN groupex.evenements_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
+ FROM group_event_participants AS ep
+ INNER JOIN group_event_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
WHERE ep.eid = {?} AND ep.uid = {?}',
$eid, $uid);
while ($i = $res_->next()) {
// }}}
// {{{ function subscribe_lists_event()
-function subscribe_lists_event($participate, $uid, $evt, $paid, $payment = null)
+/** Subscribes user to various event related mailing lists.
+ *
+ * @param $uid: user's id.
+ * @param evt: events data, in particular ids of the lists at stake.
+ * @param participate: indicates if the user takes part at the event or not;
+ * -1 means he did not answer, 0 means no, and 1 means yes.
+ * @param paid: has the user already payed anything?
+ * 0 means no, a positive amount means yes.
+ * @param payment: is this function called from a payment page?
+ * If true, only payment related lists should be updated.
+ */
+function subscribe_lists_event($uid, $evt, $participate, $paid, $payment = false)
{
- global $globals;
- $page =& Platal::page();
-
$participant_list = $evt['participant_list'];
$absent_list = $evt['absent_list'];
$unpayed_list = $evt['booked_unpayed_list'];
$payed_list = $evt['payed_list'];
$user = User::getSilent($uid);
- if ($user) {
- $email = $user->forlifeEmail();
- } else {
- $res = XDB::query("SELECT email
- FROM groupex.membres
- WHERE uid = {?} AND asso_id = {?}",
- $uid, $globals->asso('id'));
- $email = $res->fetchOneCell();
- }
+ $email = $user->forlifeEmail();
function subscribe($list, $email)
{
if ($list && $email) {
- XDB::execute("REPLACE INTO virtual_redirect
- VALUES ({?},{?})",
+ XDB::execute('REPLACE INTO virtual_redirect
+ VALUES ({?}, {?})',
$list, $email);
}
}
function unsubscribe($list, $email)
{
if ($list && $email) {
- XDB::execute("DELETE FROM virtual_redirect
- WHERE vid = {?} AND redirect = {?}",
+ XDB::execute('DELETE FROM virtual_redirect
+ WHERE vid = {?} AND redirect = {?}',
$list, $email);
}
}
- if (is_null($payment)) {
- if (is_null($participate)) {
+ /** If $payment is not null, we do not retrieve the value of $participate,
+ * thus we do not alter participant and absent lists.
+ */
+ if ($payment === true) {
+ if ($paid > 0) {
+ unsubscribe($unpayed_list, $email);
+ subscribe($payed_list, $email);
+ }
+ } else {
+ switch ($participate) {
+ case -1:
unsubscribe($participant_list, $email);
+ unsubscribe($unpayed_list, $email);
+ unsubscribe($payed_list, $email);
subscribe($absent_list, $email);
- } elseif ($participate) {
- subscribe($participant_list, $email);
- unsubscribe($absent_list, $email);
- } else {
+ break;
+ case 0:
unsubscribe($participant_list, $email);
unsubscribe($absent_list, $email);
+ unsubscribe($unpayed_list, $email);
+ unsubscribe($payed_list, $email);
+ break;
+ case 1:
+ subscribe($participant_list, $email);
+ unsubscribe($absent_list, $email);
+ if ($paid > 0) {
+ unsubscribe($unpayed_list, $email);
+ subscribe($payed_list, $email);
+ } else {
+ subscribe($unpayed_list, $email);
+ unsubscribe($payed_list, $email);
+ }
+ break;
}
}
- if ($paid > 0) {
- unsubscribe($unpayed_list, $email);
- subscribe($payed_list, $email);
- } else {
- unsubscribe($payed_list, $email);
- subscribe($unpayed_list, $email);
- }
}
// }}}
et qu'il ne contient que des lettres non accentuées,
des chiffres ou les caractères - et .");
return $old;
- } elseif ($new && ctype_digit($new)) {
+ } elseif ($new && (is_int($new) || ctype_digit($new))) {
$page->trigError("Le raccourci demandé ne peut être accepté car il
ne contient que des chiffres. Rajoute-lui par exemple
une lettre.");
//vérifier que l'alias n'est pas déja pris
if ($new && $old != $new) {
$res = XDB::query('SELECT COUNT(*)
- FROM groupex.evenements
+ FROM group_events
WHERE short_name = {?}',
$new);
if ($res->fetchOneCell() > 0) {
foreach (array('-participants@', '-paye@', '-participants-non-paye@') as $v) {
XDB::execute("INSERT IGNORE INTO virtual_redirect (
SELECT {?} AS vid, IF(al.alias IS NULL, a.email, CONCAT(al.alias, {?})) AS redirect
- FROM groupex.evenements_participants AS ep
- LEFT JOIN accounts AS a ON (ep.uid = a.uid)
- LEFT JOIN aliases AS al ON (al.id = a.uid AND al.type = 'a_vie')
+ FROM group_event_participants AS ep
+ LEFT JOIN accounts AS a ON (ep.uid = a.uid)
+ LEFT JOIN aliases AS al ON (al.uid = a.uid AND al.type = 'a_vie')
WHERE ep.eid = {?} AND " . $where[$v] . "
GROUP BY ep.uid)",
$lastid[$v], '@' . $globals->mail->domain, $eid);
}
XDB::execute("INSERT IGNORE INTO virtual_redirect (
SELECT {?} AS vid, IF(al.alias IS NULL, a.email, CONCAT(al.alias, {?})) AS redirect
- FROM groupex.membres AS m
- LEFT JOIN groupex.evenements_participants AS ep ON (ep.uid = m.uid AND ep.eid = {?})
- LEFT JOIN accounts AS a ON (a.uid = m.uid)
- LEFT JOIN aliases AS al ON (al.id = a.uid AND al.type = 'a_vie')
+ FROM group_members AS m
+ LEFT JOIN accounts AS a ON (a.uid = m.uid)
+ LEFT JOIN aliases AS al ON (al.uid = a.uid AND al.type = 'a_vie')
+ LEFT JOIN group_event_participants AS ep ON (ep.uid = m.uid AND ep.eid = {?})
WHERE m.asso_id = {?} AND ep.uid IS NULL
GROUP BY m.uid)",
$lastid['-absents@'], '@' . $globals->mail->domain, $eid, $globals->asso('id'));