migrate rss.php
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 9 Jul 2006 13:06:29 +0000 (13:06 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 9 Jul 2006 13:06:29 +0000 (13:06 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@404 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/carnet/rss.php
htdocs/login.php
htdocs/rss.php [deleted file]
include/rss.inc.php
modules/platal.php
templates/filrss.tpl
templates/login.tpl

index 0ed635c..accb694 100644 (file)
@@ -23,9 +23,11 @@ require_once('xorg.inc.php');
 require_once('rss.inc.php');
 require_once('notifs.inc.php');
 
-$uid    = init_rss('carnet/rss.tpl');
-$notifs = new Notifs($uid, false);
-$page->assign('notifs', $notifs);
+if (preg_match(',^/([^/]+)/([^/]+)\.xml$,', $_SERVER['PATH_INFO'], $m)) {
+    $uid    = init_rss('carnet/rss.tpl', $m[1], $m[2]);
+    $notifs = new Notifs($uid, false);
+    $page->assign('notifs', $notifs);
 
-$page->run();
+    $page->run();
+}
 ?> 
index db9e672..6de9a2f 100644 (file)
@@ -69,7 +69,9 @@ $page->assign_by_ref('publicite', $publicite);
 // ajout du lien RSS
 
 if (Session::has('core_rss_hash')) {
-    $page->assign('xorg_rss', Array("title" => "Polytechnique.org :: News", "href" => "/rss.php/".Session::get('forlife')."/".Session::get('core_rss_hash').".xml"));
+    $page->assign('xorg_rss',
+                  array("title" => "Polytechnique.org :: News",
+                        "href" => "/rss/".Session::get('forlife')."/".Session::get('core_rss_hash')."/rss.xml"));
 }
 
 // cache les evenements lus et raffiche les evenements a relire
diff --git a/htdocs/rss.php b/htdocs/rss.php
deleted file mode 100644 (file)
index 860388b..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 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                *
- ***************************************************************************/
-
-require_once('xorg.inc.php');
-require_once('rss.inc.php');
-
-$uid = init_rss('rss.tpl');
-
-$rss = $globals->xdb->iterator(
-        'SELECT  e.id, e.titre, e.texte, e.creation_date
-           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) )
-          WHERE  u.user_id = {?} AND FIND_IN_SET(e.flags, "valide") AND peremption >= NOW()', $uid);
-$page->assign('rss', $rss);
-
-$page->run();
-?> 
index 42b8ca1..10fb3ed 100644 (file)
@@ -37,24 +37,23 @@ function to_rss ($s)
     }
 }
 
-function init_rss($template)
+function init_rss($template, $alias, $hash)
 {
     global $page, $globals;
     new_nonhtml_page($template, AUTH_PUBLIC);
     $page->register_modifier('rss_date', '_rss_encode_date');
     $page->default_modifiers = Array('@to_rss');
 
-    if (preg_match(',^/([^/]+)/([^/]+)\.xml$,', $_SERVER['PATH_INFO'], $m)) {
-        $alias = $m[1];
-        $hash  = $m[2];
-        $res = $globals->xdb->query(
-            'SELECT  a.id
-               FROM  aliases         AS a
-         INNER JOIN  auth_user_quick AS q ON ( a.id = q.user_id AND q.core_rss_hash = {?} )
-              WHERE  a.alias = {?} AND a.type != "homonyme"', $hash, $alias);
-        $uid = $res->fetchOneCell();
+    $res = $globals->xdb->query(
+        'SELECT  a.id
+           FROM  aliases         AS a
+     INNER JOIN  auth_user_quick AS q ON ( a.id = q.user_id AND q.core_rss_hash = {?} )
+          WHERE  a.alias = {?} AND a.type != "homonyme"', $hash, $alias);
+    $uid = $res->fetchOneCell();
+
+    if (empty($uid)) {
+        exit;
     }
-    if (empty($uid)) { exit; }
 
     header('Content-Type: application/rss+xml; charset=utf8');
     return $uid;
index c68f8dc..73a05a6 100644 (file)
@@ -24,11 +24,17 @@ class PlatalModule extends PLModule
     function handlers()
     {
         return array(
-            'prefs'       => $this->make_hook('prefs', AUTH_COOKIE),
-            'prefs/rss'   => $this->make_hook('rss', AUTH_COOKIE),
-            'password'    => $this->make_hook('password', AUTH_MDP),
-            'tmpPWD'      => $this->make_hook('tmpPWD', AUTH_PUBLIC),
-            'skin'        => $this->make_hook('skin', AUTH_COOKIE),
+            // Preferences thingies
+            'prefs'       => $this->make_hook('prefs',     AUTH_COOKIE),
+            'prefs/rss'   => $this->make_hook('prefs_rss', AUTH_COOKIE),
+            'skin'        => $this->make_hook('skin',      AUTH_COOKIE),
+
+            // password related thingies
+            'password'    => $this->make_hook('password',  AUTH_MDP),
+            'tmpPWD'      => $this->make_hook('tmpPWD',    AUTH_PUBLIC),
+
+            // happenings related thingies
+            'rss'         => $this->make_hook('rss',       AUTH_PUBLIC),
         );
     }
 
@@ -77,7 +83,7 @@ class PlatalModule extends PLModule
         return PL_OK;
     }
 
-    function handler_rss(&$page)
+    function handler_prefs_rss(&$page)
     {
         global $globals;
 
@@ -184,6 +190,26 @@ class PlatalModule extends PLModule
         $page->assign_by_ref('skins', $globals->xdb->iterator($sql));
         return PL_OK;
     }
+
+    function handler_rss(&$page, $user = null, $hash = null)
+    {
+        global $globals;
+
+        require_once 'rss.inc.php';
+
+        $uid = init_rss('rss.tpl', $user, $hash);
+
+        $rss = $globals->xdb->iterator(
+                'SELECT  e.id, e.titre, e.texte, e.creation_date
+                   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) )
+                  WHERE  u.user_id = {?} AND FIND_IN_SET(e.flags, "valide")
+                                         AND peremption >= NOW()', $uid);
+        $page->assign('rss', $rss);
+
+        return PL_OK;
+    }
 }
 
 ?>
index 9d3f250..9312aa0 100644 (file)
@@ -50,7 +50,7 @@ En voici les adresses :
 <ul>
   <li>
   Anonces sur la page d'entrĂ©e :
-  <a href='{rel}/rss.php/{$smarty.session.forlife}/{$smarty.session.core_rss_hash}.xml'><img src='{rel}/images/rssicon.gif' alt='fil rss' title='fil RSS'/></a>
+  <a href='{rel}/rss/{$smarty.session.forlife}/{$smarty.session.core_rss_hash}/rss.xml'><img src='{rel}/images/rssicon.gif' alt='fil rss' title='fil RSS'/></a>
   </li>
   <li>
   Ton carnet polytechnicien :
index 533a425..e121e63 100644 (file)
@@ -144,7 +144,7 @@ Bienvenue {$smarty.session.prenom}
   </p>
   {if $smarty.session.core_rss_hash}
   <div class="right">
-    <a href='{rel}/rss.php/{$smarty.session.forlife}/{$smarty.session.core_rss_hash}.xml'><img src='{rel}/images/rssicon.gif' alt='fil rss' /></a>
+    <a href='{rel}/rss/{$smarty.session.forlife}/{$smarty.session.core_rss_hash}/rss.xml'><img src='{rel}/images/rssicon.gif' alt='fil rss' /></a>
   </div>
   {else}
   <div class="right">