openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit 775a1361f0bb2865dcf96a7d5fce53715249f80d
parent 08b8c1047e1b7d1f79d1b146fb991652701fadd5
Author: Jan Dankert <develop@jandankert.de>
Date:   Sun, 14 Mar 2021 22:29:56 +0100

Refactoring: Clearer access check.

Diffstat:
Mmodules/cms/Dispatcher.class.php | 29+----------------------------
Mmodules/cms/action/Action.class.php | 13+++++++------
Mmodules/cms/action/BaseAction.class.php | 2+-
Mmodules/cms/action/ConfigurationAction.class.php | 17++++++++++-------
Mmodules/cms/action/ElementAction.class.php | 22++++++++++++++++++++--
Mmodules/cms/action/GroupAction.class.php | 13+++++++++++--
Mmodules/cms/action/GrouplistAction.class.php | 12++++++++++--
Mmodules/cms/action/LanguageAction.class.php | 19+++++++++++++++++--
Mmodules/cms/action/LanguagelistAction.class.php | 19+++++++++++++++++--
Mmodules/cms/action/LoginAction.class.php | 7++++---
Mmodules/cms/action/ModelAction.class.php | 21+++++++++++++++++++--
Mmodules/cms/action/ModellistAction.class.php | 18+++++++++++++++---
Mmodules/cms/action/ObjectAction.class.php | 12+++++-------
Mmodules/cms/action/PageelementAction.class.php | 14++++++++++----
Mmodules/cms/action/ProfileAction.class.php | 8++++++--
Mmodules/cms/action/ProjectAction.class.php | 12++++++++++--
Mmodules/cms/action/ProjectlistAction.class.php | 10++++++++++
Mmodules/cms/action/SearchAction.class.php | 8+++++---
Mmodules/cms/action/TemplateAction.class.php | 22+++++++++++++++++++---
Mmodules/cms/action/TemplatelistAction.class.php | 20++++++++++++++++++--
Mmodules/cms/action/UserAction.class.php | 14++++++++++++--
Mmodules/cms/action/UsergroupAction.class.php | 13+++++++++++--
Mmodules/cms/action/UserlistAction.class.php | 13+++++++++++--
Mmodules/cms/action/profile/ProfileAvailableAction.class.php | 7+++++--
Mmodules/cms/action/profile/ProfilePingAction.class.php | 7+++++--
Mmodules/cms/action/project/ProjectEditAction.class.php | 21+++++++++++++++++++--
Mmodules/cms/action/project/ProjectHistoryAction.class.php | 8++++++--
Mmodules/cms/action/projectlist/ProjectlistAddAction.class.php | 9+++++++--
Mmodules/cms/action/projectlist/ProjectlistEditAction.class.php | 2--
Mmodules/cms/action/projectlist/ProjectlistHistoryAction.class.php | 2--
Mmodules/cms/ui/action/IndexAction.class.php | 7+++++--
Mmodules/cms/ui/action/TitleAction.class.php | 5++++-
Mmodules/cms/ui/action/TreeAction.class.php | 7+++++--
Mmodules/cms/ui/action/UsergroupAction.class.php | 7++++---
34 files changed, 309 insertions(+), 111 deletions(-)

