Esempio n. 1
0
 /**
  * Dispatch a module view request.
  *
  * @return mixed
  */
 public function dispatch()
 {
     if (!SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     // Get input.
     $moduleName = $this->request->getGet()->filter('_module', null, FILTER_SANITIZE_STRING);
     $pluginName = $this->request->getGet()->filter('_plugin', null, FILTER_SANITIZE_STRING);
     $action = $this->request->getGet()->filter('_action', null, FILTER_SANITIZE_STRING);
     // Load plugins.
     if (!$moduleName) {
         $type = 'SystemPlugin';
         PluginUtil::loadAllSystemPlugins();
     } else {
         $type = 'ModulePlugin';
         PluginUtil::loadAllModulePlugins();
     }
     if ($moduleName) {
         $serviceId = PluginUtil::getServiceId("{$type}_{$moduleName}_{$pluginName}_Plugin");
     } else {
         $serviceId = PluginUtil::getServiceId("{$type}_{$pluginName}_Plugin");
     }
     $this->throwNotFoundUnless($this->serviceManager->hasService($serviceId));
     $this->plugin = $this->serviceManager->getService($serviceId);
     // Sanity checks.
     $this->throwNotFoundUnless($this->plugin->isInstalled(), __f('Plugin "%s" is not installed', $this->plugin->getMetaDisplayName()));
     $this->throwForbiddenUnless($this->plugin instanceof Zikula_Plugin_ConfigurableInterface, __f('Plugin "%s" is not configurable', $this->plugin->getMetaDisplayName()));
     $this->pluginController = $this->plugin->getConfigurationController();
     $this->throwNotFoundUnless($this->pluginController->getReflection()->hasMethod($action));
     return $this->pluginController->{$action}();
 }
Esempio n. 2
0
 /**
  * @Route("/dispatch")
  *
  * Dispatch a module view request.
  *
  * @return mixed
  * 
  * @throws AccessDeniedException Thrown if the user doesn't have admin access to the module or
  *                                          if the plugin isn't configurable
  * @throws NotFoundHttpException Thrown if the plugin doesn't have the requested service or action methods
  */
 public function dispatchAction()
 {
     if (!SecurityUtil::checkPermission('ZikulaExtensionsModule::', '::', ACCESS_ADMIN)) {
         throw new AccessDeniedException();
     }
     // Get input.
     $moduleName = $this->request->query->filter('_module', null, FILTER_SANITIZE_STRING);
     $pluginName = $this->request->query->filter('_plugin', null, FILTER_SANITIZE_STRING);
     $action = $this->request->query->filter('_action', null, FILTER_SANITIZE_STRING);
     // Load plugins.
     if (!$moduleName) {
         $type = 'SystemPlugin';
         PluginUtil::loadAllSystemPlugins();
     } else {
         $type = 'ModulePlugin';
         PluginUtil::loadAllModulePlugins();
     }
     if ($moduleName) {
         $serviceId = PluginUtil::getServiceId("{$type}_{$moduleName}_{$pluginName}_Plugin");
     } else {
         $serviceId = PluginUtil::getServiceId("{$type}_{$pluginName}_Plugin");
     }
     if (!$this->getContainer()->has($serviceId)) {
         throw new NotFoundHttpException();
     }
     $this->plugin = $this->getContainer()->get($serviceId);
     // Sanity checks.
     if (!$this->plugin instanceof Zikula_Plugin_ConfigurableInterface) {
         throw new AccessDeniedException(__f('Plugin "%s" is not configurable', $this->plugin->getMetaDisplayName()));
     }
     $this->pluginController = $this->plugin->getConfigurationController();
     if (!$this->pluginController->getReflection()->hasMethod($action)) {
         throw new NotFoundHttpException();
     }
     return $this->response($this->pluginController->{$action}());
 }