From d3b257c72e35b7370968d38063ad50328485c57f Mon Sep 17 00:00:00 2001 From: Rusty Braze <180222500+RustyBraze@users.noreply.github.com> Date: Sat, 7 Sep 2024 22:18:11 +0200 Subject: [PATCH] Bugfix #34 - Closes issue #34 - Add an option to return to the previous page - in case of issues, server root --- resources/views/admin/user/edit-goodie.twig | 2 +- src/Controllers/Admin/UserGoodieController.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/views/admin/user/edit-goodie.twig b/resources/views/admin/user/edit-goodie.twig index ec6891331..44f806f56 100644 --- a/resources/views/admin/user/edit-goodie.twig +++ b/resources/views/admin/user/edit-goodie.twig @@ -9,7 +9,7 @@ {% block content %}

- {{ m.back(url('/admin-active')) }} + {{ m.back(url(previousUrl)) }} {{ block('title') }}: {{ m.user(userdata) }}

diff --git a/src/Controllers/Admin/UserGoodieController.php b/src/Controllers/Admin/UserGoodieController.php index 38166fb33..7f29fd14f 100644 --- a/src/Controllers/Admin/UserGoodieController.php +++ b/src/Controllers/Admin/UserGoodieController.php @@ -50,11 +50,15 @@ public function editGoodie(Request $request): Response $user = $this->user->findOrFail($userId); + // Get the previous page URL (referrer) + $previousUrl = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/'; + return $this->response->withView( 'admin/user/edit-goodie.twig', [ 'userdata' => $user, 'is_tshirt' => $this->config->get('goodie_type') === GoodieType::Tshirt->value, + 'previousUrl' => $previousUrl ] ); }