diff --git a/course/format/social/format.php b/course/format/social/format.php
index 181b31da752..e4bbd135ae7 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 9a344017b86..84b70df3542 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 9e9ca9c61a5..e27b36cffaf 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 48dfcfa8480..8525a2a05b4 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 98e3c9c26a5..fc9d00c9722 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);