From af42c386495fa8ecbdb33cca2a6d9de561106c16 Mon Sep 17 00:00:00 2001
From: David Siegfried <david.siegfried@uni-vechta.de>
Date: Fri, 16 Dec 2022 11:35:33 +0000
Subject: [PATCH] redirect on error, closes #1773

Closes #1773

Merge request studip/studip!1252
---
 app/controllers/resources/export.php             | 2 ++
 app/views/resources/export/resource_bookings.php | 4 ++--
 app/views/resources/resource/export_bookings.php | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/app/controllers/resources/export.php b/app/controllers/resources/export.php
index f0d5905a55e..9d0fec7b559 100644
--- a/app/controllers/resources/export.php
+++ b/app/controllers/resources/export.php
@@ -273,12 +273,14 @@ class Resources_ExportController extends AuthenticatedController
             PageLayout::postError(
                 _('Der Startzeitpunkt darf nicht hinter dem Endzeitpunkt liegen!')
             );
+            $this->redirect(Request::get('from'));
             return;
         }
         if (!$this->weekdays) {
             PageLayout::postError(
                 _('Bitte mindestens einen Wochentag auswählen.')
             );
+            $this->redirect(Request::get('from'));
             return;
         }
 
diff --git a/app/views/resources/export/resource_bookings.php b/app/views/resources/export/resource_bookings.php
index 144159067a6..67840da18fd 100644
--- a/app/views/resources/export/resource_bookings.php
+++ b/app/views/resources/export/resource_bookings.php
@@ -1,6 +1,6 @@
 <? if ($resource): ?>
-    <form class="default" method="post"
-          action="<?= $controller->link_for('resources/export/bookings')?>">
+    <form class="default" method="post" action="<?= $controller->link_for('resources/export/bookings')?>">
+        <input type="hidden" name="from" value="<?= $controller->resource_bookings($resource->id)?>">
         <?= CSRFProtection::tokenTag() ?>
         <? if ($resource instanceof Room): ?>
             <input type="hidden" name="selected_rooms[]"
diff --git a/app/views/resources/resource/export_bookings.php b/app/views/resources/resource/export_bookings.php
index b9fdf435770..641838197ee 100644
--- a/app/views/resources/resource/export_bookings.php
+++ b/app/views/resources/resource/export_bookings.php
@@ -1,6 +1,6 @@
 <? if ($resource): ?>
-    <form class="default" method="post"
-          action="<?= $controller->link_for('resources/export/bookings')?>">
+    <form class="default" method="post" action="<?= $controller->link_for('resources/export/bookings')?>">
+        <input type="hidden" name="from" value="<?= $controller->export_bookings($resource->id)?>">
         <?= CSRFProtection::tokenTag() ?>
         <? if ($resource instanceof Room): ?>
             <input type="hidden" name="selected_rooms[]"
-- 
GitLab