// 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
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);
}
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()) {