Fix #314: Switch optional_param starttime to optional_param_array (#384)

* Fix #314: Switch optional_param starttime to optional_param_array

* convert default startime to timestamp

* fix error debug warning
This commit is contained in:
Guillaume
2025-12-03 16:40:42 +10:00
committed by GitHub
parent 329c635b3a
commit 845a370d6f

View File

@@ -48,7 +48,24 @@ if ($mform->is_cancelled()) {
$clone = optional_param('clone', 0, PARAM_INT);
$edit = optional_param('edit', 0, PARAM_INT);
$time = optional_param('starttime', 0, PARAM_INT);
if (array_key_exists('starttime', $_POST) && is_array($_POST['starttime'])) {
$start = optional_param_array('starttime', [], PARAM_INT);
} else {
$start = optional_param('starttime', 0, PARAM_INT);
}
if (!empty($start['year']) && !empty($start['month']) && !empty($start['day'])) {
$hour = $start['hour'] ?? 0;
$minute = $start['minute'] ?? 0;
$time = make_timestamp(
(int) $start['year'],
(int) $start['month'],
(int) $start['day'],
(int) $hour,
(int) $minute
);
} else {
$time = 0;
}
if ($clone && $edit) {
throw new invalid_parameter_exception('Cannot provide both clone and edit ids.');
}