]> git.mjollnir.org Git - moodle.git/commitdiff
Just fixed some notices and formatting while debugging other stufff
authormoodler <moodler>
Wed, 15 Aug 2007 09:25:27 +0000 (09:25 +0000)
committermoodler <moodler>
Wed, 15 Aug 2007 09:25:27 +0000 (09:25 +0000)
lib/blocklib.php

index 3d259c85d759c13253beefbb00d0a63ffc903366..1704bc362ccf9fc32774197f2d0825201f6a81f5 100644 (file)
@@ -228,7 +228,7 @@ function blocks_have_content(&$pageblocks, $position) {
     // foreach() cannot fetch references in PHP v4.x
     for ($n=0; $n<count($pageblocks[$position]);$n++) {
         $instance = &$pageblocks[$position][$n];
-        if(!$instance->visible) {
+        if (empty($instance->visible)) {
             continue;
         }
         if(!$record = blocks_get_record($instance->blockid)) {
@@ -254,27 +254,34 @@ function blocks_have_content(&$pageblocks, $position) {
 function blocks_print_group(&$page, &$pageblocks, $position) {
     global $COURSE, $CFG, $USER;
 
-    if(empty($pageblocks[$position])) {
-        $pageblocks[$position] = array();
+    if (empty($pageblocks[$position])) {
+        $groupblocks = array();
         $maxweight = 0;
+    } else {
+        $groupblocks = $pageblocks[$position];
+        $maxweight = max(array_keys($groupblocks));
     }
-    else {
-        $maxweight = max(array_keys($pageblocks[$position]));
-    }
 
-    foreach ($pageblocks[$position] as $instance) {
+
+    foreach ($groupblocks as $instance) {
         if (!empty($instance->pinned)) {
             $maxweight--;
         }
     }
 
     $isediting = $page->user_is_editing();
-    foreach($pageblocks[$position] as $instance) {
+
+
+    foreach($groupblocks as $instance) {
+
 
         // $instance may have ->rec and ->obj
         // cached from when we walked $pageblocks
         // in blocks_have_content()
         if (empty($instance->rec)) {
+            if (empty($instance->blockid)) {
+                continue;   // Can't do anything
+            }
             $block = blocks_get_record($instance->blockid);
         } else {
             $block = $instance->rec;
@@ -285,7 +292,7 @@ function blocks_print_group(&$page, &$pageblocks, $position) {
             continue;
         }
 
-        if(!$block->visible) {
+        if (empty($block->visible)) {
             // Disabled by the admin
             continue;
         }
@@ -301,6 +308,7 @@ function blocks_print_group(&$page, &$pageblocks, $position) {
 
         $editalways = $page->edit_always();
 
+
         if (($isediting  && empty($instance->pinned)) || !empty($editalways)) {
             $options = 0;
             // The block can be moved up if it's NOT the first one in its position. If it is, we look at the OR clause: