From fe0f414dc0211a4014581dc03fcfd514ed7ed02d Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Thu, 17 Oct 2024 10:56:01 +0200 Subject: Transition templating to Twig --- src/application/mystic/forum/utils/RequestUtils.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/application/mystic/forum') diff --git a/src/application/mystic/forum/utils/RequestUtils.php b/src/application/mystic/forum/utils/RequestUtils.php index 5c6a485..11253aa 100644 --- a/src/application/mystic/forum/utils/RequestUtils.php +++ b/src/application/mystic/forum/utils/RequestUtils.php @@ -40,9 +40,10 @@ final class RequestUtils { return $fieldValue; } - public static function storeForm(): void { + public static function storeForm(string $formId): void { $_SESSION["lastForm"] = $_POST ?? []; $_SESSION["lastForm_uri"] = $_SERVER["REQUEST_URI"]; + $_SESSION["lastForm_id"] = $formId; } public static function setFormErrorDestination(?string $dest): ?string { @@ -55,7 +56,7 @@ final class RequestUtils { $next ??= self::$formErrorDestination ?? $_SERVER["REQUEST_URI"]; $_SESSION["formError/$formId"] = $message; // store last form submission - self::storeForm(); + self::storeForm($formId); header("Location: $next"); exit; } @@ -66,14 +67,20 @@ final class RequestUtils { return $err; } - public static function getLastForm(string &$lastFormUri): ?array { + public static function getLastForm_legacy(string &$lastFormUri): ?array { $lastFormUri = $_SESSION["lastForm_uri"] ?? ""; return $_SESSION["lastForm"] ?? null; } + public static function getLastForm(string &$lastFormId): ?array { + $lastFormId = $_SESSION["lastForm_id"] ?? ""; + return $_SESSION["lastForm"] ?? null; + } + public static function clearLastForm(): void { unset($_SESSION["lastForm"]); unset($_SESSION["lastForm_uri"]); + unset($_SESSION["lastForm_id"]); } public static function getAuthorizedUser(Database &$db): ?User { -- cgit v1.2.3