-
Bug
-
Resolution: Fixed
-
Major
-
2.2.5, 2.3.2
-
MOODLE_22_STABLE, MOODLE_23_STABLE
-
MOODLE_24_STABLE
-
This may be contentious, we (the OU) think the logic that was implemented in MDL-27122 is wrong.
The logic currently is:
if (!in_array($block->instance->blockname, $undeletableblocktypes)
|
|| !in_array($block->instance->pagetypepattern, array('*', 'site-index'))
|
|| $block->instance->parentcontextid != SITEID) {
|
// Delete icon.
|
$controls[] = array('url' => $actionurl . '&bui_deleteid=' . $block->instance->id,
|
'icon' => 't/delete', 'caption' => get_string('delete'), 'class' => 'editing_delete');
|
}
|
what that means is that a block is only protected from deletion if all of these are true:
- The type of block is protected
- The block's parent context is the system context
- The block is set to show on all pages, or just on the site index page.
This causes problems. Steps to reproduce:
- Create a new type of block that implements some special feature.
- As admin, carefully set up one instance of this block as follows:
- parent context: system context
- show in that context and subcontexts
- page type pattern course-view-*
- As a stupid person, who has rashly been trusted with Manager role, go to any course page. Decide you don't like that block, and click its delete icon.
Expected result: actually, that block should not have had a delete icon at all.
Actual result: the global instance of the block is deleted (again), admin cries.
I cannot see any problem if we change the logic to just
if (!in_array($block->instance->blockname, $undeletableblocktypes)) {
|
// Delete icon.
|
$controls[] = array('url' => $actionurl . '&bui_deleteid=' . $block->instance->id,
|
'icon' => 't/delete', 'caption' => get_string('delete'), 'class' => 'editing_delete');
|
}
|
If we do this, we should also change get_addable_blocks so you cannot add blocks that you are then unable to delete.
If you ever do need to change the protected block instances, the admin can temporarily un-protect that type of block.
- has a non-specific relationship to
-
MDL-27122 The Settings block shows up two times on the Front Page without the option to remove any of them
-
- Closed
-
- has been marked as being related by
-
MDL-57232 After upgrade to 3.2, some blocks do not disappear when they should, and some do disappear when they should not
-
- Closed
-