/** * The standard action for an Area */ public final function action() { $toret = null; $error_number = Controller::getVar('err'); if (!empty($error_number)) { Backend::addError(self::getError($error_number)); } if (Controller::$debug) { Backend::addNotice('Checking Method ' . Controller::$action . ' for ' . get_class($this)); } $request_method = strtolower(Controller::getMethod()) . '_' . Controller::$action; $action_method = 'action_' . Controller::$action; $view_method = Controller::$view->mode . '_' . Controller::$action; //Determine / check method $method = false; if (method_exists($this, $request_method)) { $method = $request_method; } else { if (method_exists($this, $action_method)) { $method = $action_method; } else { if (method_exists($this, $view_method)) { $method = true; } } } if (!$method) { Controller::whoops('Unknown Method', array('message' => 'Method ' . Controller::$area . '::' . Controller::$action . ' does not exist')); return null; } //Check permissions on existing method if (Controller::getCheckPermissions() && !$this->checkPermissions()) { //TODO Add a permission denied hook to give the controller a chance to handle the permission denied Controller::whoops('Permission Denied', array('message' => 'You do not have permission to ' . Controller::$action . ' ' . get_class($this))); return null; } if ($method === true) { //View method, return null; return null; } if (Controller::$debug) { Backend::addNotice('Running ' . get_class($this) . '::' . $method); } return call_user_func_array(array($this, $method), Controller::$parameters); }
/** * Check if access is allowed to the given controller class, with the given * context. This is done by calling the 'checkAccess' method of the controller. * If not allowed, this method may redirect to another page. * * @param Controller $controllerClass the controller class * @param Controller $controller the controller object * @param Context $ctx the context * @return boolean whether access is allowed. */ private function checkAccess($controllerClass, $controller, $ctx) { $method = $controllerClass->getMethod('checkAccess'); return $method->invoke($controller, $ctx); }