From 01454544896827113e49db0d2848b5aab6ce14ae Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Wed, 18 Sep 2024 23:05:35 +0200 Subject: Many changes --- src/application/messages/de.msg | 15 +++++++++ .../mystic/forum/utils/RequestUtils.php | 24 ++++++++++----- src/application/views/form_addpost.php | 3 +- src/application/views/form_login.php | 5 +-- src/application/views/form_newtopic.php | 3 +- src/application/views/form_register.php | 7 +++-- src/application/views/form_search.php | 6 ++-- src/application/views/nav_logged_in.php | 2 +- src/application/views/template_end.php | 8 ++++- src/application/views/template_navigation.php | 5 ++- .../views/template_navigation_start.php | 5 ++- src/application/views/view_post.php | 8 ++--- src/application/views/view_search_results.php | 2 +- src/application/views/view_user.php | 36 +++++++++++++++++++--- 14 files changed, 99 insertions(+), 30 deletions(-) (limited to 'src/application') diff --git a/src/application/messages/de.msg b/src/application/messages/de.msg index 784c257..3a334a9 100644 --- a/src/application/messages/de.msg +++ b/src/application/messages/de.msg @@ -254,6 +254,9 @@ metadata({ : "posted on %post_date% in %topic%" = "veröffentlicht am %post_date% in %topic%" +: "posted by %author% on %post_date% in %topic%" += "veröffentlicht von %author% am %post_date% in %topic%" + : "Show all posts" = "Alle Beiträge anzeigen" @@ -338,3 +341,15 @@ metadata({ : "%result_count% result(s) in %search_duration% second(s)" = "%result_count% Treffer in %search_duration% Sekunde(n)" + +: "Change password" += "Passwort ändern" + +: "Current password:" += "Aktuelles Passwort:" + +: "New password:" += "Neues Passwort:" + +: "Retype password:" += "Passwort wiederholen:" diff --git a/src/application/mystic/forum/utils/RequestUtils.php b/src/application/mystic/forum/utils/RequestUtils.php index 6599052..796a476 100644 --- a/src/application/mystic/forum/utils/RequestUtils.php +++ b/src/application/mystic/forum/utils/RequestUtils.php @@ -10,6 +10,8 @@ use mystic\forum\orm\User; final class RequestUtils { use StaticClass; + private static ?string $formErrorDestination = null; + public static function getRequestMethod(): string { return strtoupper($_SERVER["REQUEST_METHOD"] ?? "GET"); } @@ -27,12 +29,12 @@ final class RequestUtils { } } - public static function getRequiredField(string $field): string { + public static function getRequiredField(string $field, string $formId): string { $fieldValue = $_POST[$field] ?? null; if ($fieldValue === null) { //http_response_code(400); //Messaging::error("Missing required field $field"); - RequestUtils::triggerFormError("Missing required field '$field'"); + RequestUtils::triggerFormError("Missing required field '$field'", $formId); //exit; } return $fieldValue; @@ -43,18 +45,24 @@ final class RequestUtils { $_SESSION["lastForm_uri"] = $_SERVER["REQUEST_URI"]; } - public static function triggerFormError(string $message, ?string $next = null): never { - $next ??= $_SERVER["REQUEST_URI"]; - $_SESSION["formError"] = $message; + public static function setFormErrorDestination(?string $dest): ?string { + $prev = self::$formErrorDestination; + self::$formErrorDestination = $dest; + return $prev; + } + + public static function triggerFormError(string $message, string $formId, ?string $next = null): never { + $next ??= self::$formErrorDestination ?? $_SERVER["REQUEST_URI"]; + $_SESSION["formError/$formId"] = $message; // store last form submission self::storeForm(); header("Location: $next"); exit; } - public static function getAndClearFormError(): ?string { - $err = $_SESSION["formError"] ?? null; - unset($_SESSION["formError"]); + public static function getAndClearFormError(string $formId): ?string { + $err = $_SESSION["formError/$formId"] ?? null; + unset($_SESSION["formError/$formId"]); return $err; } diff --git a/src/application/views/form_addpost.php b/src/application/views/form_addpost.php index 33b7281..2de44c5 100644 --- a/src/application/views/form_addpost.php +++ b/src/application/views/form_addpost.php @@ -10,11 +10,12 @@ RequestUtils::clearLastForm(); ?>