MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / resource / index.php
blobcd7d7e1db5c0e421b5b3afde6dd1563faee8aa17
1 <?php // $Id$
3 require_once("../../config.php");
5 $id = required_param( 'id', PARAM_INT ); // course
7 if (! $course = get_record("course", "id", $id)) {
8 error("Course ID is incorrect");
11 require_course_login($course, true);
13 if ($course->id != SITEID) {
14 require_login($course->id);
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 $navlinks = array();
27 $navlinks[] = array('name' => $strresources, 'link' => '', 'type' => 'activityinstance');
28 $navigation = build_navigation($navlinks);
30 print_header("$course->shortname: $strresources", $course->fullname, $navigation,
31 "", "", true, "", navmenu($course));
33 if (! $resources = get_all_instances_in_course("resource", $course)) {
34 notice("There are no resources", "../../course/view.php?id=$course->id");
35 exit;
38 if ($course->format == "weeks") {
39 $table->head = array ($strweek, $strname, $strsummary);
40 $table->align = array ("center", "left", "left");
41 } else if ($course->format == "topics") {
42 $table->head = array ($strtopic, $strname, $strsummary);
43 $table->align = array ("center", "left", "left");
44 } else {
45 $table->head = array ($strlastmodified, $strname, $strsummary);
46 $table->align = array ("left", "left", "left");
49 $currentsection = "";
50 $options->para = false;
51 foreach ($resources as $resource) {
52 if ($course->format == "weeks" or $course->format == "topics") {
53 $printsection = "";
54 if ($resource->section !== $currentsection) {
55 if ($resource->section) {
56 $printsection = $resource->section;
58 if ($currentsection !== "") {
59 $table->data[] = 'hr';
61 $currentsection = $resource->section;
63 } else {
64 $printsection = '<span class="smallinfo">'.userdate($resource->timemodified)."</span>";
66 if (!empty($resource->extra)) {
67 $extra = urldecode($resource->extra);
68 } else {
69 $extra = "";
71 if (!$resource->visible) { // Show dimmed if the mod is hidden
72 $table->data[] = array ($printsection,
73 "<a class=\"dimmed\" $extra href=\"view.php?id=$resource->coursemodule\">".format_string($resource->name,true)."</a>",
74 format_text($resource->summary, FORMAT_MOODLE, $options) );
76 } else { //Show normal if the mod is visible
77 $table->data[] = array ($printsection,
78 "<a $extra href=\"view.php?id=$resource->coursemodule\">".format_string($resource->name,true)."</a>",
79 format_text($resource->summary, FORMAT_MOODLE, $options) );
83 echo "<br />";
85 print_table($table);
87 print_footer($course);