From 1ce2bb00074b8a5017b450c5e932a68bd9b91b18 Mon Sep 17 00:00:00 2001 From: Mathew May Date: Mon, 9 Aug 2021 15:20:48 +0800 Subject: [PATCH] MDL-69588 navigation: Show home primary node when required --- lib/classes/navigation/views/primary.php | 4 +++- lib/tests/navigation/views/primary_test.php | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/classes/navigation/views/primary.php b/lib/classes/navigation/views/primary.php index 67f45c7ebe6..c30b6780da1 100644 --- a/lib/classes/navigation/views/primary.php +++ b/lib/classes/navigation/views/primary.php @@ -35,8 +35,10 @@ class primary extends view { return; } $this->id = 'primary_navigation'; - $this->add(get_string('home'), new \moodle_url('/'), self::TYPE_SYSTEM, + if (get_home_page() == HOMEPAGE_SITE && isloggedin() && !isguestuser()) { + $this->add(get_string('home'), new \moodle_url('/'), self::TYPE_SYSTEM, null, 'home', new \pix_icon('i/home', '')); + } // Add the dashboard link. if (isloggedin() && !isguestuser()) { // Makes no sense if you aren't logged in. diff --git a/lib/tests/navigation/views/primary_test.php b/lib/tests/navigation/views/primary_test.php index 41f8e9efa9d..2da990d8afa 100644 --- a/lib/tests/navigation/views/primary_test.php +++ b/lib/tests/navigation/views/primary_test.php @@ -58,9 +58,9 @@ class primary_test extends \advanced_testcase { */ public function test_setting_initialise_provider() { return [ - 'Testing as a guest user' => ['guest', ['home', 'courses']], - 'Testing as an admin' => ['admin', ['home', 'myhome', 'courses', 'siteadminnode']], - 'Testing as a regular user' => ['user', ['home', 'myhome', 'courses']] + 'Testing as a guest user' => ['guest', ['courses']], + 'Testing as an admin' => ['admin', ['myhome', 'courses', 'siteadminnode']], + 'Testing as a regular user' => ['user', ['myhome', 'courses']] ]; } }