From 29ac5a6bcee85c9d4d72f92d3316660d8bc37e4e Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 19 Nov 2014 10:22:02 +0800 Subject: [PATCH] MDL-14402 blocks: Do not show assign roles on my home --- .../configure_block_throughout_site.feature | 24 +++++++++++++++++++ lib/blocklib.php | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/blocks/tests/behat/configure_block_throughout_site.feature b/blocks/tests/behat/configure_block_throughout_site.feature index b51143a4b07..b71303c1e31 100644 --- a/blocks/tests/behat/configure_block_throughout_site.feature +++ b/blocks/tests/behat/configure_block_throughout_site.feature @@ -32,3 +32,27 @@ Feature: Add and configure blocks throughout the site And I follow "Course 1" # The first block matching the pattern should be top-left block And I should see "Comments" in the "//*[@id='region-pre' or @id='block-region-side-pre']/descendant::div[contains(concat(' ', normalize-space(@class), ' '), ' block ')]" "xpath_element" + + Scenario: Blocks on the my home page cannot have roles assigned to them + Given the following "users" exist: + | username | firstname | lastname | email | + | manager1 | Manager | 1 | manager1@asd.com | + And I log in as "manager1" + And I click on "My home" "link" in the "Navigation" "block" + When I press "Customise this page" + Then I should not see "Assign roles in Navigation block" + + Scenario: Blocks on courses can have roles assigned to them + Given the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | teacher | 1 | teacher@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I follow "Course 1" + And I follow "Turn editing on" + Then I should see "Assign roles in Search forums block" diff --git a/lib/blocklib.php b/lib/blocklib.php index f8d12bf31c4..01d59ccef65 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1082,7 +1082,7 @@ class block_manager { } // Assign roles icon. - if (has_capability('moodle/role:assign', $block->context)) { + if ($this->page->pagetype != 'my-index' && has_capability('moodle/role:assign', $block->context)) { //TODO: please note it is sloppy to pass urls through page parameters!! // it is shortened because some web servers (e.g. IIS by default) give // a 'security' error if you try to pass a full URL as a GET parameter in another URL.