mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-72110 core_navigation: home page preference
Admin should respect the home page preference set just like any other user. Also when user preference is set to dashboard, the home points to the dashboard and the dashboard should become "Site home" which would point to Site home.
This commit is contained in:
parent
300d0bc03a
commit
16e939fe2c
4 changed files with 27 additions and 18 deletions
|
@ -35,15 +35,19 @@ class primary extends view {
|
|||
return;
|
||||
}
|
||||
$this->id = 'primary_navigation';
|
||||
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.
|
||||
$this->rootnodes['home'] = $this->add(get_string('myhome'), new \moodle_url('/my/'),
|
||||
self::TYPE_SETTING, null, 'myhome', new \pix_icon('i/dashboard', ''));
|
||||
if (isloggedin() && !isguestuser()) {
|
||||
$homepage = get_home_page();
|
||||
if ($homepage === HOMEPAGE_SITE) {
|
||||
$this->add(get_string('home'), new \moodle_url('/'), self::TYPE_SYSTEM,
|
||||
null, 'home', new \pix_icon('i/home', ''));
|
||||
$this->rootnodes['home'] = $this->add(get_string('myhome'), new \moodle_url('/my/'),
|
||||
self::TYPE_SETTING, null, 'myhome', new \pix_icon('i/dashboard', ''));
|
||||
} else if ($homepage === HOMEPAGE_MY) {
|
||||
$this->add(get_string('myhome'), new \moodle_url('/my/'), self::TYPE_SYSTEM,
|
||||
null, 'home', new \pix_icon('i/home', ''));
|
||||
$this->rootnodes['home'] = $this->add(get_string('sitehome'), new \moodle_url('/'),
|
||||
self::TYPE_SETTING, null, 'myhome', new \pix_icon('i/dashboard', ''));
|
||||
}
|
||||
}
|
||||
|
||||
// Add a dummy mycourse link to a mycourses page.
|
||||
|
|
|
@ -59,8 +59,8 @@ class primary_test extends \advanced_testcase {
|
|||
public function test_setting_initialise_provider() {
|
||||
return [
|
||||
'Testing as a guest user' => ['guest', ['courses']],
|
||||
'Testing as an admin' => ['admin', ['myhome', 'courses', 'siteadminnode']],
|
||||
'Testing as a regular user' => ['user', ['myhome', 'courses']]
|
||||
'Testing as an admin' => ['admin', ['home', 'myhome', 'courses', 'siteadminnode']],
|
||||
'Testing as a regular user' => ['user', ['home', 'myhome', 'courses']]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue