Add Platal::error404() and Platal::error403() to run corresponding handlers.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 17 Aug 2008 21:25:04 +0000 (23:25 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 17 Aug 2008 21:25:04 +0000 (23:25 +0200)
This functions are for internal use only (mostly for the wiki engine).
when developping an handler, you MUST return PL_FORBIDDEN or PL_NOT_FOUND to
generate the corresponding error.

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/platal.php
classes/plfeed.php
include/wiki.engine.inc.php

index 96cba8c..858ab98 100644 (file)
@@ -308,6 +308,24 @@ abstract class Platal
         $page->run();
     }
 
+    public function error403()
+    {
+        $page =& self::page();
+
+        $this->__mods['core']->handler_403($page);
+        $page->assign('platal', $this);
+        $page->run();
+    }
+
+    public function error404()
+    {
+        $page =& self::page();
+
+        $this->__mods['core']->handler_404($page);
+        $page->assign('platal', $this);
+        $page->run();
+    }
+
     public function on_subscribe($forlife, $uid, $promo, $pass)
     {
         $args = func_get_args();
index cd2d469..78af758 100644 (file)
@@ -100,7 +100,7 @@ abstract class PlFeed implements PlIterator
         $user = Platal::session()->tokenAuth($login, $token);
         if (empty($user)) {
             if ($require_auth) {
-                $page->kill("Authentication required");
+                return PL_FORBIDDEN;
             } else {
                 $user = null;
             }
index b65abe0..d8cb60a 100644 (file)
@@ -99,7 +99,8 @@ if ($feed) {
         $wikiAll = "<p>La page de wiki $n n'existe pas. "
                  . "Il te suffit de <a href='" . str_replace('.', '/', $n) . "?action=edit'>l'éditer</a></p>";
     } else {
-        $page->coreTpl('404.tpl');
+        global $platal;
+        $platal->error404();
     }
 }