]> git.mjollnir.org Git - moodle.git/commitdiff
Access fixes, merged from stable
authormoodler <moodler>
Thu, 11 Nov 2004 07:44:14 +0000 (07:44 +0000)
committermoodler <moodler>
Thu, 11 Nov 2004 07:44:14 +0000 (07:44 +0000)
mod/resource/lib.php

index b0c43bd6e1606f6a64acf27ac2602daa91efb30a..794b9f29e5ce62534e33968a104fa175e69febd2 100644 (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() {
+
 }