Ejemplo n.º 1
0
 /**
  * This action renders the template used by the splash screen popup
  */
 public function splash()
 {
     //the list of extensions the splash provides an explanation for.
     $defaultExtIds = array('items', 'tests', 'TestTaker', 'groups', 'delivery', 'results');
     //check if the user is a noob
     $this->setData('firstTime', TaoCe::isFirstTimeInTao());
     //load the extension data
     $defaultExtensions = array();
     $additionalExtensions = array();
     foreach (MenuService::getPerspectivesByGroup(Perspective::GROUP_DEFAULT) as $i => $perspective) {
         if (in_array((string) $perspective->getId(), $defaultExtIds)) {
             $defaultExtensions[strval($perspective->getId())] = array('id' => $perspective->getId(), 'name' => $perspective->getName(), 'extension' => $perspective->getExtension(), 'description' => $perspective->getDescription());
         } else {
             $additionalExtensions[$i] = array('id' => $perspective->getId(), 'name' => $perspective->getName(), 'extension' => $perspective->getExtension());
         }
         //Test if access
         $access = false;
         foreach ($perspective->getChildren() as $section) {
             if (tao_models_classes_accessControl_AclProxy::hasAccess($section->getAction(), $section->getController(), $section->getExtensionId())) {
                 $access = true;
                 break;
             }
         }
         if (in_array((string) $perspective->getId(), $defaultExtIds)) {
             $defaultExtensions[strval($perspective->getId())]['enabled'] = $access;
         } else {
             $additionalExtensions[$i]['enabled'] = $access;
         }
     }
     $this->setData('extensions', array_merge($defaultExtensions, $additionalExtensions));
     $this->setData('defaultExtensions', $defaultExtensions);
     $this->setData('additionalExtensions', $additionalExtensions);
     $this->setView('splash.tpl');
 }
Ejemplo n.º 2
0
 /**
  * Test the taoService methods, the extensions loading
  * @see tao_models_classes_TaoService::getLoadedExtensions
  */
 public function testTaoServiceExtention()
 {
     foreach (MenuService::getAllPerspectives() as $perspective) {
         $this->assertTrue(strlen($perspective->getExtension()) > 0);
         $this->assertTrue(strlen($perspective->getId()) > 0);
         foreach ($perspective->getChildren() as $section) {
             $this->assertTrue(strlen($section->getName()) > 0);
             $this->assertTrue(strlen($section->getUrl()) > 0);
         }
     }
 }
Ejemplo n.º 3
0
 public function getEntryPoints()
 {
     $entryPoints = array();
     foreach (MenuService::getEntryPoints() as $entry) {
         $entryPoints[$entry->getId()] = $entry;
     }
     foreach ($this->getMap() as $entry) {
         $entryPoints[$entry->getId()] = $entry;
     }
     return $entryPoints;
 }
 /**
  * returns the root classes to index
  * 
  * @return array
  */
 protected static function getIndexedClasses()
 {
     $classes = array();
     foreach (MenuService::getAllPerspectives() as $perspective) {
         foreach ($perspective->getChildren() as $structure) {
             foreach ($structure->getTrees() as $tree) {
                 if (!is_null($tree->get('rootNode'))) {
                     $classes[$tree->get('rootNode')] = new \core_kernel_classes_Class($tree->get('rootNode'));
                 }
             }
         }
     }
     return array_values($classes);
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
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) {
             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;
 }
Ejemplo n.º 7
0
 /**
  * Add permission information to the tree structure
  * 
  * @param array $tree
  * @return array
  */
 protected function addPermissions($tree)
 {
     $user = \common_Session_SessionManager::getSession()->getUser();
     $section = MenuService::getSection($this->getRequestParameter('extension'), $this->getRequestParameter('perspective'), $this->getRequestParameter('section'));
     $actions = array();
     foreach ($section->getActions() as $index => $action) {
         try {
             $actions[$index] = array('resolver' => new ActionResolver($action->getUrl()), 'id' => $action->getId(), 'context' => $action->getContext());
         } catch (\ResolverException $re) {
             common_Logger::d('do not handle permissions for action : ' . $action->getName() . ' ' . $action->getUrl());
         }
     }
     //then compute ACL for each node of the tree
     $treeKeys = array_keys($tree);
     if (is_int($treeKeys[0])) {
         foreach ($tree as $index => $treeNode) {
             $tree[$index] = $this->computePermissions($actions, $user, $treeNode);
         }
     } else {
         $tree = $this->computePermissions($actions, $user, $tree);
     }
     return $tree;
 }
