From: Daniel Rudolf Date: Wed, 30 Jan 2013 18:10:02 +0000 (+0100) Subject: Separating checkModules() and checkPermissions() in AbstractAction X-Git-Tag: 2.0.0_Beta_1~525^2~1^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fcf384f2a59fe8b2693238b1163f8285820008f0;p=GitHub%2FWoltLab%2FWCF.git Separating checkModules() and checkPermissions() in AbstractAction Actually nothing was changed, just separating the code into own methods to make them overridable, just like in AbstractPage. --- diff --git a/wcfsetup/install/files/lib/action/AbstractAction.class.php b/wcfsetup/install/files/lib/action/AbstractAction.class.php index fc25fc3031..db400b1541 100644 --- a/wcfsetup/install/files/lib/action/AbstractAction.class.php +++ b/wcfsetup/install/files/lib/action/AbstractAction.class.php @@ -58,25 +58,47 @@ abstract class AbstractAction implements IAction { } /** - * @see wcf\action\IAction::execute() + * @see wcf\action\IAction::checkModules() */ - public function execute() { - // check if active user is logged in - if ($this->loginRequired && !WCF::getUser()->userID) { - throw new PermissionDeniedException(); - } + public function checkModules() { + // call checkModules event + EventHandler::getInstance()->fireAction($this, 'checkModules'); // check modules - if (!empty($this->neededModules)) { - foreach ($this->neededModules as $module) { - if (!defined($module) || !constant($module)) throw new IllegalLinkException(); + foreach ($this->neededModules as $module) { + if (!defined($module) || !constant($module)) { + throw new IllegalLinkException(); } } + } + + /** + * @see wcf\action\IAction::checkPermissions() + */ + public function checkPermissions() { + // call checkPermissions event + EventHandler::getInstance()->fireAction($this, 'checkPermissions'); // check permission if (!empty($this->neededPermissions)) { WCF::getSession()->checkPermissions($this->neededPermissions); } + } + + /** + * @see wcf\action\IAction::execute() + */ + public function execute() { + // check if active user is logged in + if ($this->loginRequired && !WCF::getUser()->userID) { + throw new PermissionDeniedException(); + } + + // check modules + $this->checkModules(); + + // check permissions + $this->checkPermissions(); // call execute event EventHandler::getInstance()->fireAction($this, 'execute'); diff --git a/wcfsetup/install/files/lib/action/IAction.class.php b/wcfsetup/install/files/lib/action/IAction.class.php index b3b2b57c02..4d6e9aa1d3 100644 --- a/wcfsetup/install/files/lib/action/IAction.class.php +++ b/wcfsetup/install/files/lib/action/IAction.class.php @@ -23,6 +23,16 @@ interface IAction { */ public function readParameters(); + /** + * Checks the modules of this action. + */ + public function checkModules(); + + /** + * Checks the permissions of this action. + */ + public function checkPermissions(); + /** * Executes this action. */