/** * Returns whenever or not the current user has access to a specified link * * @param string $action * @param string $controller * @param string $extension * @param array $parameters * @return boolean * @deprecated */ public static function hasAccess($action, $controller, $extension, $parameters = array()) { $user = common_session_SessionManager::getSession()->getUser(); try { $resolver = ActionResolver::getByControllerName($controller, $extension); $className = $resolver->getController(); } catch (ResolverException $e) { return false; } return AclProxy::hasAccess($user, $className, $action, $parameters); }
/** * Get the sections of the current extension's structure * * @param string $shownExtension * @param string $shownStructure * @return array the sections */ private function getSections($shownExtension, $shownStructure) { $sections = array(); $user = common_Session_SessionManager::getSession()->getUser(); $structure = MenuService::getPerspective($shownExtension, $shownStructure); if (!is_null($structure)) { foreach ($structure->getChildren() as $section) { if (tao_models_classes_accessControl_AclProxy::hasAccess($section->getAction(), $section->getController(), $section->getExtensionId())) { foreach ($section->getActions() as $action) { $resolver = ActionResolver::getByControllerName($action->getController(), $action->getExtensionId()); if (!FuncProxy::accessPossible($user, $resolver->getController(), $action->getAction())) { $section->removeAction($action); } } $sections[] = $section; } } } return $sections; }
/** * Test {@link ActionResolver::getByControllerName(} * @dataProvider getByControllerNameProvider * @param string $extension * @param string $shortName * @param string $expectedClassName * @param string $expectedAction */ public function testGetByControllerName($extension, $shortName, $expectedClassName, $expectedAction) { $resolver = ActionResolver::getByControllerName($shortName, $extension); $this->assertFalse(is_null($resolver)); $this->assertTrue($resolver instanceof ActionResolver); $this->assertEquals($expectedClassName, $resolver->getController()); $this->assertEquals($expectedAction, $resolver->getAction()); }