From 6aac6eef8ccf4240188f16305186c950b60a06b4 Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 11 Nov 2004 07:44:14 +0000 Subject: [PATCH] Access fixes, merged from stable --- mod/resource/lib.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mod/resource/lib.php b/mod/resource/lib.php index b0c43bd6e1..794b9f29e5 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -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 = "framename}\" href=\"$CFG->wwwroot/course/view.php?id={$this->course->id}\">{$this->course->shortname} -> ". + "framename}\" href=\"index.php?id={$this->course->id}\">$this->strresources ->"; + } else { + $this->navigation = "framename}\" href=\"index.php?id={$this->course->id}\">$this->strresources ->"; + } + + 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() { + } -- 2.39.5