MDL-73233 my: Disable /my page depending on setting

When $CFG->enabledashboard will be disabled, the /my page
will redirect to a different page or display an error message.
This commit is contained in:
Sara Arjona 2022-02-25 16:26:59 +01:00
parent c612f121a0
commit 31ed9a6c2f
2 changed files with 13 additions and 0 deletions

View File

@ -23,6 +23,7 @@
*/
$string['coursemanagementoptions'] = 'Course management options';
$string['error:dashboardisdisabled'] = 'The dashboard has been disabled by the administrator.';
$string['mymoodle'] = 'Dashboard';
$string['nocourses'] = 'No course information to show.';
$string['noguest'] = 'The Dashboard page is not available to guest users';

View File

@ -52,6 +52,18 @@ if ($hassiteconfig && moodle_needs_upgrading()) {
$strmymoodle = get_string('myhome');
if (empty($CFG->enabledashboard)) {
// Dashboard is disabled, so the /my page shouldn't be displayed.
$defaultpage = get_default_home_page();
if ($defaultpage == HOMEPAGE_MYCOURSES) {
// If default page is set to "My courses", redirect to it.
redirect(new moodle_url('/my/courses.php'));
} else {
// Otherwise, raise an exception to inform the dashboard is disabled.
throw new moodle_exception('error:dashboardisdisabled', 'my');
}
}
if (isguestuser()) { // Force them to see system default, no editing allowed
// If guests are not allowed my moodle, send them to front page.
if (empty($CFG->allowguestmymoodle)) {