]> git.mjollnir.org Git - moodle.git/commitdiff
IFxed some notices when the block was used on sticky blocks page. MDL-6620
authormoodler <moodler>
Sat, 30 Sep 2006 08:22:17 +0000 (08:22 +0000)
committermoodler <moodler>
Sat, 30 Sep 2006 08:22:17 +0000 (08:22 +0000)
blocks/admin/block_admin.php

index c6e4dc8793360f56541c223dd5a90feb42984081..a3dab444e8538295d941765c2ce5ddb8374e81e4 100644 (file)
@@ -8,7 +8,7 @@ class block_admin extends block_list {
 
     function get_content() {
 
-        global $CFG, $USER;
+        global $CFG, $USER, $SITE;
 
         if ($this->content !== NULL) {
             return $this->content;
@@ -25,10 +25,17 @@ class block_admin extends block_list {
             return $this->content = '';
         }
 
+        if (!empty($this->instance->pageid)) {
+            $context = get_context_instance(CONTEXT_COURSE, $this->instance->pageid);
+        }
 
-        $course = get_record('course', 'id', $this->instance->pageid);
+        if (empty($context)) {
+            $context = get_context_instance(CONTEXT_SYSTEM);
+        }
 
-        $context = get_context_instance(CONTEXT_COURSE, $this->instance->pageid);
+        if (!$course = get_record('course', 'id', $this->instance->pageid)) {
+            $course = $SITE;
+        }
 
         if (!has_capability('moodle/course:view', $context)) {  // Just return 
             return $this->content;