From 6b726eb4864a45a9af610323c06002c617afb6b6 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 15 Aug 2007 09:25:27 +0000 Subject: [PATCH] Just fixed some notices and formatting while debugging other stufff --- lib/blocklib.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/blocklib.php b/lib/blocklib.php index 3d259c85d7..1704bc362c 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -228,7 +228,7 @@ function blocks_have_content(&$pageblocks, $position) { // foreach() cannot fetch references in PHP v4.x for ($n=0; $nvisible) { + 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: -- 2.39.5