From 07eb5b0e8b0a50e245fad68758c8f78e89806103 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 14 Feb 2009 18:18:14 +0100 Subject: [PATCH] Port xnetevents (I hope this works). Signed-off-by: Florent Bruneau --- classes/user.php | 47 +++++++-- classes/userfilter.php | 25 ++++- core | 2 +- modules/xnetevents.php | 124 ++++++++-------------- modules/xnetevents/xnetevents.inc.php | 192 ++++++++++++++-------------------- templates/xnetevents/admin.tpl | 44 ++++---- templates/xnetevents/csv.tpl | 2 +- templates/xnetevents/index.tpl | 4 +- 8 files changed, 202 insertions(+), 238 deletions(-) diff --git a/classes/user.php b/classes/user.php index 8d06c94..8d1bb08 100644 --- a/classes/user.php +++ b/classes/user.php @@ -510,21 +510,56 @@ class User extends PlUser } // Fetch a set of users from a list of UIDs - public static function getBulkUsersWithUIDs(array $uids) + public static function getBulkUsersWithUIDs(array $data, $orig = null, $dest = null) { + // Fetch the list of uids + if (is_null($orig)) { + $uids = $data; + } else { + if (is_null($dest)) { + $dest = $orig; + } + $uids = array(); + foreach ($data as $key=>$entry) { + if (isset($entry[$orig])) { + $uids[] = $entry[$orig]; + } + } + } + + // Fetch users if (count($uids) == 0) { - return array(); + return $data; } $fields = self::loadMainFieldsFromUIDs($uids); $table = array(); while (($list = $fields->next())) { $table[$list['uid']] = User::getSilentWithValues(null, $list); } - $users = array(); - foreach ($uids as $key=>$uid) { - $users[$key] = $table[$uid]; + + // Build the result with respect to input order. + if (is_null($orig)) { + $users = array(); + foreach ($uids as $key=>$uid) { + $users[$key] = $table[$uid]; + } + return $users; + } else { + foreach ($data as $key=>$entry) { + if (isset($entry[$orig])) { + $entry[$dest] = $table[$entry[$orig]]; + $data[$key] = $entry; + } + } + return $data; } - return $users; + } + + public static function getBulkUsersFromDB() + { + $args = func_get_args(); + $uids = call_user_func_array(array('XDB', 'fetchColumn'), $args); + return self::getBulkUsersWithUIDs($uids); } } diff --git a/classes/userfilter.php b/classes/userfilter.php index a2e616e..30a7029 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -460,7 +460,7 @@ class UFC_WatchRegistration extends UFC_UserRelated if (count($uids) == 0) { return UserFilterCondition::COND_FALSE; } else { - return '$UID IN (' . implode(', ', $uids) . ')'; + return '$UID IN ' . XDB::formatArray($uids); } } } @@ -482,7 +482,7 @@ class UFC_WatchPromo extends UFC_UserRelated } else { $sube = $uf->addEducationFilter(true, $this->grade); $field = 'pe' . $sube . '.' . UserFilter::promoYear($this->grade); - return $field . ' IN (' . implode(', ', $promos) . ')'; + return $field . ' IN ' . XDB::formatArray($promos); } } } @@ -725,7 +725,7 @@ class UserFilter } $cond = ''; if (!is_null($uids)) { - $cond = ' AND a.uid IN (' . implode(', ', $uids) . ')'; + $cond = ' AND a.uid IN ' . XDB::formatArray($uids); } $fetched = XDB::fetchColumn('SELECT SQL_CALC_FOUND_ROWS a.uid ' . $this->query . $cond . ' @@ -754,8 +754,13 @@ class UserFilter $table = array(); $uids = array(); foreach ($users as $user) { - $uids[] = $user->id(); - $table[$user->id()] = $user; + if ($user instanceof PlUser) { + $uid = $user->id(); + } else { + $uid = $user; + } + $uids[] = $uid; + $table[$uid] = $user; } $fetched = $this->getUIDList($uids, $count, $offset); $output = array(); @@ -813,6 +818,16 @@ class UserFilter return new UserFilter(new UFC_And($min, $max)); } + static public function sortByName() + { + return array(new UFO_Name(self::LASTNAME), new UFO_Name(self::FIRSTNAME)); + } + + static public function sortByPromo() + { + return array(new UFO_Promo(), new UFO_Name(self::LASTNAME), new UFO_Name(self::FIRSTNAME)); + } + static private function getDBSuffix($string) { return preg_replace('/[^a-z0-9]/i', '', $string); diff --git a/core b/core index b5e56a7..0ef5bd4 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit b5e56a710b4bf25ed7b186c2cb9ea6e822db8fa3 +Subproject commit 0ef5bd4bceb37a6ed6a1afb719d403f25c71ef02 diff --git a/modules/xnetevents.php b/modules/xnetevents.php index f5cd0f4..889346e 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -116,20 +116,18 @@ class XnetEventsModule extends PLModule } $page->assign('archive', $archive); - $evenements = XDB::iterator( - "SELECT e.*, LEFT(10, e.debut) AS first_day, LEFT(10, e.fin) AS last_day, - IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10), - 1) AS inscr_open, e.deadline_inscription, - u.nom, u.prenom, u.promo, a.alias, - MAX(ep.nb) IS NOT NULL AS inscrit, MAX(ep.paid) AS paid - FROM groupex.evenements AS e - 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 = {?} - AND archive = " . ($archive ? "1 " : "0 ") - . "GROUP BY e.eid - ORDER BY inscr_open DESC, debut DESC", S::v('uid'), $globals->asso('id')); + $evenements = XDB::iterator('SELECT e.*, LEFT(10, e.debut) AS first_day, LEFT(10, e.fin) 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 groupex.evenements AS e + LEFT JOIN groupex.evenements_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); $evts = array(); $undisplayed_events = 0; @@ -142,14 +140,12 @@ class XnetEventsModule extends PLModule } $e['show_participants'] = ($e['show_participants'] && (is_member() || may_update())); - $res = XDB::query( - "SELECT titre, details, montant, ei.item_id, nb, ep.paid - 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 AND uid = {?}) - WHERE ei.eid = {?}", - S::v('uid'), $e['eid']); - $e['moments'] = $res->fetchAllAssoc(); + $e['moments'] = XDB::fetchAllAssoc('SELECT titre, details, montant, ei.item_id, nb, ep.paid + 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 AND ep.uid = {?}) + WHERE ei.eid = {?}', + S::i('uid'), $e['eid']); $e['topay'] = 0; $e['paid'] = $e['moments'][0]['paid']; @@ -298,7 +294,7 @@ class XnetEventsModule extends PLModule $admin = may_update(); - $tri = (Env::v('order') == 'alpha' ? 'promo, nom, prenom' : 'nom, prenom, promo'); + $tri = (Env::v('order') == 'alpha' ? UserFilter::sortByPromo() : UserFilter::sortByName()); $page->assign('participants', get_event_participants($evt, $item_id, $tri)); @@ -334,7 +330,7 @@ class XnetEventsModule extends PLModule $page->assign('admin', may_update()); if (may_update()) { - $page->assign('participants', get_event_participants($evt, null, 'promo, nom, prenom')); + $page->assign('participants', get_event_participants($evt, null, UserFilter::sortByPromo())); } $page->register_function('display_ical', 'display_ical'); $page->assign_by_ref('e', $evt); @@ -597,63 +593,26 @@ class XnetEventsModule extends PLModule $page->assign('moments', $evt['moments']); } - $tri = (Env::v('order') == 'alpha' ? 'promo, nom, prenom' : 'nom, prenom, promo'); - $whereitemid = is_null($item_id) ? '' : "AND ep.item_id = $item_id"; - $res = XDB::iterRow( - 'SELECT UPPER(SUBSTRING(IF(u.nom IS NULL, m.nom, - IF(u.nom_usage<>"", u.nom_usage, u.nom)), 1, 1)), - COUNT(DISTINCT ep.uid) - FROM groupex.evenements_participants AS ep - INNER JOIN groupex.evenements AS e ON (ep.eid = e.eid) - LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id) - LEFT JOIN auth_user_md5 AS u ON ( u.user_id = ep.uid ) - WHERE ep.eid = {?} '.$whereitemid . ' - GROUP BY UPPER(SUBSTRING(IF(u.nom IS NULL,m.nom,u.nom), 1, 1))', $evt['eid']); - - $alphabet = array(); - $nb_tot = 0; - while (list($char, $nb) = $res->next()) { - $alphabet[ord($char)] = $char; - $nb_tot += $nb; - if (Env::has('initiale') && $char == strtoupper(Env::v('initiale'))) { - $tot = $nb; - } - } - ksort($alphabet); - $page->assign('alphabet', $alphabet); - + $page->assign('alphabet', array()); if ($evt['paiement_id']) { - $res = XDB::iterator( - "SELECT IF(u.nom_usage<>'', u.nom_usage, u.nom) AS nom, u.prenom, - u.promo, a.alias AS email, t.montant - FROM {$globals->money->mpay_tprefix}transactions AS t - INNER JOIN auth_user_md5 AS u ON(t.uid = u.user_id) - INNER JOIN aliases AS a ON (a.id = t.uid AND a.type='a_vie' ) - LEFT JOIN groupex.evenements_participants AS ep ON(ep.uid = t.uid AND ep.eid = {?}) - WHERE t.ref = {?} AND ep.uid IS NULL", - $evt['eid'], $evt['paiement_id']); - $page->assign('oublis', $res->total()); - $page->assign('oubliinscription', $res); - } - - $absents = XDB::iterator("SELECT p.uid, - IF(m.origine = 'X', IF(u.nom_usage != '', u.nom_usage, u.nom), m.nom) AS nom, - IF(m.origine = 'X', u.prenom, u.prenom) AS prenom, - IF(m.origine = 'X', u.promo, m.origine) AS promo, - IF(m.origine = 'X', FIND_IN_SET('femme', u.flags), m.sexe) AS sexe, - IF(m.origine = 'X', a.alias, m.email) AS email - FROM groupex.evenements_participants AS p - INNER JOIN groupex.membres AS m USING(uid) - LEFT JOIN groupex.evenements_participants AS p2 ON (p2.uid = m.uid AND p2.eid = p.eid - AND p2.nb != 0) - LEFT JOIN auth_user_md5 AS u ON (u.user_id = m.uid) - LEFT JOIN aliases AS a ON (a.id = u.user_id AND a.type = 'a_vie') - WHERE p.eid = {?} AND p2.eid IS NULL - " . (Env::v('initiale') ? " AND IF(u.nom IS NULL, m.nom, - IF(u.nom_usage<>'', u.nom_usage, u.nom)) LIKE '" . Env::v('initiale') . "%'" - : "") . " - GROUP BY m.uid - ORDER BY nom, prenom, promo", $evt['eid']); + $infos = User::getBulkUsersWithUIDs( + XDB::fetchAllAssoc('SELECT t.uid, t.montant + FROM ' . $globals->money->mpay_tprefix . 'transactions AS t + LEFT JOIN groupex.evenements_participants AS ep ON(ep.uid = t.uid AND ep.eid = {?}) + WHERE t.ref = {?} AND ep.uid IS NULL', + $evt['eid'], $evt['paiement_id']), + 'uid', 'user'); + $page->assign('oublis', count($infos)); + $page->assign('oubliinscription', $infos); + } + + $absents = User::getBulkUsersFromDB('SELECT p.uid + FROM groupex.evenements_participants AS p + LEFT JOIN groupex.evenements_participants AS p2 ON (p2.uid = p.uid + AND p2.eid = p.eid + AND p2.nb != 0) + WHERE p.eid = {?} AND p2.eid IS NULL + GROUP BY p.uid', $evt['eid']); $ofs = Env::i('offset'); $tot = (Env::v('initiale') ? $tot : $nb_tot); @@ -672,11 +631,10 @@ class XnetEventsModule extends PLModule $page->assign('links', $links); } - $page->assign('absents', $absents); $page->assign('participants', - get_event_participants($evt, $item_id, $tri, - "LIMIT ".($ofs*NB_PER_PAGE).", ".NB_PER_PAGE)); + get_event_participants($evt, $item_id, UserFilter::sortByName(), + NB_PER_PAGE, $ofs * NB_PER_PAGE)); } } diff --git a/modules/xnetevents/xnetevents.inc.php b/modules/xnetevents/xnetevents.inc.php index 45db5b5..57cffaf 100644 --- a/modules/xnetevents/xnetevents.inc.php +++ b/modules/xnetevents/xnetevents.inc.php @@ -27,28 +27,23 @@ function get_event_detail($eid, $item_id = false, $asso_id = null) if (is_null($asso_id)) { $asso_id = $globals->asso('id'); } - $res = XDB::query( - "SELECT SUM(nb) AS nb_tot, COUNT(DISTINCT ep.uid) AS nb, e.*, - IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10), - 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, - a.nom, a.prenom, a.promo, aa.alias - FROM groupex.evenements AS e - INNER JOIN x4dat.auth_user_md5 AS a ON a.user_id = e.organisateur_uid - INNER JOIN x4dat.aliases AS aa ON (aa.type = 'a_vie' AND aa.id = a.user_id) - 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) - 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, {?})) - 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, - '-participants@'.$globals->xnet->evts_domain, - $eid, $eid, $item_id ? $item_id : 1, $asso_id); - + $res = XDB::query('SELECT SUM(nb) AS nb_tot, COUNT(DISTINCT ep.uid) AS nb, e.*, + IF(e.deadline_inscription, + e.deadline_inscription >= LEFT(NOW(), 10), + 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) + 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, {?})) + 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, + '-participants@'.$globals->xnet->evts_domain, + $eid, $eid, $item_id ? $item_id : 1, $asso_id); $evt = $res->fetchOneAssoc(); if (!$evt) { @@ -60,28 +55,24 @@ function get_event_detail($eid, $item_id = false, $asso_id = null) // 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) - WHERE e.eid = {?} - GROUP BY ep.uid", $evt['eid']); + $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) + WHERE e.eid = {?} + GROUP BY ep.uid', $evt['eid']); $evt['nb_tot'] = array_sum($res->fetchColumn()); $evt['titre'] = ''; $evt['item_id'] = 0; } - $res = XDB::query( - "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 AND uid = {?}) - WHERE ei.eid = {?}", - S::v('uid'), $evt['eid']); - $evt['moments'] = $res->fetchAllAssoc(); - + $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 + AND uid = {?}) + WHERE ei.eid = {?}', + S::i('uid'), $evt['eid']); $evt['topay'] = 0; $evt['paid'] = 0; $evt['notify_payment'] = false; @@ -94,12 +85,10 @@ function get_event_detail($eid, $item_id = false, $asso_id = null) $evt['notify_payment'] = $evt['notify_payment'] || $m['notify_payment']; } - $req = XDB::query( - "SELECT montant - FROM {$globals->money->mpay_tprefix}transactions AS t - WHERE ref = {?} AND uid = {?}", $evt['paiement_id'], S::v('uid')); - $montants = $req->fetchColumn(); - + $montants = XDB::fetchColumn('SELECT montant + FROM ' . $globals->money->mpay_tprefix . 'transactions AS t + WHERE ref = {?} AND uid = {?}', + $evt['paiement_id'], S::v('uid')); $evt['telepaid'] = 0; foreach ($montants as $m) { $p = strtr(substr($m, 0, strpos($m, 'EUR')), ',', '.'); @@ -115,85 +104,60 @@ function get_event_detail($eid, $item_id = false, $asso_id = null) // }}} // {{{ function get_event_participants() -function get_event_participants(&$evt, $item_id, $tri, $limit = '') { +function get_event_participants(&$evt, $item_id, array $tri = array(), $count = null, $offset = null) +{ global $globals; - if (Env::has('initiale')) { - $where = 'AND IF(u.nom IS NULL, m.nom, - IF(u.nom_usage<>"", u.nom_usage, u.nom)) - LIKE "'.addslashes(Env::v('initiale')).'%"'; - } else { - $where = ''; - } - $eid = $evt['eid']; $money = $evt['money'] && (function_exists('may_update')) && may_update(); $pay_id = $evt['paiement_id']; - $query = - "SELECT IF(m.origine != 'X',m.nom,IF(u.nom_usage<>'', u.nom_usage, u.nom)) AS nom, - IF(m.origine != 'X',m.prenom,u.prenom) AS prenom, - IF(m.origine != 'X','extérieur',u.promo) AS promo, - IF(m.origine != 'X' OR u.perms = 'pending',m.email,a.alias) AS email, - IF(m.origine != 'X',m.sexe,FIND_IN_SET('femme', u.flags)) AS femme, - m.perms='admin' AS admin, - (m.origine = 'X' OR m.origine IS NULL) AS x, - 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 - INNER JOIN groupex.evenements AS e ON (ep.eid = e.eid) - LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id) - LEFT JOIN auth_user_md5 AS u ON ( u.user_id = ep.uid ) - LEFT JOIN aliases AS a ON ( a.id = ep.uid AND a.type='a_vie' ) - WHERE ep.eid = {?} - ".(($item_id)?" AND item_id = $item_id":"")." - $where - GROUP BY ep.uid - ORDER BY $tri $limit"; + $append = $item_id ? XDB::foramt(' 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 + 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)); + $tab = array(); + foreach ($users as $user) { + $uid = $user->id(); + $tab[$uid] = $query[$uid]; + $tab[$uid]['user'] = $user; + } if ($item_id) { - $res = XDB::query($query, $eid); - return $res->fetchAllAssoc(); + return $tab; } - $res = XDB::iterator($query, $eid); - $tab = array(); - $user = 0; - $evt['adminpaid'] = 0; $evt['telepaid'] = 0; $evt['topay'] = 0; $evt['paid'] = 0; - while ($u = $res->next()) { - if ($u['nb'] == 0) { - continue; - } + foreach ($tab as $uid=>&$u) { $u['adminpaid'] = $u['paid']; $u['montant'] = 0; if ($money && $pay_id) { - $res_ = XDB::query( - "SELECT montant - FROM {$globals->money->mpay_tprefix}transactions AS t - WHERE ref = {?} AND uid = {?}", - $pay_id, $u['uid']); - $montants = $res_->fetchColumn(); + $montants = XDB::fetchColumn('SELECT montant + FROM ' . $globals->money->mpay_tprefix . 'transactions AS t + WHERE ref = {?} AND uid = {?}', + $pay_id, $uid); foreach ($montants as $m) { $p = strtr(substr($m, 0, strpos($m, "EUR")), ",", "."); $u['paid'] += trim($p); } } $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) - WHERE ep.eid = {?} AND ep.uid = {?}", - $eid, $u['uid']); + $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) + WHERE ep.eid = {?} AND ep.uid = {?}', + $eid, $uid); while ($i = $res_->next()) { $u[$i['item_id']] = $i['nb']; $u['montant'] += $i['montant']*$i['nb']; } - $tab[] = $u; $evt['telepaid'] += $u['telepayment']; $evt['adminpaid'] += $u['adminpaid']; $evt['paid'] += $u['paid']; @@ -310,29 +274,27 @@ function event_change_shortname(&$page, $eid, $old, $new) $new.'-participants@'.$globals->xnet->evts_domain); $lastid = XDB::insertId(); - XDB::execute( - "INSERT IGNORE INTO virtual_redirect ( - SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect - FROM groupex.evenements_participants AS ep - LEFT JOIN groupex.membres AS m ON (ep.uid = m.uid) - LEFT JOIN auth_user_md5 AS u ON (u.user_id = ep.uid) - LEFT JOIN aliases AS a ON (a.id = ep.uid AND a.type = 'a_vie') - WHERE ep.eid = {?} AND ep.nb > 0 - GROUP BY ep.uid)", + 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\') + WHERE ep.eid = {?} AND ep.nb > 0 + GROUP BY ep.uid)', $lastid, '@'.$globals->mail->domain, $eid); XDB::execute("INSERT INTO virtual SET type = 'evt', alias = {?}", $new.'-absents@'.$globals->xnet->evts_domain); $lastid = XDB::insertId(); - XDB::execute("INSERT IGNORE INTO virtual_redirect ( - SELECT {?} AS vid, IF(a.alias IS NULL, m.email, CONCAT(a.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 auth_user_md5 AS u ON (u.user_id = m.uid) - LEFT JOIN aliases AS a ON (a.id = m.uid AND a.type = 'a_vie') - WHERE m.asso_id = {?} AND ep.uid IS NULL - GROUP BY m.uid)", + 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') + WHERE m.asso_id = {?} AND ep.uid IS NULL + GROUP BY m.uid)", $lastid, "@".$globals->mail->domain, $eid, $globals->asso('id')); return $new; @@ -360,7 +322,7 @@ function make_event_date(&$e) { $start = strtotime($e['debut']); $end = strtotime($e['fin']); - $first_day = strtotime($e['first_day']); + $first_day = @strtotime($e['first_day']); $last_day = strtotime($e['last_day']); unset($e['debut'], $e['fin'], $e['first_day'], $e['last_day']); diff --git a/templates/xnetevents/admin.tpl b/templates/xnetevents/admin.tpl index 80c3fa7..377a5a6 100644 --- a/templates/xnetevents/admin.tpl +++ b/templates/xnetevents/admin.tpl @@ -83,19 +83,15 @@ Ils ont payé mais ont oublié de s'inscrire : {iterate from=$oubliinscription item=m} - - {if !$m.prenom && !$m.nom} - {$m.email} - {else} - {$m.prenom} {$m.nom} - {/if} + + {profile user=$m.user link=false} - {$m.promo} + {$m.user->promo()} - {icon name=user_suit title="fiche"} - {icon name=vcard title="vcard"} - {icon name=email title="email"} + {icon name=user_suit title="fiche"} + {icon name=vcard title="vcard"} + {icon name=email title="email"} {$m.montant} @@ -141,18 +137,18 @@ Ils ont payé mais ont oublié de s'inscrire : {foreach from=$participants item=m} - {if $is_admin}{/if} - {if $m.femme}•{/if}{if !$m.prenom && !$m.nom}{$m.email}{else}{$m.prenom} {$m.nom}{/if} + {if $is_admin}{/if} + {profile user=$m.user promo=false link=false} {if $is_admin}{/if} - {$m.promo} + {$m.user->promo()} - {if $m.x} - {icon name=user_suit title="fiche"} - {icon name=vcard title="vcard"} - {icon name=email title="email"} + {if $m.user->hasProfile()} + {icon name=user_suit title="fiche"} + {icon name=vcard title="vcard"} + {icon name=email title="email"} {else} - {icon name=email title="email"} + {icon name=email title="email"} {/if} {if $tout} @@ -198,7 +194,7 @@ Ils ont payé mais ont oublié de s'inscrire : {/foreach}

