diff --git a/lib/dispatcher.inc.php b/lib/dispatcher.inc.php index d55246a..e49da96 100644 --- a/lib/dispatcher.inc.php +++ b/lib/dispatcher.inc.php @@ -204,11 +204,16 @@ class KTStandardDispatcher extends KTDispatcher { } function permissionDenied () { - global $default; - - $msg = '

' . _kt('Permission Denied') . '

'; - $msg .= '

' . _kt('If you feel that this is incorrect, please report both the action and your username to a system administrator.') . '

'; - + // handle anonymous specially. + if ($this->oUser->getId() == -2) { + redirect(KTUtil::ktLink('login.php','',sprintf("redirect=%s&errorMessage=%s", urlencode($_SERVER['REQUEST_URI']), urlencode(_kt("You must be logged in to perform this action"))))); exit(0); + } + + global $default; + + $msg = '

' . _kt('Permission Denied') . '

'; + $msg .= '

' . _kt('If you feel that this is incorrect, please report both the action and your username to a system administrator.') . '

'; + $this->oPage->setPageContents($msg); $this->oPage->setUser($this->oUser); $this->oPage->hideSection(); diff --git a/view.php b/view.php index af8c91a..b544e5b 100755 --- a/view.php +++ b/view.php @@ -111,7 +111,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { return $this->do_error(); } else if (!Permission::userHasDocumentReadPermission($oDocument)) { $this->oPage->addError(_kt('You are not allowed to view this document')); - return $this->do_error(); + return $this->permissionDenied(); } } @@ -350,7 +350,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { if (!Permission::userHasDocumentReadPermission($oDocument)) { // FIXME inconsistent. $this->oPage->addError(_kt('You are not allowed to view this document')); - return $this->do_error(); + return $this->permissionDenied(); } $this->oDocument =& $oDocument; @@ -457,10 +457,8 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { return $oTemplate->render($aTemplateData); } - /* we have a lot of error handling. this one is the absolute final failure. */ function do_error() { - return ''; // allow normal rendering of errors. - // FIXME show something useful / generic. + return ' '; // don't actually do anything. } function do_startComparison() { @@ -487,7 +485,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { if (!Permission::userHasDocumentReadPermission($oDocument)) { // FIXME inconsistent. $this->oPage->addError(_kt('You are not allowed to view this document')); - return $this->do_error(); + return $this->permissionDenied(); } $this->oDocument =& $oDocument; $this->oPage->setSecondaryTitle($oDocument->getName());