Bye Bye crappy init_rss.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 23 Dec 2008 22:17:52 +0000 (23:17 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 23 Dec 2008 22:17:52 +0000 (23:17 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/rss.inc.php [deleted file]
modules/carnet.php
modules/forums.php
templates/carnet/mescontacts.tpl

diff --git a/include/rss.inc.php b/include/rss.inc.php
deleted file mode 100644 (file)
index c9655d9..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-function init_rss($template, $alias, $hash, $require_uid = true)
-{
-    $page =& Platal::page();
-    $page->changeTpl($template, NO_SKIN);
-    $user = Platal::session()->tokenAuth($alias, $hash);
-    if (is_null($user)) {
-        if ($require_uid) {
-            exit;
-        } else {
-            $user = null;
-        }
-    }
-
-    if ($template) {
-        $page->assign('rss_hash', $hash);
-        header('Content-Type: application/rss+xml; charset=utf8');
-    }
-    return $user;
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index b57f994..a60d869 100644 (file)
@@ -263,16 +263,13 @@ class CarnetModule extends PLModule
 
     function handler_ical(&$page, $alias = null, $hash = null)
     {
-        require_once 'rss.inc.php';
-        $uid = init_rss(null, $alias, $hash, false);
-        if (S::logged()) {
-            if (!$uid) {
-                $uid = S::i('uid');
-            } else if ($uid != S::i('uid')) {
-                send_warning_email("Récupération d\'un autre utilisateur ($uid)");
+        $user = Platal::session()->tokenAuth($alias, $hash);
+        if (is_null($user)) {
+            if (S::logged()) {
+                $user == S::user();
+            } else {
+                return PL_FORBIDDEN;
             }
-        } else if (!$uid) {
-            exit;
         }
 
         require_once 'ical.inc.php';
@@ -290,7 +287,7 @@ class CarnetModule extends PLModule
                    FROM contacts      AS c
              INNER JOIN auth_user_md5 AS u ON (u.user_id = c.contact)
              INNER JOIN aliases       AS a ON (u.user_id = a.id AND a.type = \'a_vie\')
-                  WHERE c.uid = {?}', $uid);
+                  WHERE c.uid = {?}', $user->id());
 
         $annivs = Array();
         while (list($prenom, $nom, $promo, $naissance, $end, $ts, $hruid) = $res->next()) {
index 9c8ac06..2999659 100644 (file)
@@ -48,23 +48,17 @@ class ForumsModule extends PLModule
     {
         if (is_null($file)) {
             if (is_null($hash)) {
-                exit;
+                return PL_FORBIDDEN;
             }
             $this->handler_rss($page, null, $group, $alias, $hash);
         }
-        require_once('rss.inc.php');
-        $uid = init_rss(null, $alias, $hash);
-        if (!$uid) {
-            exit;
+        $user = Platal::session()->tokenAuth($alias, $hash);
+        if (is_null($user)) {
+            return PL_FORBIDDEN;
         }
-        $res = XDB::query("SELECT id AS uid, alias AS forlife
-                             FROM aliases
-                            WHERE type = 'a_vie' AND id = {?}", $uid);
-        $row = $res->fetchOneAssoc();
-        $_SESSION = array_merge($row, $_SESSION);
 
         require_once 'banana/forum.inc.php';
-        $banana = new ForumsBanana(S::user(), array('group' => $group, 'action' => 'rss2'));
+        $banana = new ForumsBanana($user, array('group' => $group, 'action' => 'rss2'));
         $banana->run();
         exit;
     }
index 49addfd..81812de 100644 (file)
@@ -64,7 +64,7 @@
   </li>
   <li>
     {icon name=calendar_view_day title='Anniversaires'} 
-    <a href="carnet/contacts/ical/{$smarty.session.hruid}/{$smarty.session.core_rss_hash}/anniv-x.ics" title="Anniversaires">
+    <a href="carnet/contacts/ical/{$smarty.session.hruid}/{$smarty.session.token}/anniv-x.ics" title="Anniversaires">
       Le calendrier des anniversaires
     </a>
   </li>