From: x2000habouzit
Date: Sun, 9 Jul 2006 13:06:29 +0000 (+0000)
Subject: migrate rss.php
X-Git-Tag: xorg/0.9.11~492
X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=4da0b8d742e16d461eeb9b50c481f904e816c272;p=platal.git
migrate rss.php
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@404 839d8a87-29fc-0310-9880-83ba4fa771e5
---
diff --git a/htdocs/carnet/rss.php b/htdocs/carnet/rss.php
index 0ed635c..accb694 100644
--- a/htdocs/carnet/rss.php
+++ b/htdocs/carnet/rss.php
@@ -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();
+}
?>
diff --git a/htdocs/login.php b/htdocs/login.php
index db9e672..6de9a2f 100644
--- a/htdocs/login.php
+++ b/htdocs/login.php
@@ -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
index 860388b..0000000
--- a/htdocs/rss.php
+++ /dev/null
@@ -1,35 +0,0 @@
-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();
-?>
diff --git a/include/rss.inc.php b/include/rss.inc.php
index 42b8ca1..10fb3ed 100644
--- a/include/rss.inc.php
+++ b/include/rss.inc.php
@@ -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;
diff --git a/modules/platal.php b/modules/platal.php
index c68f8dc..73a05a6 100644
--- a/modules/platal.php
+++ b/modules/platal.php
@@ -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;
+ }
}
?>
diff --git a/templates/filrss.tpl b/templates/filrss.tpl
index 9d3f250..9312aa0 100644
--- a/templates/filrss.tpl
+++ b/templates/filrss.tpl
@@ -50,7 +50,7 @@ En voici les adresses :
-
Anonces sur la page d'entrée :
-
+
-
Ton carnet polytechnicien :
diff --git a/templates/login.tpl b/templates/login.tpl
index 533a425..e121e63 100644
--- a/templates/login.tpl
+++ b/templates/login.tpl
@@ -144,7 +144,7 @@ Bienvenue {$smarty.session.prenom}
{if $smarty.session.core_rss_hash}
-

+
{else}