No more auth_user_md5 in events feed.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 14 Feb 2009 17:44:06 +0000 (18:44 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 14 Feb 2009 17:44:06 +0000 (18:44 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
core
modules/events/feed.inc.php

diff --git a/core b/core
index 0ef5bd4..e94c4a1 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 0ef5bd4bceb37a6ed6a1afb719d403f25c71ef02
+Subproject commit e94c4a1713cc0d63508a5d0ecd2d572f047975fb
index 6e80063..02bb8be 100644 (file)
@@ -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);
     }
 }