Too many bugs, not enough time!
[moodle.git] / mod / resource / index.php
blob416165a06d43b0b23d9f2798c687f7794d67ab6a
1 <?PHP // $Id$
3 require_once("../../config.php");
5 require_variable($id); // course
7 if (! $course = get_record("course", "id", $id)) {
8 error("Course ID is incorrect");
11 if ($course->category) {
12 require_login($course->id);
13 $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
16 add_to_log($course->id, "resource", "view all", "index.php?id=$course->id", "");
18 $strresource = get_string("modulename", "resource");
19 $strresources = get_string("modulenameplural", "resource");
20 $strweek = get_string("week");
21 $strtopic = get_string("topic");
22 $strname = get_string("name");
23 $strsummary = get_string("summary");
24 $strlastmodified = get_string("lastmodified");
26 print_header("$course->shortname: $strresources", "$course->fullname", "$navigation $strresources",
27 "", "", true, "", navmenu($course));
29 if (! $resources = get_all_instances_in_course("resource", $course)) {
30 notice("There are no resources", "../../course/view.php?id=$course->id");
31 exit;
34 if ($course->format == "weeks") {
35 $table->head = array ($strweek, $strname, $strsummary);
36 $table->align = array ("CENTER", "LEFT", "LEFT");
37 } else if ($course->format == "topics") {
38 $table->head = array ($strtopic, $strname, $strsummary);
39 $table->align = array ("CENTER", "LEFT", "LEFT");
40 } else {
41 $table->head = array ($strlastmodified, $strname, $strsummary);
42 $table->align = array ("LEFT", "LEFT", "LEFT");
45 $currentsection = "";
46 foreach ($resources as $resource) {
47 if ($course->format == "weeks" or $course->format == "topics") {
48 $printsection = "";
49 if ($resource->section !== $currentsection) {
50 if ($resource->section) {
51 $printsection = $resource->section;
53 if ($currentsection !== "") {
54 $table->data[] = 'hr';
56 $currentsection = $resource->section;
58 } else {
59 $printsection = '<span class="smallinfo">'.userdate($resource->timemodified)."</span>";
61 if (!empty($resource->extra)) {
62 $extra = urldecode($resource->extra);
63 } else {
64 $extra = "";
66 if (!$resource->visible) { // Show dimmed if the mod is hidden
67 $table->data[] = array ($printsection,
68 "<a class=\"dimmed\" $extra href=\"view.php?id=$resource->coursemodule\">$resource->name</a>",
69 text_to_html($resource->summary) );
71 } else { //Show normal if the mod is visible
72 $table->data[] = array ($printsection,
73 "<a $extra href=\"view.php?id=$resource->coursemodule\">$resource->name</a>",
74 text_to_html($resource->summary) );
78 echo "<br />";
80 print_table($table);
82 print_footer($course);