diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-06-25 12:35:18 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-06-25 12:35:18 +0000 |
| commit | 8fef8bc3c46650f9bdcb9beffeafdd01ef8fe76f (patch) | |
| tree | d4364579b95152b9ad42278f01d24d343506e41c /app/controllers/consultation | |
| parent | a629426a92c0907821ffd20ad991b23c87bc3d66 (diff) | |
fixes #4320, fixes #1871
Closes #4320 and #1871
Merge request studip/studip!3125
Diffstat (limited to 'app/controllers/consultation')
| -rw-r--r-- | app/controllers/consultation/admin.php | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/app/controllers/consultation/admin.php b/app/controllers/consultation/admin.php index 8ee7575..13451d2 100644 --- a/app/controllers/consultation/admin.php +++ b/app/controllers/consultation/admin.php @@ -165,13 +165,19 @@ class Consultation_AdminController extends ConsultationController CSRFProtection::verifyUnsafeRequest(); try { + $interval = Request::int('interval'); $start = $this->getDateAndTime('start'); - $end = $this->getDateAndTime('end'); + $end = $this->getDateAndTime($interval === 0 ? 'start' : 'end', 'end'); if (date('Hi', $end) <= date('Hi', $start)) { throw new InvalidArgumentException(_('Die Endzeit liegt vor der Startzeit!')); } + $dow = Request::int('day-of-week'); + if ($interval === 0) { + $dow = date('w', $start); + } + // Determine duration of a slot and pause times $duration = Request::int('duration'); $pause_time = Request::bool('pause') ? Request::int('pause_time') : null; @@ -187,8 +193,8 @@ class Consultation_AdminController extends ConsultationController $slot_count = ConsultationBlock::countSlots( $start, $end, - Request::int('day-of-week'), - Request::int('interval'), + $dow, + $interval, $duration, $pause_time, $pause_duration @@ -202,8 +208,8 @@ class Consultation_AdminController extends ConsultationController $this->range, $start, $end, - Request::int('day-of-week'), - Request::int('interval') + $dow, + $interval ); $stored = 0; @@ -872,15 +878,19 @@ class Consultation_AdminController extends ConsultationController } } - private function getDateAndTime($index) + private function getDateAndTime(string $index, string $index_time = null) { - if (!Request::submitted("{$index}-date") || !Request::submitted("{$index}-time")) { + if ($index_time === null) { + $index_time = $index; + } + + if (!Request::submitted("{$index}-date") || !Request::submitted("{$index_time}-time")) { throw new Exception("Date with index '{$index}' was not submitted properly"); } return strtotime(implode(' ', [ Request::get("{$index}-date"), - Request::get("{$index}-time") + Request::get("{$index_time}-time") ])); } |
