/** * Processes the action request. * * @return string * @throws Exception */ protected function _processActionRequest(array $namespace, $isParserHook = false, $args = array()) { global $wgRequest; $action = $wgRequest->getText('bt_action', 'list'); $class = __CLASS__ . 'Action' . ucfirst(strtolower($action)); $method = $action . 'Action'; $file = dirname(__FILE__) . '/Actions/' . $class . '.php'; if (!file_exists($file)) { throw new Exception('Invalid file: ' . $file); } if (array_key_exists($action, $this->_config->getPermissions())) { require_once dirname(__FILE__) . '/Actions/' . $class . '.php'; $controller = new $class(); $controller->setConfig($this->getConfig()); if ($controller->hasPermission($action)) { $controller->setAction($action); $controller->setParserHook($isParserHook); $controller->setNamespace($namespace); $controller->setModel(new IssueTrackerModelDefault()); $controller->setArguments($args); if (!method_exists($controller, 'init') || $controller->init() === true) { $controller->{$method}(); return $controller->getOutput(); } } return wfMsg('not_authorized'); } return wfMsg('invalid_action') . ': ' . $action; }
/** * Check whether the user's group has permission to perform this action. * * @param string $action */ public function hasPermission($action) { global $wgUser; if (isset($this->_acl[$action])) { return $this->_acl[$action]; } $perms = $this->_config->getPermissions(); if ($perms[$action]['group'] == '*') { $this->_acl[$action] = true; return true; } else { $userGroups = $wgUser->getGroups(); foreach ($userGroups as $group) { if ($group == strtolower($perms[$action]['group'])) { $this->_acl[$action] = true; return true; } } } $this->_acl[$action] = false; return false; }