예제 #1
0
 public function resolve(ResourceLocator $locator)
 {
     if ($locator->hasResourceId()) {
         $context = Claro_Context::getCurrentContext();
         $context[CLARO_CONTEXT_COURSE] = $locator->getCourseId();
         if ($locator->inGroup()) {
             $context[CLARO_CONTEXT_GROUP] = $locator->getGroupId();
         }
         $path = get_path('coursesRepositorySys') . claro_get_course_path($locator->getCourseId());
         // in a group
         if ($locator->inGroup()) {
             $groupData = claro_get_group_data($context);
             $path .= '/group/' . $groupData['directory'];
             $groupId = $locator->getGroupId();
         } else {
             $path .= '/document';
         }
         $path .= '/' . ltrim($locator->getResourceId(), '/');
         $resourcePath = '/' . ltrim($locator->getResourceId(), '/');
         $path = secure_file_path($path);
         if (!file_exists($path)) {
             throw new Exception("Resource not found {$path}");
         } elseif (is_dir($path)) {
             $url = new Url(get_module_entry_url('CLDOC'));
             $url->addParam('cmd', 'exChDir');
             $url->addParam('file', base64_encode($resourcePath));
             return $url->toUrl();
         } else {
             return get_module_url('CLDOC') . '/connector/cllp.frames.cnr.php';
             return claro_get_file_download_url($resourcePath, Claro_Context::getUrlContext($context));
         }
     } else {
         return get_module_entry_url('CLDOC');
     }
 }
예제 #2
0
파일: linker.cnr.php 프로젝트: rhertzog/lcs
 public function isNavigable(ResourceLocator $locator)
 {
     if ($locator->hasResourceId()) {
         return false;
     } else {
         return $locator->inModule() && $locator->getModuleLabel() == 'CLCAL';
     }
 }
예제 #3
0
파일: linker.cnr.php 프로젝트: rhertzog/lcs
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('wrk_assignment'), $locator->getCourseId());
     $resourceList = new LinkerResourceIterator();
     if (!$locator->hasResourceId()) {
         $sql = "SELECT `title`, `visibility`, `id`\n" . "FROM `{$tbl['wrk_assignment']}`\n";
         $res = Claroline::getDatabase()->query($sql);
         foreach ($res as $assig) {
             $loc = new ClarolineResourceLocator($locator->getCourseId(), 'CLWRK', (int) $assig['id']);
             $resource = new LinkerResource($assig['title'], $loc, true, $assig['visibility'] == 'VISIBLE', false);
             $resourceList->addResource($resource);
         }
     }
     return $resourceList;
 }
예제 #4
0
파일: linker.cnr.php 프로젝트: rhertzog/lcs
 public function getParentResourceId(ResourceLocator $locator)
 {
     if ($locator->hasResourceId()) {
         $resourceId = '/' . ltrim($locator->getResourceId(), '/');
         $parentResourceId = ltrim(str_replace('\\', '/', dirname($resourceId)), '/');
         if ($parentResourceId == '' || $parentResourceId == '/' || $parentResourceId == '.' || $parentResourceId == '..') {
             return false;
         } else {
             return $parentResourceId;
         }
     } else {
         return false;
     }
 }
예제 #5
0
파일: linker.cnr.php 프로젝트: rhertzog/lcs
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('wiki_properties', 'wiki_pages'), $locator->getCourseId());
     if ($locator->inGroup()) {
         $groupSql = "WHERE group_id = " . Claroline::getDatabase()->escape($locator->getGroupId());
     } else {
         $groupSql = "WHERE group_id = 0";
     }
     $resourceList = new LinkerResourceIterator();
     if ($locator->hasResourceId()) {
         $parts = explode('/', ltrim($locator->getResourceId(), '/'));
         if (count($parts) == 1) {
             $sql = "SELECT `title`\n" . "FROM `{$tbl['wiki_pages']}`\n" . "WHERE wiki_id = " . Claroline::getDatabase()->escape($parts[0]);
             $res = Claroline::getDatabase()->query($sql);
             foreach ($res as $page) {
                 $pageLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLWIKI', (int) $parts[0] . '/' . rawurlencode($page['title']));
                 $pageResource = new LinkerResource($page['title'] == '__MainPage__' ? get_lang('Main page') : $page['title'], $pageLoc, true, true, false);
                 $resourceList->addResource($pageResource);
             }
         }
     } else {
         $sql = "SELECT `id`, `title`\n" . "FROM `{$tbl['wiki_properties']}`\n" . $groupSql;
         $res = Claroline::getDatabase()->query($sql);
         foreach ($res as $wiki) {
             $wikiLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLWIKI', (int) $wiki['id']);
             $wikiResource = new LinkerResource($wiki['title'], $wikiLoc, true, true, true);
             $resourceList->addResource($wikiResource);
         }
     }
     return $resourceList;
 }
