mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
MDL-73233 admin: Add enabledashboard setting
The $CFG->enabledashboard setting has been added to Appearance > Navigation, to let admins disable the "Dashboard" option from the primary navigation. This commit also changes the behaviour of get_home_page(), to take into account this setting and adds a new method, get_default_home_page(), to return the expected default home page (that wil be used when current default page is not defined or valid).
This commit is contained in:
parent
9344149aba
commit
5349861e69
6 changed files with 196 additions and 14 deletions
|
@ -10367,17 +10367,40 @@ function get_home_page() {
|
|||
global $CFG;
|
||||
|
||||
if (isloggedin() && !isguestuser() && !empty($CFG->defaulthomepage)) {
|
||||
// If dashboard is disabled, home will be set to default page.
|
||||
$defaultpage = get_default_home_page();
|
||||
if ($CFG->defaulthomepage == HOMEPAGE_MY) {
|
||||
return HOMEPAGE_MY;
|
||||
if (!empty($CFG->enabledashboard)) {
|
||||
return HOMEPAGE_MY;
|
||||
} else {
|
||||
return $defaultpage;
|
||||
}
|
||||
} else if ($CFG->defaulthomepage == HOMEPAGE_MYCOURSES) {
|
||||
return HOMEPAGE_MYCOURSES;
|
||||
} else {
|
||||
return (int)get_user_preferences('user_home_page_preference', HOMEPAGE_MY);
|
||||
$userhomepage = (int) get_user_preferences('user_home_page_preference', $defaultpage);
|
||||
if (empty($CFG->enabledashboard) && $userhomepage == HOMEPAGE_MY) {
|
||||
// If the user was using the dashboard but it's disabled, return the default home page.
|
||||
$userhomepage = $defaultpage;
|
||||
}
|
||||
return $userhomepage;
|
||||
}
|
||||
}
|
||||
return HOMEPAGE_SITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default home page to display if current one is not defined or can't be applied.
|
||||
* The default behaviour is to return Dashboard if it's enabled or My courses page if it isn't.
|
||||
*
|
||||
* @return int The default home page.
|
||||
*/
|
||||
function get_default_home_page(): int {
|
||||
global $CFG;
|
||||
|
||||
return !empty($CFG->enabledashboard) ? HOMEPAGE_MY : HOMEPAGE_MYCOURSES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of a course to be displayed when showing a list of courses.
|
||||
* By default this is just $course->fullname but user can configure it. The
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue