MDL-73233 user: Review Start page user preferences

The "Start page" user preferences page has been reviewed to
consider the new $CFG->enabledashboard setting.
The "Dashboard" won't be displayed in the list if it's disabled.
Besides, the default value is now calculated calling the new
get_default_home_page() method.
This commit is contained in:
Sara Arjona
2022-03-16 11:22:22 +01:00
parent 5349861e69
commit e3d2fa41d0
6 changed files with 51 additions and 11 deletions
+14 -3
View File
@@ -933,6 +933,8 @@ class core_user {
* @return void
*/
protected static function fill_preferences_cache() {
global $CFG;
if (self::$preferencescache !== null) {
return;
}
@@ -966,13 +968,22 @@ class core_user {
global $USER;
return $USER->id == $user->id && has_capability('moodle/blog:view', context_system::instance());
});
$preferences['user_home_page_preference'] = array('type' => PARAM_INT, 'null' => NULL_ALLOWED, 'default' => HOMEPAGE_MY,
'choices' => array(HOMEPAGE_SITE, HOMEPAGE_MY, HOMEPAGE_MYCOURSES),
$choices = [HOMEPAGE_SITE];
if (!empty($CFG->enabledashboard)) {
$choices[] = HOMEPAGE_MY;
}
$choices[] = HOMEPAGE_MYCOURSES;
$preferences['user_home_page_preference'] = [
'type' => PARAM_INT,
'null' => NULL_ALLOWED,
'default' => get_default_home_page(),
'choices' => $choices,
'permissioncallback' => function ($user, $preferencename) {
global $CFG;
return (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_USER));
}
);
];
// Core components that may want to define their preferences.
// List of core components implementing callback is hardcoded here for performance reasons.