diff --git a/library/Nmc/Controller/Action.php b/library/Nmc/Controller/Action.php index 62533a545ff02a165d72777df24076f200ee26e0..10d4f7d310e024c6034702a7f374e13892e2b4f1 100644 --- a/library/Nmc/Controller/Action.php +++ b/library/Nmc/Controller/Action.php @@ -32,17 +32,6 @@ abstract class Nmc_Controller_Action extends Zend_Controller_Action { */ protected $_pluginBroker; - public function run(Zend_Controller_Dispatcher_Interface $dispatcher, - Zend_Controller_Dispatcher_Token $action) - { - $this->_action = $action; - $this->_params = $action->getParams(); - $this->_preAction(); - $returnValue = parent::run($dispatcher, $action); - $this->_postAction(); - return $returnValue; - } - protected function _registerPlugin(Nmc_Controller_Action_Plugin_Interface $plugin) { if(! $this->_pluginBroker instanceof Nmc_Controller_Action_Plugin_Broker) { @@ -58,17 +47,17 @@ abstract class Nmc_Controller_Action extends Zend_Controller_Action { } } - protected function _preAction() + public function preDispatch() { if($this->_pluginBroker instanceof Nmc_Controller_Action_Plugin_Broker) { - $this->_pluginBroker->preAction($this, $this->_action); + $this->_pluginBroker->preAction($this, $this->getRequest(), $this->getResponse()); } } - protected function _postAction() + public function postDispatch() { if($this->_pluginBroker instanceof Nmc_Controller_Action_Plugin_Broker) { - $this->_pluginBroker->postAction($this, $this->_action); + $this->_pluginBroker->postAction($this, $this->getRequest(), $this->getResponse()); } } diff --git a/library/Nmc/Controller/Action/Plugin/Authorize.php b/library/Nmc/Controller/Action/Plugin/Authorize.php index 308a4c3df4e4838ca8447e07899bd07279c4f067..4520e694cc8f1a45c541129f06fb5f525c85dc2a 100644 --- a/library/Nmc/Controller/Action/Plugin/Authorize.php +++ b/library/Nmc/Controller/Action/Plugin/Authorize.php @@ -13,16 +13,23 @@ class Nmc_Controller_Action_Plugin_Authorize implements Nmc_Controller_Action_Pl { public function preAction(Nmc_Controller_Action $controller, - Zend_Controller_Dispatcher_Token $action) + Zend_Controller_Request_Abstract $request, + Zend_Controller_Response_Abstract $response) { + if($request->getActionName() == 'unauthorized') { + return; + } + $authorized = false; if(!$controller->authorize()) { - $action->setActionName('unauthorized'); + $request->setActionName('unauthorized'); + $request->setDispatched(false); } } public function postAction(Nmc_Controller_Action $controller, - Zend_Controller_Dispatcher_Token $action) + Zend_Controller_Request_Abstract $request, + Zend_Controller_Response_Abstract $response) { //do nothing } @@ -38,7 +45,7 @@ class Nmc_Controller_Action_Plugin_Authorize implements Nmc_Controller_Action_Pl $out = new Nmc_View(); $out->page = '403'; $out->title = '403 Access Denied'; - echo $out->render(); + echo $out->render('index.xhtml'); } } \ No newline at end of file diff --git a/library/Nmc/Controller/Action/Plugin/Broker.php b/library/Nmc/Controller/Action/Plugin/Broker.php index bbab7db6095056099b6122c47b243459fcf748ce..a0ea964144fc8efdc9d572c65eb8140c53d0044a 100644 --- a/library/Nmc/Controller/Action/Plugin/Broker.php +++ b/library/Nmc/Controller/Action/Plugin/Broker.php @@ -48,18 +48,20 @@ class Nmc_Controller_Action_Plugin_Broker implements Nmc_Controller_Action_Plugi } public function preAction(Nmc_Controller_Action $controller, - Zend_Controller_Dispatcher_Token $action) + Zend_Controller_Request_Abstract $request, + Zend_Controller_Response_Abstract $response) { foreach($this->_plugins as $plugin) { - $plugin->preAction($controller, $action); + $plugin->preAction($controller, $request, $response); } } public function postAction(Nmc_Controller_Action $controller, - Zend_Controller_Dispatcher_Token $action) + Zend_Controller_Request_Abstract $request, + Zend_Controller_Response_Abstract $response) { foreach($this->_plugins as $plugin) { - $plugin->postAction($controller, $action); + $plugin->postAction($controller, $request, $response); } } diff --git a/library/Nmc/Controller/Action/Plugin/Interface.php b/library/Nmc/Controller/Action/Plugin/Interface.php index a15b613b9df45b505c06db29680cc8121c97d09f..3f67c623f763a553785b912e969f70493e348591 100644 --- a/library/Nmc/Controller/Action/Plugin/Interface.php +++ b/library/Nmc/Controller/Action/Plugin/Interface.php @@ -24,10 +24,12 @@ interface Nmc_Controller_Action_Plugin_Interface { public function preAction(Nmc_Controller_Action $controller, - Zend_Controller_Dispatcher_Token $action); + Zend_Controller_Request_Abstract $request, + Zend_Controller_Response_Abstract $response); public function postAction(Nmc_Controller_Action $controller, - Zend_Controller_Dispatcher_Token $action); + Zend_Controller_Request_Abstract $request, + Zend_Controller_Response_Abstract $response); } diff --git a/library/Nmc/Controller/Action/Plugin/Test.php b/library/Nmc/Controller/Action/Plugin/Test.php index 98803cb712db461cc1d27168d14f1e2c72af48f9..4fdb31034e91f356b794418252575e410c2f2a93 100644 --- a/library/Nmc/Controller/Action/Plugin/Test.php +++ b/library/Nmc/Controller/Action/Plugin/Test.php @@ -13,14 +13,16 @@ class Nmc_Controller_Action_Plugin_Test implements Nmc_Controller_Action_Plugin_ { public function preAction(Nmc_Controller_Action $controller, - Zend_Controller_Dispatcher_Token $action) + Zend_Controller_Request_Abstract $request, + Zend_Controller_Response_Abstract $response) { $foo = new ReflectionObject($controller); //print_r($foo->__toString()); } public function postAction(Nmc_Controller_Action $controller, - Zend_Controller_Dispatcher_Token $action) + Zend_Controller_Request_Abstract $request, + Zend_Controller_Response_Abstract $response) { //do nothing }