From 595697054aaa737e11580a9921f58f2009141f6f Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 14 Feb 2009 18:44:06 +0100 Subject: [PATCH] No more auth_user_md5 in events feed. Signed-off-by: Florent Bruneau --- core | 2 +- modules/events/feed.inc.php | 38 ++++++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/core b/core index 0ef5bd4..e94c4a1 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 0ef5bd4bceb37a6ed6a1afb719d403f25c71ef02 +Subproject commit e94c4a1713cc0d63508a5d0ecd2d572f047975fb diff --git a/modules/events/feed.inc.php b/modules/events/feed.inc.php index 6e80063..02bb8be 100644 --- a/modules/events/feed.inc.php +++ b/modules/events/feed.inc.php @@ -31,21 +31,35 @@ class EventFeed extends PlFeed 'events/rss.tpl'); } + private static function nextEvent(PlIterator &$it, PlUser &$user) + { + while ($body = $it->next()) { + $uf = UserFilter::getLegacy($body['promo_min'], $body['promo_max']); + if ($uf->checkUser($user)) { + return $body; + } + } + return null; + } + protected function fetch(PlUser &$user) { global $globals; - return XDB::iterator( - 'SELECT e.id, e.titre AS title, e.texte, e.creation_date AS publication, e.post_id, p.attachmime IS NOT NULL AS photo, - CONCAT(u2.prenom, " ", IF(u2.nom_usage = "", u2.nom, u2.nom_usage), " (X", u2.promo, ")") AS author, - FIND_IN_SET(\'wiki\', e.flags) AS wiki, - CONCAT({?}, "/events#newsid", e.id) AS link - FROM auth_user_md5 AS u - INNER JOIN evenements AS e ON ( (e.promo_min = 0 || e.promo_min <= u.promo) - AND (e.promo_max = 0 || e.promo_max >= u.promo) ) - LEFT JOIN evenements_photo AS p ON (p.eid = e.id) - INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = e.user_id) - WHERE u.user_id = {?} AND FIND_IN_SET("valide", e.flags) - AND peremption >= NOW()', $globals->baseurl, $user->id()); + $events = XDB::iterator('SELECT e.id, e.titre AS title, e.texte, e.creation_date AS publication, e.post_id, + p.attachmime IS NOT NULL AS photo, FIND_IN_SET(\'wiki\', e.flags) AS wiki, + e.user_id, e.promo_min, e.promo_max + FROM evenements AS e + LEFT JOIN evenements_photo AS p ON (p.eid = e.id) + WHERE FIND_IN_SET("valide", e.flags) AND peremption >= NOW()'); + $data = array(); + while ($e = self::nextEvent($events, $user)) { + $author = User::getWithUID($e['user_id']); + $promo = $author->promo(); + $e['author'] = $author->fullName() . ($promo ? ' (' . $promo . ')' : ''); + $e['link'] = $globals->baseurl . '/events#newsid' . $e['id']; + $data[] = $e; + } + return PlIteratorUtils::fromArray($data, 1, true); } } -- 2.1.4