Skip to content

Commit

Permalink
Fix #737 use correct capability check when custom field locked.
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden committed Mar 19, 2024
1 parent 5409156 commit c86fd84
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion classes/customfield/session_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ public function can_configure() : bool {
* @return bool true if the current can edit custom fields, false otherwise
*/
public function can_edit(field_controller $field, int $instanceid = 0) : bool {
global $PAGE;
if ($instanceid) {
$context = $this->get_instance_context($instanceid);
return (!$field->get_configdata_property('locked') ||
has_capability('moodle/course:changelockedcustomfields', $context));
} else {
$context = \context_system::instance();
$context = $PAGE->context->get_course_context();
return (!$field->get_configdata_property('locked') ||
guess_if_creator_will_have_course_capability('moodle/course:changelockedcustomfields', $context));
}
Expand Down

0 comments on commit c86fd84

Please sign in to comment.