From 8a2ab5f72d2cc246ea54f74c2b6f4fbc6b3f7705 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 13 Oct 2016 11:34:57 +0800 Subject: [PATCH] MDL-55074 navigation: Always show dashboard/home in flat nav --- course/admin.php | 19 +++++++++++++------ lib/navigationlib.php | 11 ++++------- theme/boost/classes/output/core_renderer.php | 20 ++++++++++++++++---- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/course/admin.php b/course/admin.php index b89b382332e..959101b17be 100644 --- a/course/admin.php +++ b/course/admin.php @@ -34,13 +34,20 @@ require_login($course); $context = context_course::instance($course->id); $PAGE->set_pagelayout('incourse'); -$PAGE->set_title(get_string('courseadministration')); -$PAGE->set_heading($course->fullname); -$PAGE->navbar->add(get_string('courseadministration')); -echo $OUTPUT->header(); -echo $OUTPUT->heading(get_string('courseadministration')); -$node = $PAGE->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE); +if ($courseid == $SITE->id) { + $title = get_string('frontpagesettings'); + $node = $PAGE->settingsnav->find('frontpage', navigation_node::TYPE_SETTING); +} else { + $title = get_string('courseadministration'); + $node = $PAGE->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE); +} +$PAGE->set_title($title); +$PAGE->set_heading($course->fullname); +$PAGE->navbar->add($title); +echo $OUTPUT->header(); +echo $OUTPUT->heading($title); + if ($node) { echo $OUTPUT->render_from_template('core/settings_link_page', ['node' => $node]); } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index bcdce0cdf2b..d13fc2ff006 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -1186,10 +1186,12 @@ class global_navigation extends navigation_node { // The home element should be my moodle because the root element is the site if (isloggedin() && !isguestuser()) { // Makes no sense if you aren't logged in $this->rootnodes['home'] = $this->add(get_string('myhome'), new moodle_url('/my/'), self::TYPE_SETTING, null, 'home'); + $this->rootnodes['home']->showinflatnavigation = true; } } else { // The home element should be the site because the root node is my moodle $this->rootnodes['home'] = $this->add(get_string('sitehome'), new moodle_url('/'), self::TYPE_SETTING, null, 'home'); + $this->rootnodes['home']->showinflatnavigation = true; if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY)) { // We need to stop automatic redirection $this->rootnodes['home']->action->param('redirect', '0'); @@ -1230,13 +1232,8 @@ class global_navigation extends navigation_node { // Load the users enrolled courses if they are viewing the My Moodle page AND the admin has not // set that they wish to keep the My Courses branch collapsed by default. - if (!empty($CFG->navexpandmycourses) && $this->page->pagelayout === 'mydashboard'){ - $this->rootnodes['mycourses']->forceopen = true; - $this->load_courses_enrolled(); - } else { - $this->rootnodes['mycourses']->collapse = true; - $this->rootnodes['mycourses']->make_inactive(); - } + $this->rootnodes['mycourses']->forceopen = true; + $this->load_courses_enrolled(); $canviewcourseprofile = true; diff --git a/theme/boost/classes/output/core_renderer.php b/theme/boost/classes/output/core_renderer.php index ffd652ea960..a79f2544a9a 100644 --- a/theme/boost/classes/output/core_renderer.php +++ b/theme/boost/classes/output/core_renderer.php @@ -505,11 +505,23 @@ class core_renderer extends \core_renderer { // Get the course admin node from the settings navigation. $items = $this->page->navbar->get_items(); $node = end($items); - if (($node->type == navigation_node::TYPE_COURSE)) { - $node = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE); - if ($node) { + $settingsnode = false; + if ($node->key === 'home') { + $settingsnode = $this->page->settingsnav->find('frontpage', navigation_node::TYPE_SETTING); + if ($settingsnode) { // Build an action menu based on the visible nodes from this navigation tree. - $this->build_action_menu_from_navigation($menu, $node, false, true); + $this->build_action_menu_from_navigation($menu, $settingsnode, false, true); + + $text = get_string('frontpagesettings'); + $url = new moodle_url('/course/admin.php', array('courseid' => $this->page->course->id)); + $link = new action_link($url, $text, null, null, new pix_icon('t/edit', $text)); + $menu->add_secondary_action($link); + } + } else if ($node->type == navigation_node::TYPE_COURSE) { + $settingsnode = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE); + if ($settingsnode) { + // Build an action menu based on the visible nodes from this navigation tree. + $this->build_action_menu_from_navigation($menu, $settingsnode, false, true); $text = get_string('courseadministration'); $url = new moodle_url('/course/admin.php', array('courseid' => $this->page->course->id));