2002-10-17 14:03:59 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
|
|
|
require("../../config.php");
|
|
|
|
require("lib.php");
|
|
|
|
|
|
|
|
require_variable($id); // Course Module ID
|
|
|
|
|
|
|
|
if (! $cm = get_record("course_modules", "id", $id)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $cm->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 = "<A TARGET=_top HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->
|
|
|
|
<A TARGET=_top HREF=\"index.php?id=$course->id\">$strresources</A> ->";
|
|
|
|
} else {
|
|
|
|
$navigation = "<A TARGET=_top HREF=\"index.php?id=$course->id\">$strresources</A> ->";
|
|
|
|
}
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
|
2002-10-17 14:03:59 +00:00
|
|
|
switch ($resource->type) {
|
2002-11-10 14:03:25 +00:00
|
|
|
case REFERENCE:
|
2002-10-17 14:03:59 +00:00
|
|
|
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",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
|
|
|
|
print_simple_box($resource->reference, "center");
|
|
|
|
echo "<CENTER><P>";
|
|
|
|
echo text_to_html($resource->summary);
|
|
|
|
echo "</P>";
|
|
|
|
echo "<P> </P>";
|
|
|
|
echo "<P><FONT SIZE=1>$strlastmodified: ".userdate($resource->timemodified)."</P>";
|
|
|
|
echo "</CENTER>";
|
|
|
|
print_footer($course);
|
|
|
|
break;
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
case WEBLINK:
|
2002-10-17 14:03:59 +00:00
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
redirect($resource->reference);
|
|
|
|
break;
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
case WEBPAGE:
|
2002-10-17 14:03:59 +00:00
|
|
|
if ($frameset) {
|
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname",
|
|
|
|
"$navigation <A TARGET=_top HREF=\"$resource->reference\" TITLE=\"$resource->reference\">$resource->name</A>",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
echo "<CENTER><FONT SIZE=-1>".text_to_html($resource->summary, true, false)."</FONT></CENTER>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
echo "<HEAD><TITLE>$course->shortname: $resource->name</TITLE></HEAD>\n";
|
2003-01-05 10:10:05 +00:00
|
|
|
echo "<FRAMESET ROWS=$RESOURCE_FRAME_SIZE,*>";
|
2002-10-17 14:03:59 +00:00
|
|
|
echo "<FRAME SRC=\"view.php?id=$cm->id&frameset=true\">";
|
|
|
|
echo "<FRAME SRC=\"$resource->reference\">";
|
|
|
|
echo "</FRAMESET>";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
case UPLOADEDFILE:
|
2002-10-17 14:03:59 +00:00
|
|
|
if ($frameset) {
|
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
echo "<CENTER><FONT SIZE=-1>".text_to_html($resource->summary, true, false)."</FONT></CENTER>";
|
|
|
|
|
|
|
|
} 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 "<HEAD><TITLE>$course->shortname: $resource->name</TITLE></HEAD>\n";
|
2003-01-05 10:10:05 +00:00
|
|
|
echo "<FRAMESET ROWS=$RESOURCE_FRAME_SIZE,*>";
|
2002-10-17 14:03:59 +00:00
|
|
|
echo "<FRAME SRC=\"view.php?id=$cm->id&frameset=true\">";
|
|
|
|
echo "<FRAME SRC=\"$CFG->wwwroot/$ffurl\">";
|
|
|
|
echo "</FRAMESET>";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
case PLAINTEXT:
|
2002-10-17 14:03:59 +00:00
|
|
|
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",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
|
|
|
|
print_simple_box(text_to_html($resource->alltext), "CENTER", "", "$THEME->cellcontent", "20");
|
|
|
|
|
|
|
|
echo "<CENTER><P><FONT SIZE=1>$strlastmodified: ".userdate($resource->timemodified)."</P></CENTER>";
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
break;
|
|
|
|
|
2002-11-10 14:03:25 +00:00
|
|
|
case HTML:
|
2002-10-17 14:03:59 +00:00
|
|
|
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",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
|
|
|
|
print_simple_box_start("CENTER", "", "$THEME->cellcontent", "20");
|
|
|
|
|
|
|
|
echo $resource->alltext;
|
|
|
|
|
|
|
|
print_simple_box_end();
|
|
|
|
|
|
|
|
echo "<CENTER><P><FONT SIZE=1>$strlastmodified: ".userdate($resource->timemodified)."</P></CENTER>";
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
break;
|
|
|
|
|
2002-12-24 07:01:03 +00:00
|
|
|
case PROGRAM: // Code provided by Mark Kimes <hectorp@buckfoodsvc.com>
|
|
|
|
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
|
|
|
|
|
|
|
|
$temptime = gmdate("YmdHis",time());
|
|
|
|
|
|
|
|
$temproot = $CFG->wwwroot . "/mod/resource/";
|
|
|
|
|
|
|
|
// I tried to get around this. I really did. But here we
|
|
|
|
// are, redefining the navigation resources specifically anyway.
|
|
|
|
// On the plus side, you can change the format of the navigation
|
|
|
|
// strings above without worrying what it'll do to this code. On
|
|
|
|
// the negative side, you'll have to update this code if you
|
|
|
|
// change the structure of the navigation completely. Bonus
|
|
|
|
// is that now we can have a chain of cooperative sites, each
|
|
|
|
// adding to the navigation string as it moves down the line,
|
|
|
|
// which could be quite cool. -- Mark
|
|
|
|
|
|
|
|
if ($course->category) {
|
|
|
|
$tempref = "<$course->shortname><" . $temproot . "../../course/view.php?id=$course->id>" .
|
|
|
|
"<$strresources><" . $temproot . "index.php?id=$course->id>";
|
|
|
|
} else {
|
|
|
|
$tempref = "<$strresources><index.php?id=$course->id>";
|
|
|
|
}
|
|
|
|
|
|
|
|
$tempurl = trim($resource->reference);
|
|
|
|
|
|
|
|
if ($tempquerystring = strstr($tempurl,'?')) {
|
|
|
|
$tempquerystring = substr($tempquerystring,1);
|
|
|
|
$tempurl = substr($tempurl,0,strlen($tempurl) - strlen($tempquerystring));
|
|
|
|
}
|
|
|
|
if (!empty($tempquerystring)) {
|
|
|
|
$tempquerystring = preg_replace("/(.*=)([^&]*)/e",
|
|
|
|
"'\\1' . urlencode('\\2')",
|
|
|
|
$tempquerystring);
|
|
|
|
}
|
|
|
|
$temp = $tempurl . $tempquerystring .
|
|
|
|
((strstr($tempurl,'?')) ? "&" : "?") .
|
|
|
|
"extern_nav=" . urlencode($tempref) .
|
|
|
|
"&extern_usr=" .
|
|
|
|
urlencode($USER->username) .
|
|
|
|
"&extern_nam=" . urlencode("$USER->firstname $USER->lastname") .
|
|
|
|
"&extern_tim=" . urlencode($temptime) .
|
|
|
|
"&extern_pwd=" .
|
|
|
|
urlencode(md5($temptime . $USER->password));
|
|
|
|
redirect($temp);
|
|
|
|
break;
|
|
|
|
|
2002-10-17 14:03:59 +00:00
|
|
|
default:
|
|
|
|
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
|
2002-11-10 07:37:15 +00:00
|
|
|
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
|
2002-10-17 14:03:59 +00:00
|
|
|
print_heading($resource->name);
|
|
|
|
|
|
|
|
print_simple_box("Error: unknown type of resource", "center");
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|