From 1b10d4381ab0ac56bf86ede403d8a9ebafd28996 Mon Sep 17 00:00:00 2001 From: nbm Date: Thu, 29 Sep 2005 11:14:17 +0000 Subject: [PATCH] Don't use checkSession in dispatchers - rather verify session directly and allow the dispatcher to set its own access level. --- lib/dispatcher.inc.php | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/dispatcher.inc.php b/lib/dispatcher.inc.php index 39ca21c..63d2cc1 100644 --- a/lib/dispatcher.inc.php +++ b/lib/dispatcher.inc.php @@ -59,19 +59,53 @@ class KTDispatcher { } class KTStandardDispatcher extends KTDispatcher { + var $bLogonRequired = true; + var $bAdminRequired = false; + function permissionDenied () { print "Permission denied"; } function dispatch () { - if (!checkSession()) { - exit($this->permissionDenied()); + $session = new Session(); + $sessionStatus = $session->verify($bDownload); + + if ($bLogonRequired !== false) { + if (empty($_SESSION['userID'])) { + $this->permissionDenied(); + exit(0); + } } + + if ($bAdminRequired !== false) { + if (!Permission::userIsSystemAdministrator($_SESSION['userID'])) { + $this->permissionDenied(); + exit(0); + } + } + + if ($this->check() !== true) { + $this->permissionDenied(); + exit(0); + } + return parent::dispatch(); } + + function check() { + return true; + } + + function handleOutput($data) { + global $main; + $main->bFormDisabled = true; + $main->setCentralPayload($data); + $main->render(); + } } class KTAdminDispatcher extends KTStandardDispatcher { + var $bAdminRequired = true; } ?> -- libgit2 0.21.4