From 531cc5c72711774e38796104505f24ad3b996c62 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 8 Jan 2015 14:58:26 +0800 Subject: [PATCH] MDL-48544 blocks: Only add docked tags if all blocks are docked Previously, if all blocks were hidden, then the region was reported as being docked eroniously and it was not possible to unhide the blocks. Docking should have no relation to the presence of block content. --- blocks/tests/behat/hide_blocks.feature | 28 ++++++++++++++++++++++++++ lib/blocklib.php | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 blocks/tests/behat/hide_blocks.feature diff --git a/blocks/tests/behat/hide_blocks.feature b/blocks/tests/behat/hide_blocks.feature new file mode 100644 index 00000000000..72822ba11b7 --- /dev/null +++ b/blocks/tests/behat/hide_blocks.feature @@ -0,0 +1,28 @@ +@core @core_block +Feature: Block visibility + In order to configure blocks visibility + As a teacher + I need to show and hide blocks on a page + + Background: + Given the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And I log in as "admin" + And I am on homepage + And I follow "Course 1" + And I follow "Turn editing on" + + @javascript + Scenario: Hiding all blocks on the page should remove the column they're in + Given I open the "Search forums" blocks action menu + And I click on "Hide Search forums block" "link" in the "Search forums" "block" + And I open the "Latest news" blocks action menu + And I click on "Hide Latest news block" "link" in the "Latest news" "block" + And I open the "Upcoming events" blocks action menu + And I click on "Hide Upcoming events block" "link" in the "Upcoming events" "block" + And I open the "Recent activity" blocks action menu + When I click on "Hide Recent activity block" "link" in the "Recent activity" "block" + Then ".empty-region-side-post" "css_element" should not exist in the "body" "css_element" + And I follow "Turn editing off" + And ".empty-region-side-post" "css_element" should exist in the "body" "css_element" diff --git a/lib/blocklib.php b/lib/blocklib.php index f75455aa3c4..87879510c56 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -493,7 +493,7 @@ class block_manager { return false; } foreach ($this->visibleblockcontent[$region] as $instance) { - if (!empty($instance->content) && !get_user_preferences('docked_block_instance_'.$instance->blockinstanceid, 0)) { + if (!get_user_preferences('docked_block_instance_'.$instance->blockinstanceid, 0)) { return false; } }