*
* Constructor for the base resource class.
* If cmid is set create the cm, course, resource objects.
+* and do some checks to make sure people can be here, and so on.
*
* @param cmid integer, the current course module id - not set for new resources
*/
function resource_base($cmid=0) {
+ global $CFG;
+
if ($cmid) {
if (! $this->cm = get_record("course_modules", "id", $cmid)) {
error("Course Module ID was incorrect");
error("Course is misconfigured");
}
+ require_course_login($this->course);
+
if (! $this->resource = get_record("resource", "id", $this->cm->instance)) {
error("Resource ID was incorrect");
}
+
+ $this->strresource = get_string("modulename", "resource");
+ $this->strresources = get_string("modulenameplural", "resource");
+
+ if ($this->course->category) {
+ require_login($this->course->id);
+ $this->navigation = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/course/view.php?id={$this->course->id}\">{$this->course->shortname}</a> -> ".
+ "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$this->strresources</a> ->";
+ } else {
+ $this->navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id={$this->course->id}\">$this->strresources</a> ->";
+ }
+
+ if (!$this->cm->visible and !isteacher($this->course->id)) {
+ $pagetitle = strip_tags($this->course->shortname.': '.$this->strresource);
+ print_header($pagetitle, $this->course->fullname, "$this->navigation $this->strresource", "", "", true, '', navmenu($this->course, $this->cm));
+ notice(get_string("activityiscurrentlyhidden"), "$CFG->wwwroot/course/view.php?id={$this->course->id}");
+ }
}
}
+/**
+* Display function does nothing in the base class
+*/
function display() {
+
}