addRoleAssignment($roles, array('manage')); parent::__construct($roles); } // // Extended methods from PluginGridHandler // /** * @copydoc PluginGridHandler::loadData() */ function loadCategoryData($request, $categoryDataElement, $filter) { $plugins = parent::loadCategoryData($request, $categoryDataElement, $filter); $userRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES); $showSitePlugins = false; if (in_array(ROLE_ID_SITE_ADMIN, $userRoles)) { $showSitePlugins = true; } if ($showSitePlugins) { return $plugins; } else { $contextLevelPlugins = array(); foreach ($plugins as $plugin) { if (!$plugin->isSitePlugin()) { $contextLevelPlugins[$plugin->getName()] = $plugin; } unset($plugin); } return $contextLevelPlugins; } } // // Overridden template methods. // /** * @copydoc CategoryGridHandler::getCategoryRowInstance() */ protected function getRowInstance() { import('lib.pkp.controllers.grid.plugins.PluginGridRow'); return new PluginGridRow($this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES)); } /** * @copydoc GridHandler::authorize() */ function authorize($request, &$args, $roleAssignments) { $categoryName = $request->getUserVar('category'); $pluginName = $request->getUserVar('plugin'); if ($categoryName && $pluginName) { import('lib.pkp.classes.security.authorization.PluginAccessPolicy'); switch ($request->getRequestedOp()) { case 'enable': case 'disable': case 'manage': $accessMode = ACCESS_MODE_MANAGE; break; default: $accessMode = ACCESS_MODE_ADMIN; break; } $this->addPolicy(new PluginAccessPolicy($request, $args, $roleAssignments, $accessMode)); } return parent::authorize($request, $args, $roleAssignments); } } ?>