mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-73462 course: Update visible nodes in a cat context.
This commit is contained in:
parent
f1959af7f6
commit
b9f9aae134
@ -104,6 +104,7 @@ function tool_lp_extend_navigation_category_settings($navigation, $coursecategor
|
|||||||
null,
|
null,
|
||||||
new pix_icon('i/competencies', ''));
|
new pix_icon('i/competencies', ''));
|
||||||
if (isset($settingsnode)) {
|
if (isset($settingsnode)) {
|
||||||
|
$settingsnode->set_force_into_more_menu(true);
|
||||||
$navigation->add_node($settingsnode);
|
$navigation->add_node($settingsnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,6 +120,7 @@ function tool_lp_extend_navigation_category_settings($navigation, $coursecategor
|
|||||||
null,
|
null,
|
||||||
new pix_icon('i/competencies', ''));
|
new pix_icon('i/competencies', ''));
|
||||||
if (isset($settingsnode)) {
|
if (isset($settingsnode)) {
|
||||||
|
$settingsnode->set_force_into_more_menu(true);
|
||||||
$navigation->add_node($settingsnode);
|
$navigation->add_node($settingsnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,9 +137,24 @@ class secondary extends view {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function get_default_category_mapping(): array {
|
protected function get_default_category_mapping(): array {
|
||||||
return [];
|
return [
|
||||||
|
self::TYPE_SETTING => [
|
||||||
|
'edit' => 1,
|
||||||
|
'permissions' => 2,
|
||||||
|
'roles' => 2.1,
|
||||||
|
'checkpermissions' => 2.2,
|
||||||
|
]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the keys of the course secondary nav nodes that should be forced into the "more" menu by default.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function get_default_category_more_menu_nodes(): array {
|
||||||
|
return ['addsubcat', 'roles', 'permissions', 'contentbank', 'cohort', 'filters', 'restorecourse'];
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Define the keys of the course secondary nav nodes that should be forced into the "more" menu by default.
|
* Define the keys of the course secondary nav nodes that should be forced into the "more" menu by default.
|
||||||
*
|
*
|
||||||
@ -211,6 +226,7 @@ class secondary extends view {
|
|||||||
case CONTEXT_COURSECAT:
|
case CONTEXT_COURSECAT:
|
||||||
$this->headertitle = get_string('categoryheader');
|
$this->headertitle = get_string('categoryheader');
|
||||||
$this->load_category_navigation();
|
$this->load_category_navigation();
|
||||||
|
$defaultmoremenunodes = $this->get_default_category_more_menu_nodes();
|
||||||
break;
|
break;
|
||||||
case CONTEXT_SYSTEM:
|
case CONTEXT_SYSTEM:
|
||||||
$this->headertitle = get_string('homeheader');
|
$this->headertitle = get_string('homeheader');
|
||||||
@ -659,14 +675,10 @@ class secondary extends view {
|
|||||||
$settingsnav = $this->page->settingsnav;
|
$settingsnav = $this->page->settingsnav;
|
||||||
$mainnode = $settingsnav->find('categorysettings', self::TYPE_CONTAINER);
|
$mainnode = $settingsnav->find('categorysettings', self::TYPE_CONTAINER);
|
||||||
$nodes = $this->get_default_category_mapping();
|
$nodes = $this->get_default_category_mapping();
|
||||||
$siteadmin = $settingsnav->find('root', self::TYPE_SITE_ADMIN);
|
|
||||||
|
|
||||||
// If an admin is viewing a category context then load the site admin menu.
|
if ($mainnode) {
|
||||||
if ($siteadmin) {
|
|
||||||
$this->load_admin_navigation();
|
|
||||||
} else if ($mainnode) {
|
|
||||||
$url = new \moodle_url('/course/index.php', ['categoryid' => $this->context->instanceid]);
|
$url = new \moodle_url('/course/index.php', ['categoryid' => $this->context->instanceid]);
|
||||||
$this->add($this->context->get_context_name(), $url, self::TYPE_CONTAINER, null, 'categorymain');
|
$this->add(get_string('category'), $url, self::TYPE_CONTAINER, null, 'categorymain');
|
||||||
|
|
||||||
// Add the initial nodes.
|
// Add the initial nodes.
|
||||||
$nodesordered = $this->get_leaf_nodes($mainnode, $nodes);
|
$nodesordered = $this->get_leaf_nodes($mainnode, $nodes);
|
||||||
|
@ -5418,12 +5418,13 @@ class settings_navigation extends navigation_node {
|
|||||||
if (can_edit_in_category($catcontext->instanceid)) {
|
if (can_edit_in_category($catcontext->instanceid)) {
|
||||||
$url = new moodle_url('/course/management.php', array('categoryid' => $catcontext->instanceid));
|
$url = new moodle_url('/course/management.php', array('categoryid' => $catcontext->instanceid));
|
||||||
$editstring = get_string('managecategorythis');
|
$editstring = get_string('managecategorythis');
|
||||||
$categorynode->add($editstring, $url, self::TYPE_SETTING, null, 'managecategory', new pix_icon('i/edit', ''));
|
$node = $categorynode->add($editstring, $url, self::TYPE_SETTING, null, 'managecategory', new pix_icon('i/edit', ''));
|
||||||
|
$node->set_show_in_secondary_navigation(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_capability('moodle/category:manage', $catcontext)) {
|
if (has_capability('moodle/category:manage', $catcontext)) {
|
||||||
$editurl = new moodle_url('/course/editcategory.php', array('id' => $catcontext->instanceid));
|
$editurl = new moodle_url('/course/editcategory.php', array('id' => $catcontext->instanceid));
|
||||||
$categorynode->add(get_string('editcategorythis'), $editurl, self::TYPE_SETTING, null, 'edit', new pix_icon('i/edit', ''));
|
$categorynode->add(get_string('settings'), $editurl, self::TYPE_SETTING, null, 'edit', new pix_icon('i/edit', ''));
|
||||||
|
|
||||||
$addsubcaturl = new moodle_url('/course/editcategory.php', array('parent' => $catcontext->instanceid));
|
$addsubcaturl = new moodle_url('/course/editcategory.php', array('parent' => $catcontext->instanceid));
|
||||||
$categorynode->add(get_string('addsubcategory'), $addsubcaturl, self::TYPE_SETTING, null,
|
$categorynode->add(get_string('addsubcategory'), $addsubcaturl, self::TYPE_SETTING, null,
|
||||||
@ -5449,13 +5450,6 @@ class settings_navigation extends navigation_node {
|
|||||||
$categorynode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, 'checkpermissions', new pix_icon('i/checkpermissions', ''));
|
$categorynode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, 'checkpermissions', new pix_icon('i/checkpermissions', ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
$cb = new contentbank();
|
|
||||||
if ($cb->is_context_allowed($catcontext)
|
|
||||||
&& has_capability('moodle/contentbank:access', $catcontext)) {
|
|
||||||
$url = new \moodle_url('/contentbank/index.php', ['contextid' => $catcontext->id]);
|
|
||||||
$categorynode->add(get_string('contentbank'), $url, self::TYPE_CUSTOM, null, 'contentbank', new \pix_icon('i/contentbank', ''));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the context locking node.
|
// Add the context locking node.
|
||||||
$this->add_context_locking_node($categorynode, $catcontext);
|
$this->add_context_locking_node($categorynode, $catcontext);
|
||||||
|
|
||||||
@ -5485,6 +5479,14 @@ class settings_navigation extends navigation_node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cb = new contentbank();
|
||||||
|
if ($cb->is_context_allowed($catcontext)
|
||||||
|
&& has_capability('moodle/contentbank:access', $catcontext)) {
|
||||||
|
$url = new \moodle_url('/contentbank/index.php', ['contextid' => $catcontext->id]);
|
||||||
|
$categorynode->add(get_string('contentbank'), $url, self::TYPE_CUSTOM, null,
|
||||||
|
'contentbank', new \pix_icon('i/contentbank', ''));
|
||||||
|
}
|
||||||
|
|
||||||
return $categorynode;
|
return $categorynode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user