From: x2003bruneau Date: Tue, 21 Nov 2006 23:38:29 +0000 (+0000) Subject: Fix events mail aliases behaviour X-Git-Tag: xorg/0.9.12~77 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=9193e8f787838f89112bc58bac49e3394569539d;p=platal.git Fix events mail aliases behaviour git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1121 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/include/validations/paiements.inc.php b/include/validations/paiements.inc.php index 02f1cbe..074c690 100644 --- a/include/validations/paiements.inc.php +++ b/include/validations/paiements.inc.php @@ -69,7 +69,7 @@ class PayReq extends Validate // }}} // {{{ function same_event() - function same_event($evt, $asso_id) + static function same_event($evt, $asso_id) { $wevt = 's:3:"evt";s:'.strlen($evt+"").':"'.$evt.'"'; $wassoid = 's:7:"asso_id";s:'.strlen($asso_id + "").':"'.$asso_id.'"'; diff --git a/include/xnet/page.inc.php b/include/xnet/page.inc.php index 77db604..64185f9 100644 --- a/include/xnet/page.inc.php +++ b/include/xnet/page.inc.php @@ -75,6 +75,7 @@ class XnetPage extends PlatalPage $sub = array(); $sub['liste des groupes'] = 'plan'; $sub['documentation'] = 'Xnet'; + $sub['Signaler un bug'] = array('link' => 'send_bug', 'onclick' => 'send_bug();return false'); $menu["Menu Principal"] = $sub; if (S::logged() && $globals->asso()) { diff --git a/modules/xnetevents.php b/modules/xnetevents.php index 4db6920..cbbb0a3 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -126,7 +126,7 @@ class XnetEventsModule extends PLModule 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) AS inscrit, MAX(ep.paid) AS paid + 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) @@ -231,8 +231,9 @@ class XnetEventsModule extends PLModule // update actual inscriptions $updated = false; + $total = 0; foreach ($subs as $j => $nb) { - if ($nb > 0) { + if ($nb >= 0) { XDB::execute( "REPLACE INTO groupex.evenements_participants VALUES ({?}, {?}, {?}, {?}, {?})", @@ -245,9 +246,10 @@ class XnetEventsModule extends PLModule $eid, S::v("uid"), $j); $updated = $eid; } + $total += $nb; } - if ($updated !== false) { - pl_redirect('events?updated='.$updated); + if ($updated !== false) { + subscribe_lists_event($total, S::i('uid'), $evt); } $page->assign('event', get_event_detail($eid)); } @@ -439,7 +441,7 @@ class XnetEventsModule extends PLModule VALUES ({?}, {?}, '', '', 0)", $eid, 1); } - pl_redirect('events'); + //pl_redirect('events'); } // get a list of all the payment for this asso @@ -536,19 +538,17 @@ class XnetEventsModule extends PLModule if ($nb) { XDB::execute("REPLACE INTO groupex.evenements_participants VALUES ({?}, {?}, {?}, {?}, {?})", - $evt['eid'], $member['uid'], $id, $nb, $paid); - } else { - XDB::execute("DELETE FROM groupex.evenements_participants - WHERE uid = {?} AND eid = {?} AND item_id = {?}", - $member['uid'], $evt['eid'], $id); + $evt['eid'], $member['uid'], $id, $nb, $paid); } } - $res = XDB::query("SELECT uid + $res = XDB::query("SELECT COUNT(uid) AS cnt, SUM(nb) AS nb FROM groupex.evenements_participants - WHERE uid = {?} AND eid = {?}", + WHERE uid = {?} AND eid = {?} + GROUP BY uid", $member['uid'], $evt['eid']); - $u = $res->fetchOneCell(); + $u = $res->fetchOneAssoc(); + $u = $u['cnt'] ? null : $u['nb']; subscribe_lists_event($u, $member['uid'], $evt); } diff --git a/modules/xnetevents/xnetevents.inc.php b/modules/xnetevents/xnetevents.inc.php index 1c3b147..1cc15cc 100644 --- a/modules/xnetevents/xnetevents.inc.php +++ b/modules/xnetevents/xnetevents.inc.php @@ -176,36 +176,54 @@ function get_event_participants($evt, $item_id, $tri, $limit = '') { // }}} // {{{ function subscribe_lists_event() -function subscribe_lists_event($participate, $uid, $evt) { +function subscribe_lists_event($participate, $uid, $evt) +{ + require_once('user.func.inc.php'); global $globals,$page; $participant_list = $evt['participant_list']; $absent_list = $evt['absent_list']; - $email = S::v('forlife'); + $email = get_user_forlife($uid); if ($email) { $email .= '@'.$globals->mail->domain; } else { - $res = XDB::query("SELECT email FROM groupex.membres WHERE uid = {?} AND asso_id = {?}", S::v('uid'), $globals->asso('id')); + $res = XDB::query("SELECT email + FROM groupex.membres + WHERE uid = {?} AND asso_id = {?}", + S::v('uid'), $globals->asso('id')); $email = $res->fetchOneCell(); } - $subscribe = $participate ? $participant_list : (is_member()?$absent_list:0); - $unsubscri = $participate ? $absent_list : $participant_list; - - if ($subscribe) { - XDB::execute( - "REPLACE INTO virtual_redirect VALUES({?},{?})", - $subscribe, $email); + function subscribe($list, $email) + { + if ($list && $email) { + XDB::execute("REPLACE INTO virtual_redirect + VALUES ({?},{?})", + $list, $email); + } } - if ($unsubscri) { - XDB::execute( - "DELETE FROM virtual_redirect WHERE vid = {?} AND redirect = {?}", - $unsubscri, $email); + function unsubscribe($list, $email) + { + if ($list && $email) { + XDB::execute("DELETE FROM virtual_redirect + WHERE vid = {?} AND redirect = {?}", + $list, $email); + } } + if (is_null($participate)) { + unsubscribe($participant_list, $email); + subscribe($absent_list, $email); + } elseif ($participate) { + subscribe($participant_list, $email); + unsubscribe($absent_list, $email); + } else { + unsubscribe($participant_list, $email); + unsubscribe($absent_list, $email); + } } // }}} @@ -224,9 +242,10 @@ function event_change_shortname(&$page, $old, $new) //vérifier que l'alias n'est pas déja pris if ($new && $old != $new) { - $res = XDB::query('SELECT COUNT(*) FROM virtual - WHERE alias LIKE {?}', - $new.'-absents@%'); + $res = XDB::query('SELECT COUNT(*) + FROM groupex.evenements + WHERE short_name = {?}', + $new); if ($res->fetchOneCell() > 0) { $page->trig("Le raccourci demandé est déjà utilisé. Choisis en un autre."); return $old; @@ -242,10 +261,9 @@ function event_change_shortname(&$page, $old, $new) foreach (array('-absents@', '-participants@') as $v) { $v .= $globals->xnet->evts_domain; XDB::execute("UPDATE virtual SET alias = {?} - WHERE type = 'evt' AND alias = {?}", - $new.$v, $old.$v); + WHERE type = 'evt' AND alias = {?}", + $new.$v, $old.$v); } - return $new; }