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 = "framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname -> framename}\" href=\"index.php?id=$course->id\">$strresources ->"; } else { $navigation = "framename}\" href=\"index.php?id=$course->id\">$strresources ->"; } $pagetitle = strip_tags("$course->shortname: $resource->name"); if (!$cm->visible and !isteacher($course->id)) { print_header($pagetitle, "$course->fullname", "$navigation $resource->name", "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm)); notice(get_string("activityiscurrentlyhidden")); } switch ($resource->type) { case REFERENCE: add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id"); print_header($pagetitle, "$course->fullname", "$navigation $resource->name", "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm)); 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 WEBLINK: add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id"); redirect($resource->reference, "", 0); break; case WEBPAGE: if ($frameset == "top") { print_header($pagetitle, "$course->fullname", "$navigation framename}\" href=\"$resource->reference\" title=\"$resource->reference\">$resource->name", "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm, "parent")); 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 "resource_framesize,*>"; echo "id&frameset=top\">"; echo "reference\">"; echo ""; } break; case UPLOADEDFILE: require_once("../../files/mimetypes.php"); if ($CFG->slasharguments) { $fullurl = "$CFG->wwwroot/file.php/$course->id/$resource->reference"; } else { $fullurl = "$CFG->wwwroot/file.php?file=/$course->id/$resource->reference"; } $embedded = false; if (mimeinfo("icon", $fullurl) == "image.gif") { // It's an image $embedded = true; $resourceimage = true; } else { $resourceimage = false; } // (could check for more embeddable media here...) if ($frameset == "top" or $embedded) { if ($frameset == "top") { $targetwindow = "parent"; } else { $targetwindow = "self"; } print_header($pagetitle, "$course->fullname", "$navigation framename\" HREF=\"$fullurl\">$resource->name", "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm, $targetwindow)); echo "
".text_to_html($resource->summary, true, false)."
"; add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id"); } if ($embedded) { // Display resource embedded in page if ($resourceimage) { echo "
"; echo "
"; echo "
"; } print_footer($course); } else { // Display resource in a frame of it's own. echo "$course->shortname: $resource->name\n"; echo "resource_framesize,*>"; echo "id&frameset=top\">"; echo ""; echo ""; } break; case PLAINTEXT: add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id"); print_header($pagetitle, "$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 "

$strlastmodified: ".userdate($resource->timemodified)."

"; print_footer($course); break; case HTML: add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id"); print_header($pagetitle, "$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 "

$strlastmodified: ".userdate($resource->timemodified)."

"; print_footer($course); break; case PROGRAM: // Code provided by Mark Kimes 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>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; case WIKITEXT: add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id"); print_header($pagetitle, "$course->fullname", "$navigation $resource->name", "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm)); print_simple_box(wiki_to_html($resource->alltext), "center", "", "$THEME->cellcontent", "20" ); echo "

$strlastmodified: ".userdate($resource->timemodified)."

"; print_footer($course); break; default: print_header($pagetitle, "$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; } ?>