Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e34461f5ea
Fetching contributors…

Cannot retrieve contributors at this time

file 132 lines (102 sloc) 5.812 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
<?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> ->";
}


switch ($resource->type) {
case REFERENCE:
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), navmenu($course, $cm));

print_simple_box($resource->reference, "center");
echo "<CENTER><P>";
echo text_to_html($resource->summary);
echo "</P>";
echo "<P>&nbsp</P>";
echo "<P><FONT SIZE=1>$strlastmodified: ".userdate($resource->timemodified)."</P>";
echo "</CENTER>";
print_footer($course);
break;

case WEBLINK:
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
redirect($resource->reference);
break;

case WEBPAGE:
if ($frameset) {
print_header("$course->shortname: $resource->name", "$course->fullname",
"$navigation <A TARGET=_top HREF=\"$resource->reference\" TITLE=\"$resource->reference\">$resource->name</A>",
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
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";
echo "<FRAMESET ROWS=130,*>";
echo "<FRAME SRC=\"view.php?id=$cm->id&frameset=true\">";
                echo "<FRAME SRC=\"$resource->reference\">";
echo "</FRAMESET>";
}
break;

case UPLOADEDFILE:
if ($frameset) {
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
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";
echo "<FRAMESET ROWS=130,*>";
echo "<FRAME SRC=\"view.php?id=$cm->id&frameset=true\">";
                echo "<FRAME SRC=\"$CFG->wwwroot/$ffurl\">";
echo "</FRAMESET>";
}
break;

case PLAINTEXT:
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), navmenu($course, $cm));

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;

case HTML:
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), navmenu($course, $cm));

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;

default:
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
"", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
print_heading($resource->name);

print_simple_box("Error: unknown type of resource", "center");

print_footer($course);
break;
}


?>
Something went wrong with that request. Please try again.