From 3828422d82941caaf5be673dcd6283595e32406b Mon Sep 17 00:00:00 2001 From: Mathew May Date: Wed, 20 Feb 2019 08:38:06 +0800 Subject: [PATCH] MDL-60339 course: Course editing only checked against site:manageblocks. Add in additional capabilities to the page. When all_editing_caps is called it'll check against moodle/site:manageblocks & added capabilities. If moodle/site:manageblocks was not set the user would have trouble editing the page. --- course/externallib.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/course/externallib.php b/course/externallib.php index 3e8744cc99d..a4d322c82e3 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -3539,6 +3539,17 @@ class core_course_external extends external_api { $id = $params['id']; $sectionreturn = $params['sectionreturn']; + // Set of permissions an editing user may have. + $contextarray = [ + 'moodle/course:update', + 'moodle/course:manageactivities', + 'moodle/course:activityvisibility', + 'moodle/course:sectionvisibility', + 'moodle/course:movesections', + 'moodle/course:setcurrentsection', + ]; + $PAGE->set_other_editing_capability($contextarray); + list($course, $cm) = get_course_and_cm_from_cmid($id); $modcontext = context_module::instance($cm->id); $coursecontext = context_course::instance($course->id); @@ -3646,6 +3657,17 @@ class core_course_external extends external_api { $id = $params['id']; $sectionreturn = $params['sectionreturn']; + // Set of permissions an editing user may have. + $contextarray = [ + 'moodle/course:update', + 'moodle/course:manageactivities', + 'moodle/course:activityvisibility', + 'moodle/course:sectionvisibility', + 'moodle/course:movesections', + 'moodle/course:setcurrentsection', + ]; + $PAGE->set_other_editing_capability($contextarray); + // Validate access to the course (note, this is html for the course view page, we don't validate access to the module). list($course, $cm) = get_course_and_cm_from_cmid($id); self::validate_context(context_course::instance($course->id));