Merge branch 'MDL-65019-master' of git://github.com/jleyva/moodle
[moodle.git] / course / externallib.php
index 83a789b..fb3481a 100644 (file)
@@ -328,7 +328,8 @@ class core_course_external extends external_api {
                                 foreach ($contents as $content) {
                                     // Check repository file (only main file).
                                     if (!isset($module['contentsinfo']['repositorytype'])) {
-                                        $module['contentsinfo']['repositorytype'] = isset($content['repositorytype']) ? $content['repositorytype'] : '';
+                                           $module['contentsinfo']['repositorytype'] =
+                                                   isset($content['repositorytype']) ? $content['repositorytype'] : '';
                                     }
                                     if (isset($content['filesize'])) {
                                         $module['contentsinfo']['filessize'] += $content['filesize'];
@@ -3545,6 +3546,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);
@@ -3652,6 +3664,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));