Ejemplo n.º 8
0
 /**
  * Add translations as translation units found in a structure.xml manifest
  * a given PO file.
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param tao_helpers_translation_POFile $poFile
  * @throws Exception
  * @return void
  */
 public function addManifestsTranslations(tao_helpers_translation_POFile $poFile)
 {
     $this->outVerbose("Adding all manifests messages to extension '" . $this->options['extension'] . "'");
     $rootDir = dirname(__FILE__) . '/../../';
     $directories = scandir($rootDir);
     $exceptions = array('generis', 'tao', '.*');
     if (false === $directories) {
         $this->err("The TAO root directory is not readable. Please check permissions on this directory.", true);
     } else {
         foreach ($directories as $dir) {
             if (is_dir($rootDir . $dir) && !in_array($dir, $exceptions)) {
                 // Maybe it should be read.
                 if (in_array('.*', $exceptions) && $dir[0] == '.') {
                     continue;
                 } else {
                     // Is this a TAO extension ?
                     $file = MenuService::getStructuresFilePath($this->options['extension']);
                     if (!is_null($file)) {
                         $structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
                         $structureExtractor->extract();
                         $poFile->addTranslationUnits($structureExtractor->getTranslationUnits());
                         $this->outVerbose("Manifest of extension '" . $dir . "' added to extension '" . $this->options['extension'] . "'");
                     }
                 }
             }
         }
     }
 }
 /**
  * Enables an extension
  */
 public function enable()
 {
     $extId = $this->getRequestParameter('id');
     \common_ext_ExtensionsManager::singleton()->setEnabled($extId, true);
     MenuService::flushCache();
     echo json_encode(array('success' => true, 'message' => __('Disabled %s', $this->getRequestParameter('id'))));
 }
 /**
  * Renders json data from the current ontology root class.
  * 
  * The possible request parameters are the following:
  * 
  * * labelFilter: A filter string to be used. The returned hierarchy will be a single root class, with children without class hierarchy.
  * * uniqueNode: A URI indicating the returned hiearchy will be a single class, with a single children corresponding to the URI.
  * * browse:
  * * hideInstances:
  * * chunk:
  * * offset:
  * * limit:
  * * subclasses:
  * * classUri:
  * 
  * @return void
  */
 public function getOntologyData()
 {
     if (!tao_helpers_Request::isAjax()) {
         throw new common_exception_IsAjaxAction(__FUNCTION__);
     }
     $options = array('subclasses' => true, 'instances' => true, 'highlightUri' => '', 'labelFilter' => '', 'chunk' => false, 'offset' => 0, 'limit' => 0);
     if ($this->hasRequestParameter('filter')) {
         $options['labelFilter'] = $this->getRequestParameter('filter');
     }
     if ($this->hasRequestParameter('loadNode')) {
         $options['uniqueNode'] = $this->getRequestParameter('loadNode');
     }
     if ($this->hasRequestParameter("selected")) {
         $options['browse'] = array($this->getRequestParameter("selected"));
     }
     if ($this->hasRequestParameter('hideInstances')) {
         if ((bool) $this->getRequestParameter('hideInstances')) {
             $options['instances'] = false;
         }
     }
     if ($this->hasRequestParameter('classUri')) {
         $clazz = $this->getCurrentClass();
         $options['chunk'] = !$clazz->equals($this->getRootClass());
     } else {
         $clazz = $this->getRootClass();
     }
     if ($this->hasRequestParameter('offset')) {
         $options['offset'] = $this->getRequestParameter('offset');
     }
     if ($this->hasRequestParameter('limit')) {
         $options['limit'] = $this->getRequestParameter('limit');
     }
     if ($this->hasRequestParameter('subclasses')) {
         $options['subclasses'] = $this->getRequestParameter('subclasses');
     }
     //generate the tree from the given parameters
     $tree = $this->service->toTree($clazz, $options);
     //load the user URI from the session
     $user = common_Session_SessionManager::getSession()->getUser();
     //Get the requested section
     $section = MenuService::getSection($this->getRequestParameter('extension'), $this->getRequestParameter('perspective'), $this->getRequestParameter('section'));
     //Get the actions from the section and bind them an ActionResolver that helps getting controller/action from action URL.
     $actions = array();
     foreach ($section->getActions() as $index => $action) {
         try {
             $actions[$index] = array('resolver' => new ActionResolver($action->getUrl()), 'id' => $action->getId(), 'context' => $action->getContext());
         } catch (\ResolverException $re) {
             common_Logger::d('do not handle permissions for action : ' . $action->getName() . ' ' . $action->getUrl());
         }
     }
     //then compute ACL for each node of the tree
     $treeKeys = array_keys($tree);
     if (is_int($treeKeys[0])) {
         foreach ($tree as $index => $treeNode) {
             $tree[$index] = $this->computePermissions($actions, $user, $treeNode);
         }
     } else {
         $tree = $this->computePermissions($actions, $user, $tree);
     }
     //expose the tree
     $this->returnJson($tree);
 }