summaryrefslogtreecommitdiff
path: root/src/application
diff options
context:
space:
mode:
Diffstat (limited to 'src/application')
-rw-r--r--src/application/messages/de.msg15
-rw-r--r--src/application/mystic/forum/utils/RequestUtils.php24
-rw-r--r--src/application/views/form_addpost.php3
-rw-r--r--src/application/views/form_login.php5
-rw-r--r--src/application/views/form_newtopic.php3
-rw-r--r--src/application/views/form_register.php7
-rw-r--r--src/application/views/form_search.php6
-rw-r--r--src/application/views/nav_logged_in.php2
-rw-r--r--src/application/views/template_end.php8
-rw-r--r--src/application/views/template_navigation.php5
-rw-r--r--src/application/views/template_navigation_start.php5
-rw-r--r--src/application/views/view_post.php8
-rw-r--r--src/application/views/view_search_results.php2
-rw-r--r--src/application/views/view_user.php36
14 files changed, 99 insertions, 30 deletions
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();
?>
<h3 id="form"><?= __("Reply to this topic") ?></h3>
<?php
-if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
+if (($_formError = RequestUtils::getAndClearFormError("addpost")) !== null) {
_view("alert_error", ["message" => $_formError]);
}
?>
<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>#form" method="post" enctype="multipart/form-data">
+<input type="hidden" name="form_id" value="addpost">
<div class="form-group">
<label for="i_message"><?= __("Message:") ?></label>
<textarea class="form-control" id="i_message" name="message" required rows="12" cols="60" style="resize:vertical;max-height:499px"></textarea>
diff --git a/src/application/views/form_login.php b/src/application/views/form_login.php
index 1ae20a9..1c4a9ea 100644
--- a/src/application/views/form_login.php
+++ b/src/application/views/form_login.php
@@ -15,11 +15,12 @@ RequestUtils::clearLastForm();
<div class="col-md-4"></div>
<div class="well col-md-4">
<?php
-if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
+if (($_formError = RequestUtils::getAndClearFormError("login")) !== null) {
_view("alert_error", ["message" => $_formError]);
}
?>
<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post">
+<input type="hidden" name="form_id" value="login">
<div class="form-group">
<label for="i_username"><?= __("Username:") ?></label>
<input class="form-control" type="text" id="i_username" name="username" value="<?= htmlentities($lastForm["username"] ?? "") ?>" required autofocus>
@@ -31,7 +32,7 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
</div>
<div class="form-group">
- <button class="btn btn-default" type="submit"><?= __("Log in") ?></button>
+ <button class="btn btn-primary" type="submit"><?= __("Log in") ?></button>
</div>
<div class="form-group">
diff --git a/src/application/views/form_newtopic.php b/src/application/views/form_newtopic.php
index f701fbb..0850c84 100644
--- a/src/application/views/form_newtopic.php
+++ b/src/application/views/form_newtopic.php
@@ -13,11 +13,12 @@ RequestUtils::clearLastForm();
<h1><?= __("New topic") ?></h1>
</div>
<?php
-if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
+if (($_formError = RequestUtils::getAndClearFormError("newtopic")) !== null) {
_view("alert_error", ["message" => $_formError]);
}
?>
<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>#form" method="post" enctype="multipart/form-data">
+<input type="hidden" name="form_id" value="newtopic">
<div class="form-group">
<label for="i_message"><?= __("Topic title:") ?></label>
<input type="text" class="form-control" id="i_title" name="title" value="<?= htmlentities($lastForm["title"] ?? "") ?>" required autofocus>
diff --git a/src/application/views/form_register.php b/src/application/views/form_register.php
index a082611..23f470d 100644
--- a/src/application/views/form_register.php
+++ b/src/application/views/form_register.php
@@ -15,11 +15,12 @@ RequestUtils::clearLastForm();
<div class="col-md-4"></div>
<div class="well col-md-4">
<?php
-if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
+if (($_formError = RequestUtils::getAndClearFormError("register")) !== null) {
_view("alert_error", ["message" => $_formError]);
}
?>
<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post">
+<input type="hidden" name="form_id" value="register">
<div class="form-group" id="group0">
<label for="i_username"><?= __("Username:") ?></label>
<input class="form-control" id="i_username" type="text" name="username" value="" required>
@@ -27,7 +28,7 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
<div class="form-group" id="group1">
<label for="i_username"><?= __("Username:") ?></label>
- <input class="form-control" id="i_username" type="text" name="df82a9bc21" value="<?= htmlentities($lastForm["df82a9bc21"] ?? "") ?>" required>
+ <input class="form-control" id="i_username" type="text" name="df82a9bc21" value="<?= htmlentities($lastForm["df82a9bc21"] ?? "") ?>" required autofocus>
</div>
<div class="form-group" id="group2">
@@ -64,7 +65,7 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
</div>
<div class="form-group">
- <button class="btn btn-default" type="submit"><?= __("Register now") ?></button>
+ <button class="btn btn-primary" type="submit"><?= __("Register now") ?></button>
</div>
<div class="form-group">
diff --git a/src/application/views/form_search.php b/src/application/views/form_search.php
index edc68b8..ed3752f 100644
--- a/src/application/views/form_search.php
+++ b/src/application/views/form_search.php
@@ -12,11 +12,13 @@ RequestUtils::clearLastForm();
<h1><?= __("Search") ?></h1>
</div>
<?php
-if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
+if (($_formError = RequestUtils::getAndClearFormError("search")) !== null) {
_view("alert_error", ["message" => $_formError]);
}
?>
-<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post">
+<form action="." method="get">
+ <input type="hidden" name="form_id" value="search">
+ <input type="hidden" name="_action" value="search">
<div class="form-group">
<div class="input-group">
<input class="form-control" type="search" id="i_query" name="query" value="<?= htmlentities($lastForm["query"] ?? $query ?? "") ?>" required autofocus>
diff --git a/src/application/views/nav_logged_in.php b/src/application/views/nav_logged_in.php
index 0f77f90..c049ec5 100644
--- a/src/application/views/nav_logged_in.php
+++ b/src/application/views/nav_logged_in.php
@@ -7,6 +7,6 @@ use mystic\forum\orm\User;
]) ?>
</p></li>
<li<?= $GLOBALS["action"] === "search" ? ' class="active"' : '' ?>><a href="?_action=search"><span class="glyphicon glyphicon-search" aria-hidden="true"></span><span class="sr-only"><?= __("Search") ?></span></a></li>
-<li><a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($user->id)) ?>"><span class="glyphicon glyphicon-user" aria-hidden="true"></span><span class="sr-only">View profile</span></a></li>
+<li<?= ($isViewingOwnProfile ?? false) ? ' class="active"' : '' ?>><a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($user->id)) ?>"><span class="glyphicon glyphicon-user" aria-hidden="true"></span><span class="sr-only">View profile</span></a></li>
<li><a href="?_action=logout&amp;next=<?= htmlentities(urlencode($_SERVER["REQUEST_URI"])) ?>"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span><span class="sr-only">Log out</span></a></li>
</ul>
diff --git a/src/application/views/template_end.php b/src/application/views/template_end.php
index f322b36..9633782 100644
--- a/src/application/views/template_end.php
+++ b/src/application/views/template_end.php
@@ -76,11 +76,17 @@ $(function() {
$("input[type=file]").each(function(i, e) {
var isMultiple = !!$(e).prop("multiple");
+ var isSmall = !!$(e).hasClass("small");
var $input = $('<input type="text" readonly class="form-control" />').attr("placeholder", _messages.filesSelected[0]).css("text-overflow", "ellipsis");
+ var $btn = $('<button class="btn btn-default" type="button"></button>');
+ if (isSmall) {
+ $input.addClass("input-sm");
+ $btn.addClass("btn-sm");
+ }
$(e).after($('<div class="input-group file-input-group"></div>').append(
$input,
$('<span class="input-group-btn"></span>').append(
- $('<button class="btn btn-default" type="button"></button>').text(_messages.selectFiles[isMultiple ? 1 : 0]).click(function() {
+ $btn.text(_messages.selectFiles[isMultiple ? 1 : 0]).click(function() {
$(e).click();
})
)
diff --git a/src/application/views/template_navigation.php b/src/application/views/template_navigation.php
index d39c1ea..ff0752b 100644
--- a/src/application/views/template_navigation.php
+++ b/src/application/views/template_navigation.php
@@ -1,6 +1,9 @@
<?php
if ($user) {
- _view("nav_logged_in", ["user" => $user]);
+ _view("nav_logged_in", [
+ "user" => $user,
+ "isViewingOwnProfile" => $isViewingOwnProfile ?? false,
+ ]);
} else {
_view("nav_guest");
}
diff --git a/src/application/views/template_navigation_start.php b/src/application/views/template_navigation_start.php
index 3c69bf4..bd2b3a5 100644
--- a/src/application/views/template_navigation_start.php
+++ b/src/application/views/template_navigation_start.php
@@ -7,6 +7,9 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
- <a class="navbar-brand" href="."><?= htmlentities(env("MYSTIC_FORUM_TITLE") ?? "Forum") ?></a>
+ <a class="navbar-brand" href=".">
+ <span class="myb-icon mybblogo" aria-hidden="false"></span>
+ <?= htmlentities(env("MYSTIC_FORUM_TITLE") ?? "Forum") ?>
+ </a>
</div>
<div class="collapse navbar-collapse" id="nav-collapse">
diff --git a/src/application/views/view_post.php b/src/application/views/view_post.php
index 18be820..62b2d18 100644
--- a/src/application/views/view_post.php
+++ b/src/application/views/view_post.php
@@ -35,13 +35,13 @@ $is_op = $postAuthor?->id === $topicAuthor?->id && $postAuthor?->id !== null;
</div>
<div class="media-body">
<div class="well icon-well text-warning">
- <span class="glyphicon glyphicon-exclamation-sign color-warning" aria-hidden="true"></span>
+ <span class="glyphicon glyphicon-exclamation-sign text-warning" aria-hidden="true"></span>
<em><?= __("This post has been deleted") ?></em>
</div>
</div>
</div>
<?php else: ?>
-<div class="media" id="post-<?= htmlentities($post->id) ?>" data-text="<?= htmlentities($post->content) ?>">
+<div class="media" id="post-<?= htmlentities($post->id) ?>" data-text="<?= htmlentities($post->content) ?>" style="overflow: visible;">
<?php if (!$hide_pfp): ?>
<div class="media-left hidden-sm hidden-xs">
<?php if ($postAuthor): ?>
@@ -57,7 +57,7 @@ $is_op = $postAuthor?->id === $topicAuthor?->id && $postAuthor?->id !== null;
<?php endif; ?>
</div>
<?php endif; ?>
- <div class="media-body">
+ <div class="media-body" style="overflow: visible;">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title h3">
@@ -100,7 +100,7 @@ $is_op = $postAuthor?->id === $topicAuthor?->id && $postAuthor?->id !== null;
<?php endif; ?>
</div>
<div class="panel-body">
- <div class="post-content"><?= renderPost(trim($post->content)) ?></div>
+ <div class="post-content"><?= renderPost($post->content) ?></div>
<?php if (count($imageAttachments) > 0): ?>
<div class="post-images clearfix">
<?php /** @var Attachment $attachment */ foreach ($imageAttachments as $attachment): ?>
diff --git a/src/application/views/view_search_results.php b/src/application/views/view_search_results.php
index 19a6978..e21fbb8 100644
--- a/src/application/views/view_search_results.php
+++ b/src/application/views/view_search_results.php
@@ -27,7 +27,7 @@ use mystic\forum\utils\StringUtils;
</div>
<?php else: ?>
<div class="well icon-well text-info margin-top margin-bottom">
- <span class="glyphicon glyphicon-info-sign color-info" aria-hidden="true"></span>
+ <span class="glyphicon glyphicon-info-sign text-info" aria-hidden="true"></span>
<em><?= __("No results for this search") ?></em>
</div>
<?php endif; ?>
diff --git a/src/application/views/view_user.php b/src/application/views/view_user.php
index 6631407..aba0f2f 100644
--- a/src/application/views/view_user.php
+++ b/src/application/views/view_user.php
@@ -23,7 +23,7 @@ $dateJoined->setTime(0, 0, 0, 0);
?>
<div class="clearfix page-header margin-top-0">
- <img class="pull-left margin-right" src="?_action=profilepicture&amp;user=<?= htmlentities(urlencode($user->id)) ?>">
+ <img class="pull-left margin-right" src="?_action=profilepicture&amp;user=<?= htmlentities(urlencode($user->id)) ?>" alt="<?= __("Profile picture") ?>" width="64" height="64">
<span class="h1"><?= htmlentities($user->displayName) ?></span>
<?php if ($isOwnProfile): ?>
<span class="label label-primary"><?= __("You") ?></span>
@@ -69,7 +69,7 @@ $dateJoined->setTime(0, 0, 0, 0);
</div>
<?php else: ?>
<div class="well icon-well text-info margin-top margin-bottom">
- <span class="glyphicon glyphicon-info-sign color-info" aria-hidden="true"></span>
+ <span class="glyphicon glyphicon-info-sign text-info" aria-hidden="true"></span>
<em><?= __("This user has not posted anything yet") ?></em>
</div>
<?php endif; ?>
@@ -80,11 +80,12 @@ $dateJoined->setTime(0, 0, 0, 0);
<div class="col-md-3">
<h3><?= __("Edit profile") ?></h3>
<?php
-if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
+if (($_formError = RequestUtils::getAndClearFormError("update_profile")) !== null) {
_view("alert_error", ["message" => $_formError]);
}
?>
<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="form_id" value="update_profile">
<div class="form-group">
<label for="i_display_name"><?= __("Display name:") ?></label>
<input required class="form-control" type="text" name="display_name" id="i_display_name" value="<?= htmlentities($user->displayName) ?>">
@@ -130,12 +131,39 @@ $_checkbox_disabled_class = $_checkbox_disabled ? " disabled text-muted" : "";
<?= __("Upload new profile picture") ?>
</label>
</div>
- <input type="file" name="pfp" id="i_pfp" accept="image/png,image/jpeg" class="margin-left-3x">
+ <input type="file" name="pfp" id="i_pfp" accept="image/png,image/jpeg" class="margin-left-3x small">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success"><?= __("Save changes") ?></button>
</div>
</form>
+<?php if ($isOwnProfile): ?>
+<h3><?= __("Change password") ?></h3>
+<?php
+if (($_formError = RequestUtils::getAndClearFormError("update_password")) !== null) {
+ _view("alert_error", ["message" => $_formError]);
+}
+?>
+<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post">
+ <input type="hidden" name="form_id" value="update_password">
+ <div class="form-group">
+ <label for="i_current_password"><?= __("Current password:") ?></label>
+ <input autocomplete="current-password" required class="form-control" type="password" name="current_password" id="i_current_password" required>
+ </div>
+ <div class="form-group">
+ <label for="i_new_password"><?= __("New password:") ?></label>
+ <input autocomplete="new-password" required class="form-control" type="password" name="new_password" id="i_new_password" required>
+ </div>
+ <div class="form-group">
+ <label for="i_retype_password"><?= __("Retype password:") ?></label>
+ <input autocomplete="new-password" required class="form-control" type="password" name="retype_password" id="i_retype_password" required>
+ </div>
+ <div class="form-group">
+ <button type="submit" class="btn btn-success"><?= __("Change password") ?></button>
+ </div>
+</form>
+<?php endif; ?>
+
</div>
</div>