* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-define('PL_DO_AUTH', 300);
-define('PL_FORBIDDEN', 403);
-define('PL_NOT_FOUND', 404);
-define('PL_WIKI', 500);
-define('PL_JSON', 501);
+// Return values for handlers and hooks. This defines the behavior of both the
+// plat/al engine, and the invidivual hooks.
+define('PL_DO_AUTH', 300); // User should be redirected to the login page.
+define('PL_BAD_REQUEST', 400); // Request is not valid, and could not be interpreted.
+define('PL_FORBIDDEN', 403); // User is not allowed to view page (auth or permission error).
+define('PL_NOT_FOUND', 404); // Page doesn't not exist. Engine will try to offer suggestions.
+define('PL_WIKI', 500); // Page is a wiki page, plat/al engine should yield to the wiki engine.
+define('PL_JSON', 501); // Page is valid, but result should be JSON-encoded, not HTML-encoded.
abstract class PlHook
{
$page->assign('platal', $this);
$res = $this->call_hook($page);
switch ($res) {
+ case PL_BAD_REQUEST:
+ $this->mods['core']->handler_400($page);
+ break;
+
case PL_FORBIDDEN:
$this->mods['core']->handler_403($page);
break;
function handlers()
{
return array(
+ '400' => $this->make_hook('400', AUTH_PUBLIC),
'403' => $this->make_hook('403', AUTH_PUBLIC),
'404' => $this->make_hook('404', AUTH_PUBLIC),
'login' => $this->make_hook('login', AUTH_COOKIE),
exit;
}
- function handler_403($page)
+ function handler_400(PlPage& $page)
+ {
+ header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
+ $page->coreTpl('40x.tpl');
+ $page->trigError('Ta requête est invalide.');
+ }
+
+ function handler_403(PlPage& $page)
{
- global $globals;
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
+ $page->coreTpl('40x.tpl');
$page->trigError('Tu n\'as pas les permissions nécessaires pour accéder à cette page.');
- $page->coreTpl('403.tpl');
}
- function handler_404($page)
+ function handler_404(PlPage& $page)
{
- global $globals, $platal;
+ global $platal;
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
$page->coreTpl('404.tpl');
$page->assign('near', $platal->near_hook());