From 5ecce533f5cacd9cc5a3123351691de196e756ec Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Thu, 15 Sep 2016 15:06:53 +0800 Subject: [PATCH] MDL-55876 core_course: prevent changes on front page course --- course/lib.php | 5 +++++ course/tests/courselib_test.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/course/lib.php b/course/lib.php index a8ac69b2645..a1351e7b9a0 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2776,6 +2776,11 @@ function update_course($data, $editoroptions = NULL) { $data->timemodified = time(); + // Prevent changes on front page course. + if ($data->id == SITEID) { + throw new moodle_exception('invalidcourse', 'error'); + } + $oldcourse = course_get_format($data->id)->get_course(); $context = context_course::instance($oldcourse->id); diff --git a/course/tests/courselib_test.php b/course/tests/courselib_test.php index f0d4869de70..a4ff880722b 100644 --- a/course/tests/courselib_test.php +++ b/course/tests/courselib_test.php @@ -2913,4 +2913,16 @@ class core_course_courselib_testcase extends advanced_testcase { $this->assertNotEmpty($res->prevpageurl); $this->assertEmpty($res->nextpageurl); } + + /** + * Test test_update_course_frontpage_category. + */ + public function test_update_course_frontpage_category() { + // Fetch front page course. + $course = get_course(SITEID); + // Test update information on front page course. + $course->category = 99; + $this->setExpectedException('moodle_exception'); + update_course($course); + } }