From c1d8705fd2a164ab96e05aaf7610e1b9d8cf22e6 Mon Sep 17 00:00:00 2001 From: defacer Date: Wed, 2 Feb 2005 02:41:56 +0000 Subject: [PATCH] Change the semantics of blocks_print_adminblock() to make life easier to developers who use pages. Conversely simplified the code a bit in courses. --- course/format/social/format.php | 4 ++-- course/format/topics/format.php | 4 ++-- course/format/weeks/format.php | 4 ++-- index.php | 6 ++---- lib/blocklib.php | 8 +++++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/course/format/social/format.php b/course/format/social/format.php index 181b31da75..e4bbd135ae 100644 --- a/course/format/social/format.php +++ b/course/format/social/format.php @@ -57,8 +57,8 @@ if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) { echo ''; blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]); - if ($editing && !empty($missingblocks)) { - blocks_print_adminblock($PAGE, $missingblocks); + if ($editing) { + blocks_print_adminblock($PAGE, $pageblocks); } echo ''; } diff --git a/course/format/topics/format.php b/course/format/topics/format.php index 9a344017b8..84b70df354 100644 --- a/course/format/topics/format.php +++ b/course/format/topics/format.php @@ -273,8 +273,8 @@ if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) { echo ''; blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]); - if ($editing && !empty($missingblocks)) { - blocks_print_adminblock($PAGE, $missingblocks); + if ($editing) { + blocks_print_adminblock($PAGE, $pageblocks); } echo ''; } diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index 9e9ca9c61a..e27b36cffa 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -259,8 +259,8 @@ if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) { echo ''; blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]); - if ($editing && !empty($missingblocks)) { - blocks_print_adminblock($PAGE, $missingblocks); + if ($editing) { + blocks_print_adminblock($PAGE, $pageblocks); } echo ''; } diff --git a/index.php b/index.php index 48dfcfa848..8525a2a05b 100644 --- a/index.php +++ b/index.php @@ -76,8 +76,6 @@ // but I'm not sure if it's worth the complexity increase... $pageblocks = blocks_get_by_page($PAGE); } - - $missingblocks = blocks_get_missing($PAGE, $pageblocks); } optional_variable($preferred_width_left, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT])); @@ -216,8 +214,8 @@ echo '
'; } blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]); - if ($editing && !empty($missingblocks)) { - blocks_print_adminblock($PAGE, $missingblocks); + if ($editing) { + blocks_print_adminblock($PAGE, $pageblocks); } echo ''; } diff --git a/lib/blocklib.php b/lib/blocklib.php index 98e3c9c26a..fc9d00c972 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -542,12 +542,14 @@ function blocks_get_by_page($page) { } //This function prints the block to admin blocks as necessary -function blocks_print_adminblock($page, $missingblocks) { +function blocks_print_adminblock(&$page, &$pageblocks) { global $USER; - $strblocks = get_string('blocks'); - $stradd = get_string('add'); + $missingblocks = blocks_get_missing($page, $pageblocks); + if (!empty($missingblocks)) { + $strblocks = get_string('blocks'); + $stradd = get_string('add'); foreach ($missingblocks as $blockid) { $block = blocks_get_record($blockid); $blockobject = block_instance($block->name); -- 2.39.5