MDL-81247 calendar: freeze event type if "user" only allowed.

This commit is contained in:
Paul Holden 2024-03-17 21:10:50 +00:00 committed by Jenkins
parent cd85e090f3
commit 53e8a62003
2 changed files with 3 additions and 2 deletions

View File

@ -78,7 +78,8 @@ trait eventtype {
if (!empty($eventtypes['user']) && count($options) == 1) {
$mform->addElement('hidden', 'eventtype');
$mform->setType('eventtype', PARAM_TEXT);
$mform->setDefault('eventtype', 'user');
$mform->hardFreeze('eventtype');
$mform->setConstant('eventtype', 'user');
return;
} else {
$mform->addElement('select', 'eventtype', get_string('eventkind', 'calendar'), $options);

View File

@ -106,7 +106,7 @@ class managesubscriptions extends \moodleform {
$courseid = (!empty($data[$coursekey])) ? $data[$coursekey] : null;
$eventtypes = calendar_get_allowed_event_types($courseid);
if (empty($eventtype) || !isset($eventtypes[$eventtype])) {
if (empty($eventtype) || !isset($eventtypes[$eventtype]) || $eventtypes[$eventtype] == false) {
$errors['eventtype'] = get_string('invalideventtype', 'calendar');
}