course)) {
error("Course is misconfigured");
}
if (! $resource = get_record("resource", "id", $cm->instance)) {
error("Resource ID was incorrect");
}
$strresource = get_string("modulename", "resource");
$strresources = get_string("modulenameplural", "resource");
$strlastmodified = get_string("lastmodified");
if ($course->category) {
require_login($course->id);
$navigation = "id\">$course->shortname ->
id\">$strresources ->";
} else {
$navigation = "id\">$strresources ->";
}
switch ($resource->type) {
case 1: // Reference (eg Journal or Book etc)
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
"", "", true, update_module_button($cm->id, $course->id, $strresource));
print_simple_box($resource->reference, "center");
echo "
";
echo text_to_html($resource->summary);
echo "
";
echo " 
";
echo "$strlastmodified: ".userdate($resource->timemodified)."
";
echo "";
print_footer($course);
break;
case 5: // Web Link
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
redirect($resource->reference);
break;
case 2: // Web Page
if ($frameset) {
print_header("$course->shortname: $resource->name", "$course->fullname",
"$navigation reference\" TITLE=\"$resource->reference\">$resource->name",
"", "", true, update_module_button($cm->id, $course->id, $strresource));
echo "".text_to_html($resource->summary, true, false)."";
} else {
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
echo "$course->shortname: $resource->name\n";
echo "";
}
break;
case 3: // Uploaded File
if ($frameset) {
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
"", "", true, update_module_button($cm->id, $course->id, $strresource));
echo "".text_to_html($resource->summary, true, false)."";
} else {
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
if ($CFG->slasharguments) {
$ffurl = "file.php/$course->id/$resource->reference";
} else {
$ffurl = "file.php?file=/$course->id/$resource->reference";
}
echo "$course->shortname: $resource->name\n";
echo "";
}
break;
case 4: // Plain text
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
"", "", true, update_module_button($cm->id, $course->id, $strresource));
print_simple_box(text_to_html($resource->alltext), "CENTER", "", "$THEME->cellcontent", "20");
echo "$strlastmodified: ".userdate($resource->timemodified)."
";
print_footer($course);
break;
case 6: // HTML text
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
"", "", true, update_module_button($cm->id, $course->id, $strresource));
print_simple_box_start("CENTER", "", "$THEME->cellcontent", "20");
echo $resource->alltext;
print_simple_box_end();
echo "$strlastmodified: ".userdate($resource->timemodified)."
";
print_footer($course);
break;
default:
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
"", "", true, update_module_button($cm->id, $course->id, $strresource));
print_heading($resource->name);
print_simple_box("Error: unknown type of resource", "center");
print_footer($course);
break;
}
?>