blocklib MDL-20207 Added $CFG->undeletableblocktypes and documented in config-dist
This commit is contained in:
@@ -172,6 +172,11 @@ $CFG->admin = 'admin';
|
||||
// These blocks are used when no other default setting is found.
|
||||
// $CFG->defaultblocks = 'participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity';
|
||||
//
|
||||
// The blocks in this list will be protected from deletion, and this is primarily
|
||||
// used to protect the navigation and settings blocks which can be very hard to
|
||||
// get back if accidentally delete.
|
||||
// $CFG->undeletableblocktypes = 'global_navigation_tree,settings_navigation_tree';
|
||||
//
|
||||
// You can specify a different class to be created for the $PAGE global, and to
|
||||
// compute which blocks appear on each page. However, I cannot think of any good
|
||||
// reason why you would need to change that. It just felt wrong to hard-code the
|
||||
|
||||
+11
-3
@@ -877,6 +877,12 @@ class block_manager {
|
||||
public function edit_controls($block) {
|
||||
global $CFG;
|
||||
|
||||
if (!isset($CFG->undeletableblocktypes) || (!is_array($CFG->undeletableblocktypes) && !is_string($CFG->undeletableblocktypes))) {
|
||||
$CFG->undeletableblocktypes = array('global_navigation_tree','settings_navigation_tree');
|
||||
} else if (is_string($CFG->undeletableblocktypes)) {
|
||||
$CFG->undeletableblocktypes = explode(',', $CFG->undeletableblocktypes);
|
||||
}
|
||||
|
||||
$controls = array();
|
||||
$actionurl = $this->page->url->out(false, array('sesskey'=> sesskey()), false);
|
||||
|
||||
@@ -905,9 +911,11 @@ class block_manager {
|
||||
}
|
||||
|
||||
if ($this->page->user_can_edit_blocks() && $block->user_can_edit() && $block->user_can_addto($this->page)) {
|
||||
// Delete icon.
|
||||
$controls[] = array('url' => $actionurl . '&bui_deleteid=' . $block->instance->id,
|
||||
'icon' => 't/delete', 'caption' => get_string('delete'));
|
||||
if (!in_array($block->instance->blockname, $CFG->undeletableblocktypes)) {
|
||||
// Delete icon.
|
||||
$controls[] = array('url' => $actionurl . '&bui_deleteid=' . $block->instance->id,
|
||||
'icon' => 't/delete', 'caption' => get_string('delete'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->page->user_can_edit_blocks()) {
|
||||
|
||||
Reference in New Issue
Block a user