MDL-70261 course: Allow update locked course custom fields
authorIlya Tregubov <ilya@moodle.com>
Mon, 23 Nov 2020 07:59:13 +0000 (09:59 +0200)
committerIlya Tregubov <ilya@moodle.com>
Tue, 15 Dec 2020 12:43:11 +0000 (14:43 +0200)
                  on course upload.

course/classes/customfield/course_handler.php

index dede44d..c30da88 100644 (file)
@@ -102,8 +102,13 @@ class course_handler extends \core_customfield\handler {
                     has_capability('moodle/course:changelockedcustomfields', $context));
         } else {
             $context = $this->get_parent_context();
-            return (!$field->get_configdata_property('locked') ||
-                guess_if_creator_will_have_course_capability('moodle/course:changelockedcustomfields', $context));
+            if ($context->contextlevel == CONTEXT_SYSTEM) {
+                return (!$field->get_configdata_property('locked') ||
+                    has_capability('moodle/course:changelockedcustomfields', $context));
+            } else {
+                return (!$field->get_configdata_property('locked') ||
+                    guess_if_creator_will_have_course_capability('moodle/course:changelockedcustomfields', $context));
+            }
         }
     }