Commit 1b10d4381ab0ac56bf86ede403d8a9ebafd28996
1 parent
79bf71aa
Don't use checkSession in dispatchers - rather verify session directly
and allow the dispatcher to set its own access level. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3674 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
36 additions
and
2 deletions
lib/dispatcher.inc.php
| ... | ... | @@ -59,19 +59,53 @@ class KTDispatcher { |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | class KTStandardDispatcher extends KTDispatcher { |
| 62 | + var $bLogonRequired = true; | |
| 63 | + var $bAdminRequired = false; | |
| 64 | + | |
| 62 | 65 | function permissionDenied () { |
| 63 | 66 | print "Permission denied"; |
| 64 | 67 | } |
| 65 | 68 | |
| 66 | 69 | function dispatch () { |
| 67 | - if (!checkSession()) { | |
| 68 | - exit($this->permissionDenied()); | |
| 70 | + $session = new Session(); | |
| 71 | + $sessionStatus = $session->verify($bDownload); | |
| 72 | + | |
| 73 | + if ($bLogonRequired !== false) { | |
| 74 | + if (empty($_SESSION['userID'])) { | |
| 75 | + $this->permissionDenied(); | |
| 76 | + exit(0); | |
| 77 | + } | |
| 69 | 78 | } |
| 79 | + | |
| 80 | + if ($bAdminRequired !== false) { | |
| 81 | + if (!Permission::userIsSystemAdministrator($_SESSION['userID'])) { | |
| 82 | + $this->permissionDenied(); | |
| 83 | + exit(0); | |
| 84 | + } | |
| 85 | + } | |
| 86 | + | |
| 87 | + if ($this->check() !== true) { | |
| 88 | + $this->permissionDenied(); | |
| 89 | + exit(0); | |
| 90 | + } | |
| 91 | + | |
| 70 | 92 | return parent::dispatch(); |
| 71 | 93 | } |
| 94 | + | |
| 95 | + function check() { | |
| 96 | + return true; | |
| 97 | + } | |
| 98 | + | |
| 99 | + function handleOutput($data) { | |
| 100 | + global $main; | |
| 101 | + $main->bFormDisabled = true; | |
| 102 | + $main->setCentralPayload($data); | |
| 103 | + $main->render(); | |
| 104 | + } | |
| 72 | 105 | } |
| 73 | 106 | |
| 74 | 107 | class KTAdminDispatcher extends KTStandardDispatcher { |
| 108 | + var $bAdminRequired = true; | |
| 75 | 109 | } |
| 76 | 110 | |
| 77 | 111 | ?> | ... | ... |