예제 #6
0
파일: linker.cnr.php 프로젝트: rhertzog/lcs
 public function getResourceList(ResourceLocator $locator)
 {
     $resourceList = new LinkerResourceIterator();
     $tbl = get_module_course_tbl(array('bb_topics', 'bb_forums'), $locator->getCourseId());
     if (!$locator->hasResourceId()) {
         if (!$locator->inGroup()) {
             $sql = "SELECT `forum_id`, `forum_name`, `group_id`\n" . "FROM `{$tbl['bb_forums']}`\n";
             $forumList = Claroline::getDatabase()->query($sql);
             foreach ($forumList as $forum) {
                 $forumLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLFRM', empty($forum['group_id']) ? (int) $forum['forum_id'] : null, empty($forum['group_id']) ? null : $forum['group_id']);
                 $topicResource = new LinkerResource(empty($forum['forum_name']) ? get_lang('Untitled') : $forum['forum_name'], $forumLoc, true, true, true);
                 $resourceList->addResource($topicResource);
             }
         } else {
             $sql = "SELECT `forum_id` AS `id`, `forum_name` AS `name`\n" . "FROM `{$tbl['bb_forums']}`\n" . "WHERE `group_id` = " . Claroline::getDatabase()->escape($locator->getGroupId());
             $res = Claroline::getDatabase()->query($sql);
             if (count($res)) {
                 $groupForum = $res->fetch(Database_ResultSet::FETCH_OBJECT);
                 $sql = "SELECT `topic_id`, `topic_title`, `forum_id`\n" . "FROM `{$tbl['bb_topics']}`\n" . "WHERE `forum_id` = " . Claroline::getDatabase()->escape($groupForum->id);
                 $topicList = Claroline::getDatabase()->query($sql);
                 foreach ($topicList as $topic) {
                     $topicLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLFRM', (int) $topic['topic_id'], $locator->getGroupId());
                     $topicResource = new LinkerResource(empty($topic['topic_title']) ? get_lang('Untitled') : $topic['topic_title'], $topicLoc, true, true, false);
                     $resourceList->addResource($topicResource);
                 }
             }
         }
     } else {
         if ($locator->inGroup()) {
         } else {
             $elems = explode('/', ltrim($locator->getResourceId(), '/'));
             if (count($elems) == 1) {
                 $sql = "SELECT `topic_id`, `topic_title`, `forum_id`\n" . "FROM `{$tbl['bb_topics']}`\n" . "WHERE `forum_id` = " . Claroline::getDatabase()->escape($elems[0]);
                 $topicList = Claroline::getDatabase()->query($sql);
                 foreach ($topicList as $topic) {
                     $topicLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLFRM', (int) $topic['forum_id'] . '/' . (int) $topic['topic_id']);
                     $topicResource = new LinkerResource(empty($topic['topic_title']) ? get_lang('Untitled') : $topic['topic_title'], $topicLoc, true, true, false);
                     $resourceList->addResource($topicResource);
                 }
             } else {
                 // not navigable
             }
         }
     }
     return $resourceList;
 }
예제 #7
0
파일: linker.lib.php 프로젝트: rhertzog/lcs
 public function getParent(ResourceLocator $locator)
 {
     if ($locator instanceof ExternalResourceLocator) {
         $parent = false;
     } elseif ($locator->hasResourceId()) {
         if ($navigator = $this->loadModuleNavigator($locator->getModuleLabel())) {
             $resourceId = $navigator->getParentResourceId($locator);
         } else {
             $resourceId = null;
         }
         $parent = new ClarolineResourceLocator($locator->getCourseId(), $locator->getModuleLabel(), $resourceId, $locator->getGroupId());
     } elseif ($locator->inModule()) {
         $parent = new ClarolineResourceLocator($locator->getCourseId(), null, null, $locator->getGroupId());
     } elseif ($locator->inGroup()) {
         $parent = new ClarolineResourceLocator($locator->getCourseId(), 'CLGRP', null, null);
     } else {
         $parent = false;
     }
     return $parent;
 }