Example #1
0
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('announcement'), $locator->getCourseId());
     $sql = "SELECT `id`, `title`, `visibility`\n" . "FROM `{$tbl['announcement']}`";
     $res = Claroline::getDatabase()->query($sql);
     $resourceList = new LinkerResourceIterator();
     foreach ($res as $annoucement) {
         $annoucementLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLANN', (int) $annoucement['id']);
         $annoucementResource = new LinkerResource(empty($annoucement['title']) ? get_lang('Untitled') : $annoucement['title'], $annoucementLoc, true, $annoucement['visibility'] == 'HIDE' ? false : true, false);
         $resourceList->addResource($annoucementResource);
     }
     return $resourceList;
 }
Example #2
0
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('calendar_event'), $locator->getCourseId());
     $sql = "SELECT `id`, `titre`, `day`, `visibility`\n" . "FROM `{$tbl['calendar_event']}`";
     $res = Claroline::getDatabase()->query($sql);
     $resourceList = new LinkerResourceIterator();
     foreach ($res as $event) {
         $eventLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLCAL', (int) $event['id']);
         $eventResource = new LinkerResource(empty($event['titre']) ? $event['day'] : $event['titre'], $eventLoc, true, $event['visibility'] == 'HIDE' ? false : true, false);
         $resourceList->addResource($eventResource);
     }
     return $resourceList;
 }
Example #3
0
 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;
 }
Example #4
0
 /**
  * Provide the list of available resources for a resource
  *
  * @para ResourceLocator $locator The resource locator.
  * @return LinkerResourceIterator Resource list as an iterator
  */
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl_cdb_names = get_module_course_tbl(array('lp_learnPath'), $locator->getCourseId());
     $tblPath = $tbl_cdb_names['lp_learnPath'];
     $resourceList = new LinkerResourceIterator();
     $sql = "SELECT `learnPath_id` AS `id`, `name`, `visibility`\n                FROM `" . $tblPath . "`\n                ORDER BY `name` ASC";
     $pathList = claro_sql_query_fetch_all_rows($sql);
     foreach ($pathList as $path) {
         $fileLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLLNP', $path['id']);
         $fileResource = new LinkerResource($path['name'], $fileLoc, true, $path['visibility'] == 'SHOW' ? true : false, false);
         $resourceList->addResource($fileResource);
     }
     return $resourceList;
 }
Example #5
0
 public function getResourceList(ResourceLocator $locator)
 {
     $groupId = null;
     if ($locator->inGroup()) {
         $groupData = claro_get_group_data(array(CLARO_CONTEXT_COURSE => $locator->getCourseId(), CLARO_CONTEXT_GROUP => $locator->getGroupId()));
         $groupId = $locator->getGroupId();
     }
     $path = $this->getPath($locator);
     if (!$this->isPathNavigable($path)) {
         throw new Exception("{$path} does not exists or is not a directory");
     } else {
         $tbl = get_module_course_tbl(array('document'), $locator->getCourseId());
         $fileProperties = array();
         if (!$locator->inGroup()) {
             $sql = "SELECT `path`, `visibility`, `comment`\n" . "FROM `{$tbl['document']}`\n" . "WHERE 1";
             $res = Claroline::getDatabase()->query($sql);
             foreach ($res as $row) {
                 $fileProperties[$row['path']] = $row;
             }
         }
         $it = new DirectoryIterator($path);
         $dirList = array();
         $fileList = array();
         foreach ($it as $file) {
             if ($file->isDir() && $file->isDot()) {
                 continue;
             }
             $relativePath = str_replace('\\', '/', str_replace($file->getPath(), '', $file->getPathname()));
             if ($locator->hasResourceId()) {
                 $relativePath = '/' . ltrim(ltrim($locator->getResourceId(), '/') . '/' . ltrim($relativePath, '/'), '/');
             }
             if ($file->isDir()) {
                 $dirList[] = $relativePath;
             } elseif ($file->isFile()) {
                 $fileList[] = $relativePath;
             }
         }
         natcasesort($dirList);
         natcasesort($fileList);
         $resourceList = new LinkerResourceIterator();
         foreach ($dirList as $relativePath) {
             $isVisible = true;
             if (array_key_exists($relativePath, $fileProperties)) {
                 $isVisible = $fileProperties[$relativePath]['visibility'] != 'i' ? true : false;
             }
             $resourceList->addResource($this->createResourceLocator($locator->getCourseId(), $relativePath, $isVisible, true, $groupId));
         }
         foreach ($fileList as $relativePath) {
             $isVisible = true;
             if (array_key_exists($relativePath, $fileProperties)) {
                 $isVisible = $fileProperties[$relativePath]['visibility'] != 'i' ? true : false;
             }
             $resourceList->addResource($this->createResourceLocator($locator->getCourseId(), $relativePath, $isVisible, false, $groupId));
         }
         return $resourceList;
     }
 }
Example #6
0
 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;
 }
Example #7
0
 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;
 }
Example #8
0
 public function getResourceName(ResourceLocator $locator)
 {
     $path = $locator->getResourceId();
     return str_replace('/', ' > ', $path);
 }
Example #9
0
 public static function getLocatorIdAndAddIfMissing(ResourceLocator $locator)
 {
     $tbl = claro_sql_get_course_tbl();
     $sql = "SELECT `id` FROM `{$tbl['resources']}`\n" . "WHERE BINARY `crl` = " . Claroline::getDatabase()->quote($locator->__toString());
     $res = Claroline::getDatabase()->query($sql);
     if ($res->numRows()) {
         return (int) $res->fetch(Database_ResultSet::FETCH_VALUE);
     } else {
         $sql = "INSERT INTO `{$tbl['resources']}`\n" . "SET\n" . "`crl` = " . Claroline::getDatabase()->quote($locator->__toString()) . "\n" . ",`title` = ''";
         Claroline::getDatabase()->exec($sql);
         return (int) Claroline::getDatabase()->insertId();
     }
 }