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

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

Closes #3771

Merge request studip/studip!3180
parent a93297b7
No related branches found
No related tags found
No related merge requests found
...@@ -394,24 +394,27 @@ class Consultation_AdminController extends ConsultationController ...@@ -394,24 +394,27 @@ class Consultation_AdminController extends ConsultationController
'sem_perm' => $permissions, 'sem_perm' => $permissions,
]); ]);
} }
}
if (Request::isPost()) { public function store_booking_action($block_id, $slot_id, $page = 0): void
CSRFProtection::verifyUnsafeRequest(); {
CSRFProtection::verifyUnsafeRequest();
if ($this->slot->isOccupied()) { $slot = $this->loadSlot($block_id, $slot_id);
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();
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) public function edit_action($block_id, $page = 0)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @var int $page * @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() ?> <?= CSRFProtection::tokenTag() ?>
<fieldset> <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