-{if $absents->total()} +{if $absents|@count}
@@ -206,18 +202,18 @@ Ils ont payé mais ont oublié de s'inscrire : - {iterate from=$absents item=m} + {foreach from=$absents item=m} - {/iterate} + {/foreach}
Prénom NOMOrigine
- {if $is_admin}{/if} - {if $m.sexe}•{/if}{$m.prenom} {$m.nom} + {if $is_admin}{/if} + {profile user=$m link=false promo=false} {if $is_admin}{/if} - {$m.promo} + {$m->promo()}
{/if} diff --git a/templates/xnetevents/csv.tpl b/templates/xnetevents/csv.tpl index 1ed7346..f4d206d 100644 --- a/templates/xnetevents/csv.tpl +++ b/templates/xnetevents/csv.tpl @@ -26,7 +26,7 @@ $telepayment}Télépaiement;Liquide/Chèque;{/if}Payé{/if}{else};Nombre{/if} {foreach from=$participants item=m} ; -{$m.nom};{$m.prenom};{$m.promo}{if $tout}{foreach from=$moments item=i};{$m[$i.item_id]}{/foreach}{if $admin && +{$m.user->lastName()};{$m.user->firstName()};{$m.user->promo()}{if $tout}{foreach from=$moments item=i};{$m[$i.item_id]}{/foreach}{if $admin && $money};{$m.montant};{if $telepayment}{$m.telepayment};{$m.adminpaid};{/if}{$m.paid}{/if}{else};{$m.nb}{/if} {/foreach} diff --git a/templates/xnetevents/index.tpl b/templates/xnetevents/index.tpl index 19b858c..95d5abd 100644 --- a/templates/xnetevents/index.tpl +++ b/templates/xnetevents/index.tpl @@ -97,9 +97,7 @@ Annonceur : - - {$e.prenom} {$e.nom} ({$e.promo}) - + {profile user=$e.organisateur_uid promo=true groupperms=false} {if $is_admin || $e.show_participants || ($e.deadline_inscription && $e.inscr_open)} -- 2.1.4