diff --git a/modules/cms/Dispatcher.class.php b/modules/cms/Dispatcher.class.php @@ -143,33 +143,6 @@ class Dispatcher return $result; } - /** - * Prüft, ob die Actionklasse aufgerufen werden darf. - * - * @param $do Action - * @throws SecurityException falls der Aufruf nicht erlaubt ist. - */ - private function checkAccess($do) - { - switch (@$do->security) { - case Action::SECURITY_GUEST: - // Ok. - break; - case Action::SECURITY_USER: - if (!is_object($do->currentUser)) - throw new SecurityException( TextMessage::create('No user logged in, but this action ${0} requires a valid user',[$this->request->__toString()])); - break; - case Action::SECURITY_ADMIN: - if (!is_object($do->currentUser) || !$do->currentUser->isAdmin) - throw new SecurityException(TextMessage::create('This action ${0} requires administration privileges, but user ${1} is not an admin',[ - $this->request->__toString(), - @$do->currentUser->name - ])); - break; - default: - } - - } private function checkPostToken() { @@ -341,7 +314,7 @@ class Dispatcher $do->request = $this->request; $do->init(); - $this->checkAccess($do); + $do->checkAccess(); // POST-Request => ...Post() wird aufgerufen. // GET-Request => ...View() wird aufgerufen. diff --git a/modules/cms/action/Action.class.php b/modules/cms/action/Action.class.php @@ -9,7 +9,9 @@ use cms\model\User; use logger\Logger; use util\Cookie; use util\ClassUtils; +use util\exception\SecurityException; use util\Session; +use util\text\TextMessage; /** @@ -24,18 +26,17 @@ use util\Session; * @package openrat.actions * @abstract */ -class Action +abstract class Action { - const SECURITY_GUEST = 1; // Jeder (auch nicht angemeldete) dürfen diese Aktion ausführen - const SECURITY_USER = 2; // Angemeldete Benutzer dürfen diese Aktion ausführen - const SECURITY_ADMIN = 3; // Nur Administratoren dürfen diese Aktion ausführen - const NOTICE_OK = 'ok'; const NOTICE_INFO = 'info'; const NOTICE_WARN = 'warning'; const NOTICE_ERROR = 'error'; - public $security = self::SECURITY_USER; // Default. + /** + * Checks if the actual action is allowed. + */ + abstract function checkAccess(); protected $templateVars = [ 'errors' => [], diff --git a/modules/cms/action/BaseAction.class.php b/modules/cms/action/BaseAction.class.php @@ -5,7 +5,7 @@ namespace cms\action; /** */ -class BaseAction extends Action +abstract class BaseAction extends Action { public function __construct() diff --git a/modules/cms/action/ConfigurationAction.class.php b/modules/cms/action/ConfigurationAction.class.php @@ -19,6 +19,7 @@ namespace cms\action; // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. use cms\base\DefaultConfig; +use util\exception\SecurityException; use util\Session; /** @@ -29,8 +30,6 @@ use util\Session; */ class ConfigurationAction extends BaseAction { - public $security = Action::SECURITY_ADMIN; - /** * Konstruktor */ @@ -80,9 +79,13 @@ class ConfigurationAction extends BaseAction return $conf; } -} - - + /** + * User must be an administration. + */ + public function checkAccess() { + if ( ! $this->userIsAdmin() ) + throw new SecurityException(); + } -?>- \ No newline at end of file +}+ \ No newline at end of file diff --git a/modules/cms/action/ElementAction.class.php b/modules/cms/action/ElementAction.class.php @@ -7,10 +7,12 @@ use cms\base\Configuration; use cms\model\BaseObject; use cms\model\Element; use cms\model\Folder; +use cms\model\Permission; use cms\model\Project; use cms\model\Template; use ReflectionClass; use ReflectionProperty; +use util\exception\SecurityException; use util\Text; @@ -21,8 +23,6 @@ use util\Text; */ class ElementAction extends BaseAction { - public $security = Action::SECURITY_USER; - /** * @var Element */ @@ -50,5 +50,23 @@ class ElementAction extends BaseAction $this->setTemplateVar( 'elementid' ,$this->element->elementid ); } + + + /** + * User must be an project administrator. + */ + public function checkAccess() { + $template = new Template( $this->element->templateid ); + $template->load(); + $project = new Project( $template->projectid ); + $rootFolderId = $project->getRootObjectId(); + + $rootFolder = new Folder( $rootFolderId ); + $rootFolder->load(); + + if ( ! $rootFolder->hasRight( Permission::ACL_PROP ) ) + throw new SecurityException(); + } + } diff --git a/modules/cms/action/GroupAction.class.php b/modules/cms/action/GroupAction.class.php @@ -8,6 +8,7 @@ use cms\model\Group; use cms\model\Language; use cms\model\Project; use cms\model\User; +use util\exception\SecurityException; // OpenRat Content Management System // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de @@ -35,8 +36,6 @@ use cms\model\User; class GroupAction extends BaseAction { - public $security = Action::SECURITY_ADMIN; - /** * @var Group */ @@ -57,4 +56,14 @@ class GroupAction extends BaseAction $this->setTemplateVar( 'groupid',$this->group->groupid ); } + + /** + * User must be an administration. + */ + public function checkAccess() { + if ( ! $this->userIsAdmin() ) + throw new SecurityException(); + } + + } \ No newline at end of file diff --git a/modules/cms/action/GrouplistAction.class.php b/modules/cms/action/GrouplistAction.class.php @@ -3,6 +3,7 @@ namespace cms\action; use cms\model\Group; +use util\exception\SecurityException; // OpenRat Content Management System // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de @@ -32,12 +33,19 @@ use cms\model\Group; class GrouplistAction extends BaseAction { - public $security = Action::SECURITY_ADMIN; - function __construct() { parent::__construct(); } + /** + * User must be an administration. + */ + public function checkAccess() { + if ( ! $this->userIsAdmin() ) + throw new SecurityException(); + } + + } \ No newline at end of file diff --git a/modules/cms/action/LanguageAction.class.php b/modules/cms/action/LanguageAction.class.php @@ -3,7 +3,11 @@ namespace cms\action; use cms\base\Configuration; +use cms\model\Folder; use cms\model\Language; +use cms\model\Permission; +use cms\model\Project; +use util\exception\SecurityException; // OpenRat Content Management System // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de @@ -31,8 +35,6 @@ use cms\model\Language; */ class LanguageAction extends BaseAction { - public $security = Action::SECURITY_USER; - /** * Zu bearbeitende Sprache, wird im Kontruktor instanziiert * @type Language @@ -57,5 +59,18 @@ class LanguageAction extends BaseAction } + /** + * User must be an project administrator. + */ + public function checkAccess() { + $project = new Project( $this->language->projectid ); + $rootFolderId = $project->getRootObjectId(); + + $rootFolder = new Folder( $rootFolderId ); + $rootFolder->load(); + + if ( ! $rootFolder->hasRight( Permission::ACL_PROP ) ) + throw new SecurityException(); + } } \ No newline at end of file diff --git a/modules/cms/action/LanguagelistAction.class.php b/modules/cms/action/LanguagelistAction.class.php @@ -3,9 +3,12 @@ namespace cms\action; use cms\base\Configuration; +use cms\model\Folder; use cms\model\Language; +use cms\model\Permission; use cms\model\Project; use language\Messages; +use util\exception\SecurityException; use util\Html; @@ -35,8 +38,6 @@ use util\Html; */ class LanguagelistAction extends BaseAction { - public $security = Action::SECURITY_USER; - /** * @var Project */ @@ -58,4 +59,18 @@ class LanguagelistAction extends BaseAction $this->project = new Project( $this->request->getId()); } + + /** + * User must be an project administrator. + */ + public function checkAccess() { + $rootFolderId = $this->project->getRootObjectId(); + + $rootFolder = new Folder( $rootFolderId ); + $rootFolder->load(); + + if ( ! $rootFolder->hasRight( Permission::ACL_PROP ) ) + throw new SecurityException(); + } + } \ No newline at end of file diff --git a/modules/cms/action/LoginAction.class.php b/modules/cms/action/LoginAction.class.php @@ -51,9 +51,6 @@ use util\text\TextMessage; class LoginAction extends BaseAction { - public $security = Action::SECURITY_GUEST; - - public function __construct() { parent::__construct(); @@ -151,6 +148,10 @@ class LoginAction extends BaseAction session_regenerate_id(true); } + + public function checkAccess() { + return true; + } } diff --git a/modules/cms/action/ModelAction.class.php b/modules/cms/action/ModelAction.class.php @@ -2,8 +2,12 @@ namespace cms\action; +use cms\model\Folder; use cms\model\Model; +use cms\model\Permission; +use cms\model\Project; use language\Messages; +use util\exception\SecurityException; // OpenRat Content Management System @@ -32,8 +36,6 @@ use language\Messages; */ class ModelAction extends BaseAction { - public $security = Action::SECURITY_USER; - /** * @var Model */ @@ -53,4 +55,19 @@ class ModelAction extends BaseAction $this->model->load(); } + + /** + * User must be an project administrator. + */ + public function checkAccess() { + $project = new Project( $this->model->projectid ); + $rootFolderId = $project->getRootObjectId(); + + $rootFolder = new Folder( $rootFolderId ); + $rootFolder->load(); + + if ( ! $rootFolder->hasRight( Permission::ACL_PROP ) ) + throw new SecurityException(); + } + } \ No newline at end of file diff --git a/modules/cms/action/ModellistAction.class.php b/modules/cms/action/ModellistAction.class.php @@ -2,8 +2,11 @@ namespace cms\action; +use cms\model\Folder; use cms\model\Model; +use cms\model\Permission; use cms\model\Project; +use util\exception\SecurityException; use util\Html; // OpenRat Content Management System @@ -37,9 +40,6 @@ class ModellistAction extends BaseAction */ protected $project; - public $security = Action::SECURITY_USER; - - function __construct() { parent::__construct(); @@ -53,5 +53,17 @@ class ModellistAction extends BaseAction } + /** + * User must be an project administrator. + */ + public function checkAccess() { + $rootFolderId = $this->project->getRootObjectId(); + + $rootFolder = new Folder( $rootFolderId ); + $rootFolder->load(); + + if ( ! $rootFolder->hasRight( Permission::ACL_PROP ) ) + throw new SecurityException(); + } } \ No newline at end of file diff --git a/modules/cms/action/ObjectAction.class.php b/modules/cms/action/ObjectAction.class.php @@ -27,9 +27,6 @@ use util\Session; class ObjectAction extends BaseAction { - - public $security = Action::SECURITY_GUEST; - private $objectid; /** @@ -61,7 +58,6 @@ class ObjectAction extends BaseAction $this->setBaseObject( $baseObject ); - $this->checkRight( $this->getRequiredPermission() ); } @@ -92,9 +88,11 @@ class ObjectAction extends BaseAction * * @return bool */ - protected function checkRight( $permission ) { + public function checkAccess() { + + $requiredPermission = $this->getRequiredPermission(); - if ( ! $this->baseObject->hasRight($permission ) ) - throw new SecurityException('User has insufficient permissions ('.$permission.')' ); + if ( ! $this->baseObject->hasRight($requiredPermission) ) + throw new SecurityException('User has insufficient permissions ('.$requiredPermission.')' ); } } \ No newline at end of file diff --git a/modules/cms/action/PageelementAction.class.php b/modules/cms/action/PageelementAction.class.php @@ -6,10 +6,8 @@ use cms\base\Language as L; use cms\generator\PageContext; use cms\generator\PageGenerator; use cms\generator\Producer; -use cms\generator\PublishEdit; use cms\generator\Publisher; use cms\generator\PublishOrder; -use cms\generator\PublishPreview; use cms\generator\ValueContext; use cms\generator\ValueGenerator; use cms\model\Permission; @@ -57,8 +55,6 @@ use util\Transformer; */ class PageelementAction extends BaseAction { - public $security = Action::SECURITY_GUEST; - /** * Enthaelt das Seitenobjekt * @type Page @@ -718,4 +714,14 @@ class PageelementAction extends BaseAction return ''; } } + + + /** + * User must have read rights to the page. + */ + public function checkAccess() { + if ( ! $this->page->hasRight( Permission::ACL_READ ) ) + throw new SecurityException(); + } + } diff --git a/modules/cms/action/ProfileAction.class.php b/modules/cms/action/ProfileAction.class.php @@ -27,6 +27,7 @@ use language\Language; use language\Messages; use logger\Logger; use security\Base2n; +use util\exception\SecurityException; use util\exception\ValidationException; use util\Mail; use util\Session; @@ -38,8 +39,6 @@ use util\UIUtils; */ class ProfileAction extends BaseAction { - public $security = Action::SECURITY_USER; - protected $user; /** @@ -87,4 +86,9 @@ class ProfileAction extends BaseAction } + public function checkAccess() { + if ( !$this->user ) + throw new SecurityException(); + } + } \ No newline at end of file diff --git a/modules/cms/action/ProjectAction.class.php b/modules/cms/action/ProjectAction.class.php @@ -35,8 +35,6 @@ use util\exception\SecurityException; */ class ProjectAction extends BaseAction { - public $security = Action::SECURITY_ADMIN; - /** * @var Project */ @@ -99,4 +97,14 @@ class ProjectAction extends BaseAction return $hostname; } + + + /** + * User must be an administrator. + */ + public function checkAccess() { + if ( ! $this->userIsAdmin() ) + throw new SecurityException(); + } + } \ No newline at end of file diff --git a/modules/cms/action/ProjectlistAction.class.php b/modules/cms/action/ProjectlistAction.class.php @@ -39,4 +39,14 @@ class ProjectlistAction extends BaseAction parent::__construct(); } + + /** + * Listing projects is allowed for all users. + * + * @return bool + */ + public function checkAccess() { + + return true; + } } \ No newline at end of file diff --git a/modules/cms/action/SearchAction.class.php b/modules/cms/action/SearchAction.class.php @@ -48,8 +48,6 @@ class SearchAction extends BaseAction const FLAG_DESCRIPTION = 8; const FLAG_VALUE = 16; - public $security = Action::SECURITY_USER; - /** * leerer Kontruktor */ @@ -192,5 +190,9 @@ class SearchAction extends BaseAction return $resultList; } - + + + public function checkAccess() { + return true; + } } \ No newline at end of file diff --git a/modules/cms/action/TemplateAction.class.php b/modules/cms/action/TemplateAction.class.php @@ -3,7 +3,7 @@ namespace cms\action; namespace cms\action; -use cms\generator\PublishPublic; +use cms\model\Folder; use cms\model\Permission; use cms\model\Element; use cms\model\Page; @@ -11,6 +11,7 @@ use cms\model\Project; use cms\model\Template; use cms\model\TemplateModel; use language\Messages; +use util\exception\SecurityException; use util\exception\ValidationException; use util\Html; use util\Session; @@ -42,8 +43,6 @@ use util\Session; class TemplateAction extends BaseAction { - public $security = Action::SECURITY_USER; - /** * @var Template */ @@ -74,4 +73,21 @@ class TemplateAction extends BaseAction } } + + + + /** + * User must be an project administrator. + */ + public function checkAccess() { + $project = new Project( $this->template->projectid ); + $rootFolderId = $project->getRootObjectId(); + + $rootFolder = new Folder( $rootFolderId ); + $rootFolder->load(); + + if ( ! $rootFolder->hasRight( Permission::ACL_PROP ) ) + throw new SecurityException(); + } + } \ No newline at end of file diff --git a/modules/cms/action/TemplatelistAction.class.php b/modules/cms/action/TemplatelistAction.class.php @@ -3,9 +3,12 @@ namespace cms\action; use cms\model\Element; +use cms\model\Folder; +use cms\model\Permission; use cms\model\Project; use cms\model\Template; use language\Messages; +use util\exception\SecurityException; // OpenRat Content Management System // Copyright (C) 2002-2009 Jan Dankert @@ -33,8 +36,6 @@ use language\Messages; class TemplatelistAction extends BaseAction { - public $security = Action::SECURITY_USER; - /** * @var Project */ @@ -53,4 +54,19 @@ class TemplatelistAction extends BaseAction $this->project = new Project( $this->request->getId()); } + + + /** + * User must be an project administrator. + */ + public function checkAccess() { + + $rootFolderId = $this->project->getRootObjectId(); + $rootFolder = new Folder( $rootFolderId ); + $rootFolder->load(); + + if ( ! $rootFolder->hasRight( Permission::ACL_PROP ) ) + throw new SecurityException(); + } + } \ No newline at end of file diff --git a/modules/cms/action/UserAction.class.php b/modules/cms/action/UserAction.class.php @@ -13,6 +13,7 @@ use cms\model\User; use language\Messages; use security\Base2n; use security\Password; +use util\exception\SecurityException; use util\exception\ValidationException; use util\Mail; use util\Session; @@ -44,8 +45,6 @@ use util\Session; */ class UserAction extends BaseAction { - public $security = Action::SECURITY_ADMIN; - /** * @var User */ @@ -66,4 +65,15 @@ class UserAction extends BaseAction $this->user->load(); $this->setTemplateVar('userid',$this->user->userid); } + + + + /** + * User must be an administration. + */ + public function checkAccess() { + if ( ! $this->userIsAdmin() ) + throw new SecurityException(); + } + } \ No newline at end of file diff --git a/modules/cms/action/UsergroupAction.class.php b/modules/cms/action/UsergroupAction.class.php @@ -18,6 +18,7 @@ namespace cms\action; // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +use util\exception\SecurityException; /** @@ -26,10 +27,18 @@ namespace cms\action; */ class UsergroupAction extends BaseAction { - public $security = Action::SECURITY_ADMIN; - function __construct() { parent::__construct(); } + + + /** + * User must be an administration. + */ + public function checkAccess() { + if ( ! $this->userIsAdmin() ) + throw new SecurityException(); + } + } \ No newline at end of file diff --git a/modules/cms/action/UserlistAction.class.php b/modules/cms/action/UserlistAction.class.php @@ -18,6 +18,7 @@ namespace cms\action; // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +use util\exception\SecurityException; /** @@ -28,11 +29,19 @@ namespace cms\action; */ class UserlistAction extends BaseAction { - public $security = Action::SECURITY_ADMIN; - function __construct() { parent::__construct(); } + + /** + * User must be an administration. + */ + public function checkAccess() { + if ( ! $this->userIsAdmin() ) + throw new SecurityException(); + } + + } \ No newline at end of file diff --git a/modules/cms/action/profile/ProfileAvailableAction.class.php b/modules/cms/action/profile/ProfileAvailableAction.class.php @@ -7,8 +7,6 @@ use util\ClassName; class ProfileAvailableAction extends ProfileAction implements Method { - public $security = Action::SECURITY_GUEST; // Available for all - public function view() { $action = $this->request->getText('queryaction'); @@ -63,4 +61,9 @@ class ProfileAvailableAction extends ProfileAction implements Method { public function post() { } + + + public function checkAccess() { + return true; + } } diff --git a/modules/cms/action/profile/ProfilePingAction.class.php b/modules/cms/action/profile/ProfilePingAction.class.php @@ -6,11 +6,14 @@ use cms\action\ProfileAction; class ProfilePingAction extends ProfileAction implements Method { - public $security = Action::SECURITY_GUEST; - public function view() { + // Only visible in API requests. $this->setTemplateVar('pong',1); } public function post() { } + + public function checkAccess() { + return true; + } } diff --git a/modules/cms/action/project/ProjectEditAction.class.php b/modules/cms/action/project/ProjectEditAction.class.php @@ -3,11 +3,12 @@ namespace cms\action\project; use cms\action\Action; use cms\action\Method; use cms\action\ProjectAction; +use cms\model\Folder; +use cms\model\Permission; +use util\exception\SecurityException; class ProjectEditAction extends ProjectAction implements Method { - public $security = Action::SECURITY_GUEST; - public function view() { $this->setTemplateVar('name' ,$this->project->name); @@ -17,4 +18,20 @@ class ProjectEditAction extends ProjectAction implements Method { } public function post() { } + + + + /** + * the root object must be readable by the current user. + */ + public function checkAccess() { + $rootFolderId = $this->project->getRootObjectId(); + + $rootFolder = new Folder( $rootFolderId ); + $rootFolder->load(); + + if ( ! $rootFolder->hasRight( Permission::ACL_PROP ) ) + throw new SecurityException(); + } + } diff --git a/modules/cms/action/project/ProjectHistoryAction.class.php b/modules/cms/action/project/ProjectHistoryAction.class.php @@ -8,8 +8,6 @@ use cms\model\Permission; class ProjectHistoryAction extends ProjectAction implements Method { - public $security = Action::SECURITY_GUEST; - public function view() { $result = $this->project->getLastChanges(); @@ -21,6 +19,12 @@ class ProjectHistoryAction extends ProjectAction implements Method { $this->setTemplateVar('timeline', $result); } + public function post() { } + + public function checkAccess() { + return true; // rights for every search result are respected in view() + } + } diff --git a/modules/cms/action/projectlist/ProjectlistAddAction.class.php b/modules/cms/action/projectlist/ProjectlistAddAction.class.php @@ -9,8 +9,6 @@ use util\exception\SecurityException; class ProjectlistAddAction extends ProjectlistAction implements Method { - public $security = Action::SECURITY_ADMIN; - public function view() { $this->setTemplateVar( 'projects',Project::getAllProjects() ); @@ -42,4 +40,11 @@ class ProjectlistAddAction extends ProjectlistAction implements Method { //} } + + + public function checkAccess() + { + if ( ! $this->userIsAdmin() ) + throw new SecurityException(); + } } diff --git a/modules/cms/action/projectlist/ProjectlistEditAction.class.php b/modules/cms/action/projectlist/ProjectlistEditAction.class.php @@ -9,8 +9,6 @@ use cms\model\Project; class ProjectlistEditAction extends ProjectlistAction implements Method { - public $security = Action::SECURITY_GUEST; - public function view() { // Projekte ermitteln $list = array(); diff --git a/modules/cms/action/projectlist/ProjectlistHistoryAction.class.php b/modules/cms/action/projectlist/ProjectlistHistoryAction.class.php @@ -9,8 +9,6 @@ use cms\model\Project; class ProjectlistHistoryAction extends ProjectlistAction implements Method { - public $security = Action::SECURITY_GUEST; - public function view() { $result = Project::getAllLastChanges(); diff --git a/modules/cms/ui/action/IndexAction.class.php b/modules/cms/ui/action/IndexAction.class.php @@ -33,9 +33,7 @@ use util\Session; */ class IndexAction extends Action { - public $security = Action::SECURITY_GUEST; - /** * Konstruktor */ @@ -76,4 +74,9 @@ class IndexAction extends Action },$csp,array_keys($csp) ))); } + + public function checkAccess() { + return true; // Allowed for all + } + } diff --git a/modules/cms/ui/action/TitleAction.class.php b/modules/cms/ui/action/TitleAction.class.php @@ -36,5 +36,8 @@ use util\Html; */ class TitleAction extends Action { - public $security = Action::SECURITY_GUEST; + public function checkAccess() { + return true; // Allowed for all + } + } diff --git a/modules/cms/ui/action/TreeAction.class.php b/modules/cms/ui/action/TreeAction.class.php @@ -48,11 +48,14 @@ use util\Session; class TreeAction extends BaseAction { - public $security = Action::SECURITY_GUEST; - public function __construct() { parent::__construct(); } + + public function checkAccess() { + return true; // Allowed for all + } + } diff --git a/modules/cms/ui/action/UsergroupAction.class.php b/modules/cms/ui/action/UsergroupAction.class.php @@ -33,9 +33,6 @@ use util\Session; */ class UsergroupAction extends Action { - public $security = Action::SECURITY_ADMIN; - - /** * Konstruktor */ @@ -44,4 +41,8 @@ class UsergroupAction extends Action parent::__construct(); } + + public function checkAccess() { + return true; // Allowed for all + } }