diff --git a/public/admin/tool/mobile/classes/api.php b/public/admin/tool/mobile/classes/api.php index 801f76fe157..5f380d67251 100644 --- a/public/admin/tool/mobile/classes/api.php +++ b/public/admin/tool/mobile/classes/api.php @@ -379,6 +379,7 @@ class api { } if (empty($section) || $section === 'navigation') { + $settings->enablemyhome = $CFG->enablemyhome ?? 1; $settings->enabledashboard = $CFG->enabledashboard; } diff --git a/public/admin/tool/mobile/tests/externallib_test.php b/public/admin/tool/mobile/tests/externallib_test.php index 483aeb23671..4fa10388b05 100644 --- a/public/admin/tool/mobile/tests/externallib_test.php +++ b/public/admin/tool/mobile/tests/externallib_test.php @@ -242,6 +242,7 @@ final class externallib_test extends \core_external\tests\externallib_testcase { $expected[] = ['name' => 'coursegraceperiodafter', 'value' => $CFG->coursegraceperiodafter]; $expected[] = ['name' => 'coursegraceperiodbefore', 'value' => $CFG->coursegraceperiodbefore]; + $expected[] = ['name' => 'enablemyhome', 'value' => $CFG->enablemyhome ?? 1]; $expected[] = ['name' => 'enabledashboard', 'value' => $CFG->enabledashboard]; $expected[] = ['name' => 'customusermenuitems', 'value' => $CFG->customusermenuitems]; $expected[] = ['name' => 'timezone', 'value' => $CFG->timezone]; diff --git a/public/course/externallib.php b/public/course/externallib.php index d027ff41de1..46d445f3bfe 100644 --- a/public/course/externallib.php +++ b/public/course/externallib.php @@ -144,6 +144,11 @@ class core_course_external extends external_api { //retrieve the course $course = $DB->get_record('course', array('id' => $params['courseid']), '*', MUST_EXIST); + // Accessing the site home via the web service is not allowed when it is disabled. + if ($course->id == SITEID && empty($CFG->enablemyhome)) { + throw new moodle_exception('error:sitehomeisdisabled', 'course'); + } + // now security checks $context = context_course::instance($course->id, IGNORE_MISSING); try { diff --git a/public/lang/en/course.php b/public/lang/en/course.php index a9b058fe404..4b5c2a9b872 100644 --- a/public/lang/en/course.php +++ b/public/lang/en/course.php @@ -95,6 +95,7 @@ $string['downloadcontent_help'] = 'Should this activity or resource be included The setting has no effect on mobile app content download for offline usage.'; $string['enabledownloadcoursecontent'] = 'Enable download course content'; +$string['error:sitehomeisdisabled'] = 'The Site Home has been disabled by an administrator.'; $string['errorendbeforestart'] = 'The end date ({$a}) is before the course start date.'; $string['favourite'] = 'Starred course'; $string['filterbothactive'] = 'First ({$a->first}) Last ({$a->last})';