From 2255c598a5e3cf7f3fd4d94beacaa55e48c6433d Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Thu, 7 Apr 2022 13:50:38 +0100 Subject: [PATCH] MDL-74436 calendar: validate course/category field during import. --- calendar/classes/local/event/forms/managesubscriptions.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/calendar/classes/local/event/forms/managesubscriptions.php b/calendar/classes/local/event/forms/managesubscriptions.php index c6f20f45b25..5011f59e30d 100644 --- a/calendar/classes/local/event/forms/managesubscriptions.php +++ b/calendar/classes/local/event/forms/managesubscriptions.php @@ -140,6 +140,13 @@ class managesubscriptions extends \moodleform { $errors['url'] = get_string('errorrequiredurlorfile', 'calendar'); } + // Validate course/category event types (ensure appropriate field is also filled in). + if ($eventtype === 'course' && empty($data['courseid'])) { + $errors['courseid'] = get_string('selectacourse'); + } else if ($eventtype === 'category' && empty($data['categoryid'])) { + $errors['categoryid'] = get_string('required'); + } + return $errors; }