]> git.mjollnir.org Git - moodle.git/commitdiff
Now we can get a list of the blocks being on display in the course page.
authordefacer <defacer>
Fri, 21 May 2004 11:06:49 +0000 (11:06 +0000)
committerdefacer <defacer>
Fri, 21 May 2004 11:06:49 +0000 (11:06 +0000)
Could be used by one block to detect the existence of another, for example.

course/view.php
lib/blocklib.php

index bf2bb97b14361a031f99b44aec570e52043f44f7..dc85cc7790829cc4ebd7e97b6199e806f1735aae 100644 (file)
         $missingblocks = array();
         $recblocks = get_records('blocks','visible','1');
 
+        // Note down which blocks are going to get displayed
+        blocks_used($allblocks, $recblocks);
+
         if($editing && $recblocks) {
             foreach($recblocks as $recblock) {
                 // If it's not hidden or displayed right now...
         }
     } else {
         $USER->editing = false;
+
+        // Note down which blocks are going to get displayed
+        $allblocks = array_merge($leftblocks, $rightblocks);
+        $recblocks = get_records('blocks','visible','1');
+        blocks_used($allblocks, $recblocks);
     }
 
     $SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
index 87353413a613d54f90d27767743ce65c49a683ad..aa5396d67d137869587893a716b65923fe3db798 100644 (file)
@@ -889,4 +889,22 @@ function blocks_get_block_ids ($blockinfo) {
     //Just call this with the appropiate parammeters.
     return blocks_get_default_blocks(NULL,$blockinfo);
 }
+
+// This is used to register the blocks that are displayed in the course page.
+// Set in course/view.php, and read from any other place.
+function blocks_used($blocks = NULL, $records = NULL) {
+    static $used = NULL;
+
+    if(!empty($blocks) && !empty($records)) {
+        $used = array();
+        foreach($blocks as $val) {
+            if($val > 0 && isset($records[$val])) {
+                $used[] = $records[$val]->name;
+            }
+        }
+    }
+
+    return $used;
+}
+
 ?>