Skip to content
Snippets Groups Projects
Commit 76ed0b81 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

fix deletion of bookings, fixes #4566

Closes #4566

Merge request studip/studip!3475
parent 0ad1eca4
No related branches found
No related tags found
No related merge requests found
...@@ -1885,29 +1885,27 @@ class Resources_BookingController extends AuthenticatedController ...@@ -1885,29 +1885,27 @@ class Resources_BookingController extends AuthenticatedController
{ {
PageLayout::setTitle(_('Buchung löschen')); PageLayout::setTitle(_('Buchung löschen'));
if ($this->booking->isReadOnlyForUser($this->current_user)) { $booking = ResourceBooking::find($booking_id) ?? $this->booking;
if (!$booking) {
throw new InvalidArgumentException(_('Diese Buchung existiert nicht'));
}
if ($booking->isReadOnlyForUser($this->current_user)) {
//The user must not delete this booking! //The user must not delete this booking!
throw new AccessDeniedException(); throw new AccessDeniedException();
} }
$this->show_details = true; $this->show_details = !Request::submitted('hide_details');
if (Request::submitted('hide_details')) {
$this->show_details = false;
}
$this->show_question = true; $this->show_question = true;
if (Request::submitted('confirm')) { if (Request::submitted('confirm')) {
CSRFProtection::verifyUnsafeRequest(); CSRFProtection::verifyUnsafeRequest();
if ($this->booking->delete()) { if ($booking->delete()) {
$this->show_question = false; $this->show_question = false;
PageLayout::postSuccess( PageLayout::postSuccess(_('Die Buchung wurde gelöscht!'));
_('Die Buchung wurde gelöscht!')
);
} else { } else {
PageLayout::postError( PageLayout::postError(_('Fehler beim Löschen der Buchung!'));
_('Fehler beim Löschen der Buchung!')
);
} }
} }
} }
......
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