Skip to content
Snippets Groups Projects
Commit cc942a29 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Jan-Hendrik Willms
Browse files

split display and booking action into two separate actions, fixes #3771

Closes #3771

Merge request studip/studip!3180
parent ef95178f
No related branches found
No related tags found
No related merge requests found
......@@ -356,24 +356,27 @@ class Consultation_AdminController extends ConsultationController
'sem_perm' => $permissions,
]);
}
}
if (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();
public function store_booking_action($block_id, $slot_id, $page = 0): void
{
CSRFProtection::verifyUnsafeRequest();
if ($this->slot->isOccupied()) {
PageLayout::postError(_('Dieser Termin ist bereits belegt.'));
} else {
$booking = new ConsultationBooking();
$booking->slot_id = $this->slot->id;
$booking->user_id = Request::option('user_id');
$booking->reason = trim(Request::get('reason'));
$booking->store();
$slot = $this->loadSlot($block_id, $slot_id);
PageLayout::postSuccess(_('Der Termin wurde reserviert.'));
}
if ($slot->isOccupied()) {
PageLayout::postError(_('Dieser Termin ist bereits belegt.'));
} else {
$booking = new ConsultationBooking();
$booking->slot_id = $slot->id;
$booking->user_id = Request::option('user_id');
$booking->reason = trim(Request::get('reason'));
$booking->store();
$this->redirect("consultation/admin/index/{$page}#slot-{$this->slot->id}");
PageLayout::postSuccess(_('Der Termin wurde reserviert.'));
}
$this->redirect("consultation/admin/index/{$page}#slot-{$slot->id}");
}
public function edit_action($block_id, $page = 0)
......
......@@ -5,7 +5,7 @@
* @var int $page
*/
?>
<form action="<?= $controller->book($slot->block, $slot, $page) ?>" method="post" class="default">
<form action="<?= $controller->store_booking($slot->block, $slot, $page) ?>" method="post" class="default">
<?= CSRFProtection::tokenTag() ?>
<fieldset>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment