Merge branch 'wip-MDL-56586-master-2' of git://github.com/marinaglancy/moodle

This commit is contained in:
Dan Poltawski
2016-11-24 09:30:29 +00:00
24 changed files with 481 additions and 91 deletions
+19
View File
@@ -3764,6 +3764,25 @@ class flat_navigation extends navigation_node_collection {
$flat->key = 'sitesettings';
$this->add($flat);
}
// Add-a-block in editing mode.
if (isset($this->page->theme->addblockposition) &&
$this->page->theme->addblockposition == BLOCK_ADDBLOCK_POSITION_FLATNAV &&
$PAGE->user_is_editing() && $PAGE->user_can_edit_blocks() &&
($addable = $PAGE->blocks->get_addable_blocks())) {
$url = new moodle_url($PAGE->url, ['bui_addblock' => '', 'sesskey' => sesskey()]);
$addablock = navigation_node::create(get_string('addblock'), $url);
$flat = new flat_navigation_node($addablock, 0);
$flat->set_showdivider(true);
$flat->key = 'addblock';
$this->add($flat);
$blocks = [];
foreach ($addable as $block) {
$blocks[] = $block->name;
}
$params = array('blocks' => $blocks, 'url' => '?' . $url->get_query_string(false));
$PAGE->requires->js_call_amd('core/addblockmodal', 'init', array($params));
}
}
}