MDL-60339 course: Course editing only checked against site:manageblocks.
authorMathew May <mathewm@hotmail.co.nz>
Wed, 20 Feb 2019 00:38:06 +0000 (08:38 +0800)
committerMathew May <mathewm@hotmail.co.nz>
Fri, 22 Mar 2019 05:47:16 +0000 (13:47 +0800)
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

index 3e8744c..a4d322c 100644 (file)
@@ -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));