Esempio n. 1
0
 /**
  * Does not respect params
  * 
  * @param string $url
  * @return boolean
  */
 public static function hasAccessUrl($url)
 {
     $user = common_session_SessionManager::getSession()->getUser();
     try {
         $resolver = new ActionResolver($url);
         return AclProxy::hasAccess($user, $resolver->getController(), $resolver->getAction(), array());
         $className = $resolver->getController();
     } catch (ResolverException $e) {
         return false;
     }
 }
Esempio n. 2
0
 /**
  * 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) {
             $resolver = new ActionResolver($section->getUrl());
             if (FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())) {
                 foreach ($section->getActions() as $action) {
                     $resolver = new ActionResolver($action->getUrl());
                     if (!FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())) {
                         $section->removeAction($action);
                     }
                 }
                 $sections[] = $section;
             }
         }
     }
     return $sections;
 }
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * 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());
 }