Moving to GitHub.
[platal.git] / modules / forums.php
index a3ebc22..914fafc 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -24,13 +24,13 @@ class ForumsModule extends PLModule
     function handlers()
     {
         return array(
-            'banana'         => $this->make_hook('banana',      AUTH_COOKIE),
-            'banana/rss'     => $this->make_hook('rss',         AUTH_PUBLIC, 'user', NO_HTTPS),
-            'admin/forums'   => $this->make_hook('forums_bans', AUTH_MDP,    'admin'),
+            'banana'       => $this->make_hook('banana',      AUTH_COOKIE, 'forums'),
+            'banana/rss'   => $this->make_hook('rss',         AUTH_PUBLIC, 'forums', NO_HTTPS),
+            'admin/forums' => $this->make_hook('forums_bans', AUTH_PASSWD, 'admin'),
         );
     }
 
-    function handler_banana(&$page, $group = null, $action = null, $artid = null)
+    function handler_banana($page, $group = null, $action = null, $artid = null)
     {
         $page->changeTpl('banana/index.tpl');
         $page->setTitle('Forums & PA');
@@ -44,36 +44,30 @@ class ForumsModule extends PLModule
         run_banana($page, 'ForumsBanana', $get);
     }
 
-    function handler_rss(&$page, $group, $alias, $hash, $file = null)
+    function handler_rss($page, $group, $alias, $hash, $file = null)
     {
         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;
     }
 
-    function handler_forums_bans(&$page, $action = 'list', $id = null)
+    function handler_forums_bans($page, $action = 'list', $id = null)
     {
         $page->setTitle('Administration - Bannissements des forums');
         $page->assign('title', 'Gestion des mises au ban');
-        $table_editor = new PLTableEditor('admin/forums','forums.innd','id_innd');
+        $table_editor = new PLTableEditor('admin/forums','forum_innd','id_innd');
         $table_editor->add_sort_field('priority', true, true);
         $table_editor->describe('read_perm','lecture',true);
         $table_editor->describe('write_perm','écriture',true);
@@ -83,7 +77,7 @@ class ForumsModule extends PLModule
         $page->changeTpl('forums/admin.tpl');
     }
 
-    static function run_banana(&$page, $params = null)
+    static function run_banana($page, $params = null)
     {
         $page->changeTpl('banana/index.tpl');
         $page->setTitle('Forums & PA');
@@ -93,5 +87,5 @@ class ForumsModule extends PLModule
     }
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>