Access fixes, merged from stable

This commit is contained in:
moodler
2004-11-11 07:44:14 +00:00
parent 6a6002f68c
commit 6aac6eef8c
+26
View File
@@ -66,11 +66,14 @@ var $resource;
*
* 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");
@@ -80,14 +83,37 @@ function resource_base($cmid=0) {
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() {
}