From 91b30b4fd1d88075f4fe3ce1a338544accdbe335 Mon Sep 17 00:00:00 2001 From: Jason den Dulk Date: Wed, 24 Nov 2021 13:13:52 +1100 Subject: [PATCH] MDL-72838 nav: Skip redirect to Dashboard from logo link Added homeurl ($PAGE->navigation->action) to config helpers added to mustache templates. Changed boost and classic themes to use config.homeurl on the brand logo link. Updated global_navigation class to set properties to correct values when get_home_page() returns HOMEPAGE_MYCOURSES. --- lib/navigationlib.php | 16 +++++++++++++--- lib/outputrequirementslib.php | 1 + theme/boost/templates/navbar.mustache | 5 +++-- theme/classic/templates/navbar.mustache | 5 +++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index cfeec7013a9..641b5839242 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -1254,8 +1254,9 @@ class global_navigation extends navigation_node { return; } - if (get_home_page() == HOMEPAGE_SITE) { - // We are using the site home for the root element + $homepage = get_home_page(); + if ($homepage == HOMEPAGE_SITE) { + // We are using the site home for the root element. $properties = array( 'key' => 'home', 'type' => navigation_node::TYPE_SYSTEM, @@ -1263,8 +1264,17 @@ class global_navigation extends navigation_node { 'action' => new moodle_url('/'), 'icon' => new pix_icon('i/home', '') ); + } else if ($homepage == HOMEPAGE_MYCOURSES) { + // We are using the user's course summary page for the root element. + $properties = array( + 'key' => 'mycourses', + 'type' => navigation_node::TYPE_SYSTEM, + 'text' => get_string('mycourses'), + 'action' => new moodle_url('/my/courses.php'), + 'icon' => new pix_icon('i/course', '') + ); } else { - // We are using the users my moodle for the root element + // We are using the users my moodle for the root element. $properties = array( 'key' => 'myhome', 'type' => navigation_node::TYPE_SYSTEM, diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index 8341b9a9882..b9a835cd861 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -324,6 +324,7 @@ class page_requirements_manager { $this->M_cfg = array( 'wwwroot' => $CFG->wwwroot, + 'homeurl' => $page->navigation->action, 'sesskey' => sesskey(), 'sessiontimeout' => $CFG->sessiontimeout, 'sessiontimeoutwarning' => $CFG->sessiontimeoutwarning, diff --git a/theme/boost/templates/navbar.mustache b/theme/boost/templates/navbar.mustache index 46eed9ca5ef..4b779a1a080 100644 --- a/theme/boost/templates/navbar.mustache +++ b/theme/boost/templates/navbar.mustache @@ -32,7 +32,8 @@ "user_menu": "" }, "config": { - "wwwroot": "#" + "wwwroot": "#", + "homeurl": "/my/" }, "sitename": "Moodle Site", "mobileprimarynav": [ @@ -61,7 +62,7 @@ {{#str}}sidepanel, core{{/str}} - + {{# output.should_display_navbar_logo }} diff --git a/theme/classic/templates/navbar.mustache b/theme/classic/templates/navbar.mustache index a7bf5a97d42..31a8415bbff 100644 --- a/theme/classic/templates/navbar.mustache +++ b/theme/classic/templates/navbar.mustache @@ -31,14 +31,15 @@ "user_menu": "" }, "config": { - "wwwroot": "#" + "wwwroot": "#", + "homeurl": "/my/" }, "sitename": "Moodle Site" } }}