This commit is contained in:
@@ -12,6 +12,7 @@ $editPostId = (int)($_GET['edit_post'] ?? 0);
|
||||
$communityCfg = require __DIR__ . '/../../../config/community.php';
|
||||
$community = $pdo ? new \App\Community($pdo, $communityCfg) : null;
|
||||
$access = $pdo ? new \App\CommunityAccess($pdo, $communityCfg) : null;
|
||||
$forumCategories = $community ? $community->listForumCategories() : [];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
|
||||
$action = (string)($_POST['action'] ?? '');
|
||||
@@ -123,181 +124,190 @@ $userVotes = ($access && $userId) ? $access->getUserPostVotes((int)$userId, $pos
|
||||
<span><?= htmlspecialchars((string)$thread['title'], ENT_QUOTES) ?></span>
|
||||
</div>
|
||||
|
||||
<div class="forum-thread-head">
|
||||
<div>
|
||||
<h1><?= htmlspecialchars((string)$thread['title'], ENT_QUOTES) ?></h1>
|
||||
<p class="forum-thread-head__meta">Erstellt von <?= htmlspecialchars($threadAuthor, ENT_QUOTES) ?> am <?= htmlspecialchars((string)$thread['created_at'], ENT_QUOTES) ?></p>
|
||||
<?php if (!empty($thread['board_title'])): ?>
|
||||
<p class="muted small" style="margin:8px 0 0;">Bereich: <?= htmlspecialchars((string)$thread['board_title'], ENT_QUOTES) ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="forum-thread-head__meta-box">
|
||||
<strong><?= count($posts) ?></strong>
|
||||
<span>Antworten</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="toast-bar" style="margin-bottom:14px; border-color:#f87171; color:#991b1b;"><?= htmlspecialchars($error, ENT_QUOTES) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($info): ?>
|
||||
<div class="toast-bar" style="margin-bottom:14px;"><?= htmlspecialchars($info, ENT_QUOTES) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<article class="forum-post forum-post--lead">
|
||||
<aside class="forum-post__author">
|
||||
<div class="forum-post__avatar" aria-hidden="true"><?= strtoupper(mb_substr($threadAuthor, 0, 1)) ?></div>
|
||||
<strong><?= htmlspecialchars($threadAuthor, ENT_QUOTES) ?></strong>
|
||||
<span><?= htmlspecialchars(trim((string)($threadLevel['icon'] ?? '') . ' ' . (string)($threadLevel['label'] ?? '')), ENT_QUOTES) ?></span>
|
||||
<span><?= number_format($threadPoints, 1) ?> Punkte</span>
|
||||
<?php if ($isForumAdmin): ?>
|
||||
<div class="forum-post__admin">
|
||||
<button class="btn ghost" type="button" data-modal-open="modalThreadEdit">Thema bearbeiten</button>
|
||||
<form method="post" onsubmit="return confirm('Thema wirklich löschen?');">
|
||||
<input type="hidden" name="action" value="thread_delete">
|
||||
<button class="btn ghost" type="submit">Thema löschen</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</aside>
|
||||
<div class="forum-post__body">
|
||||
<div class="forum-post__head">
|
||||
<span><?= htmlspecialchars((string)$thread['created_at'], ENT_QUOTES) ?></span>
|
||||
<span>#1</span>
|
||||
</div>
|
||||
<div class="forum-post__content">
|
||||
<?= nl2br(htmlspecialchars((string)$thread['body'], ENT_QUOTES)) ?>
|
||||
</div>
|
||||
<?php if ($userId && $access && $access->supportsReports()): ?>
|
||||
<form method="post" class="forum-inline-report">
|
||||
<input type="hidden" name="action" value="report_content">
|
||||
<input type="hidden" name="target_type" value="thread">
|
||||
<input type="hidden" name="target_id" value="<?= (int)$thread['id'] ?>">
|
||||
<input type="hidden" name="reason" value="Thread benötigt Moderation oder Prüfung.">
|
||||
<button class="btn ghost" type="submit">Thema melden</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<div class="forum-replies-head">
|
||||
<h2>Antworten</h2>
|
||||
<span><?= count($posts) ?> Beitrag/Beiträge</span>
|
||||
</div>
|
||||
|
||||
<div class="forum-replies">
|
||||
<?php foreach ($posts as $index => $p): ?>
|
||||
<?php
|
||||
$postAuthor = (string)($p['display_name'] ?: 'Mitglied');
|
||||
$summary = $feedbackSummary[(int)$p['id']] ?? ['helpful' => 0, 'unhelpful' => 0];
|
||||
$userVote = $userVotes[(int)$p['id']] ?? 0;
|
||||
$isHighlighted = !empty($p['highlighted_at']);
|
||||
?>
|
||||
<article class="forum-post<?= $isHighlighted ? ' forum-post--highlighted' : '' ?>">
|
||||
<aside class="forum-post__author">
|
||||
<div class="forum-post__avatar" aria-hidden="true"><?= strtoupper(mb_substr($postAuthor, 0, 1)) ?></div>
|
||||
<strong><?= htmlspecialchars($postAuthor, ENT_QUOTES) ?></strong>
|
||||
<?php if ($isHighlighted): ?>
|
||||
<span class="forum-highlight-badge">Hilfreich hervorgehoben</span>
|
||||
<div class="forum-shell">
|
||||
<?php
|
||||
$sidebarCategories = $forumCategories;
|
||||
$sidebarCurrentBoardSlug = (string)($thread['board_slug'] ?? '');
|
||||
require __DIR__ . '/sidebar.php';
|
||||
?>
|
||||
<div class="forum-shell__main">
|
||||
<div class="forum-thread-head">
|
||||
<div>
|
||||
<h1><?= htmlspecialchars((string)$thread['title'], ENT_QUOTES) ?></h1>
|
||||
<p class="forum-thread-head__meta">Erstellt von <?= htmlspecialchars($threadAuthor, ENT_QUOTES) ?> am <?= htmlspecialchars((string)$thread['created_at'], ENT_QUOTES) ?></p>
|
||||
<?php if (!empty($thread['board_title'])): ?>
|
||||
<p class="muted small" style="margin:8px 0 0;">Bereich: <?= htmlspecialchars((string)$thread['board_title'], ENT_QUOTES) ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if ($isForumAdmin && $access && $access->supportsRestrictions()): ?>
|
||||
<form method="post" class="forum-admin-mini-form">
|
||||
<input type="hidden" name="action" value="restriction_set">
|
||||
<input type="hidden" name="target_user_id" value="<?= (int)$p['user_id'] ?>">
|
||||
<input type="hidden" name="restriction_type" value="reply_blocked">
|
||||
<input type="hidden" name="reason" value="Antworten in der Community vorübergehend gesperrt.">
|
||||
<button class="btn ghost" type="submit">Antworten sperren</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="forum-thread-head__meta-box">
|
||||
<strong><?= count($posts) ?></strong>
|
||||
<span>Antworten</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="toast-bar" style="margin-bottom:14px; border-color:#f87171; color:#991b1b;"><?= htmlspecialchars($error, ENT_QUOTES) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($info): ?>
|
||||
<div class="toast-bar" style="margin-bottom:14px;"><?= htmlspecialchars($info, ENT_QUOTES) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<article class="forum-post forum-post--lead">
|
||||
<aside class="forum-post__author">
|
||||
<div class="forum-post__avatar" aria-hidden="true"><?= strtoupper(mb_substr($threadAuthor, 0, 1)) ?></div>
|
||||
<strong><?= htmlspecialchars($threadAuthor, ENT_QUOTES) ?></strong>
|
||||
<span><?= htmlspecialchars(trim((string)($threadLevel['icon'] ?? '') . ' ' . (string)($threadLevel['label'] ?? '')), ENT_QUOTES) ?></span>
|
||||
<span><?= number_format($threadPoints, 1) ?> Punkte</span>
|
||||
<?php if ($isForumAdmin): ?>
|
||||
<div class="forum-post__admin">
|
||||
<button class="btn ghost" type="button" data-modal-open="modalThreadEdit">Thema bearbeiten</button>
|
||||
<form method="post" onsubmit="return confirm('Thema wirklich löschen?');">
|
||||
<input type="hidden" name="action" value="thread_delete">
|
||||
<button class="btn ghost" type="submit">Thema löschen</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</aside>
|
||||
<div class="forum-post__body">
|
||||
<div class="forum-post__head">
|
||||
<span><?= htmlspecialchars((string)$p['created_at'], ENT_QUOTES) ?></span>
|
||||
<span>#<?= $index + 2 ?></span>
|
||||
<span><?= htmlspecialchars((string)$thread['created_at'], ENT_QUOTES) ?></span>
|
||||
<span>#1</span>
|
||||
</div>
|
||||
<div class="forum-post__content">
|
||||
<?php if ($editPostId === (int)$p['id'] && $isForumAdmin): ?>
|
||||
<form method="post" class="stack gap-10">
|
||||
<input type="hidden" name="action" value="post_update">
|
||||
<input type="hidden" name="post_id" value="<?= (int)$p['id'] ?>">
|
||||
<textarea name="body" class="textarea" rows="6" required><?= htmlspecialchars((string)$p['body'], ENT_QUOTES) ?></textarea>
|
||||
<div class="flex gap-12">
|
||||
<button class="btn" type="submit">Änderung speichern</button>
|
||||
<a class="btn ghost" href="/community_thread?id=<?= $threadId ?>">Abbrechen</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<?= nl2br(htmlspecialchars((string)$p['body'], ENT_QUOTES)) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="forum-post__toolbar">
|
||||
<?php if ($userId && $access && $access->supportsFeedback()): ?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="post_vote">
|
||||
<input type="hidden" name="post_id" value="<?= (int)$p['id'] ?>">
|
||||
<input type="hidden" name="value" value="1">
|
||||
<button class="btn ghost<?= $userVote === 1 ? ' is-active' : '' ?>" type="submit">Hilfreich (<?= (int)$summary['helpful'] ?>)</button>
|
||||
</form>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="post_vote">
|
||||
<input type="hidden" name="post_id" value="<?= (int)$p['id'] ?>">
|
||||
<input type="hidden" name="value" value="-1">
|
||||
<button class="btn ghost<?= $userVote === -1 ? ' is-active' : '' ?>" type="submit">Nicht hilfreich (<?= (int)$summary['unhelpful'] ?>)</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php if ($userId && $access && $access->supportsReports()): ?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="report_content">
|
||||
<input type="hidden" name="target_type" value="post">
|
||||
<input type="hidden" name="target_id" value="<?= (int)$p['id'] ?>">
|
||||
<input type="hidden" name="reason" value="Beitrag benötigt Moderation oder Prüfung.">
|
||||
<button class="btn ghost" type="submit">Melden</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($userId && $access && $access->canHighlightHelpful($community->computePoints((int)$userId))): ?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="highlight_post">
|
||||
<input type="hidden" name="post_id" value="<?= (int)$p['id'] ?>">
|
||||
<input type="hidden" name="highlight" value="<?= $isHighlighted ? '0' : '1' ?>">
|
||||
<button class="btn ghost" type="submit"><?= $isHighlighted ? 'Hervorhebung entfernen' : 'Als hilfreich hervorheben' ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($isForumAdmin): ?>
|
||||
<a class="btn ghost" href="/community_thread?id=<?= $threadId ?>&edit_post=<?= (int)$p['id'] ?>">Bearbeiten</a>
|
||||
<form method="post" onsubmit="return confirm('Beitrag wirklich löschen?');">
|
||||
<input type="hidden" name="action" value="post_delete">
|
||||
<input type="hidden" name="post_id" value="<?= (int)$p['id'] ?>">
|
||||
<button class="btn ghost" type="submit">Löschen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?= nl2br(htmlspecialchars((string)$thread['body'], ENT_QUOTES)) ?>
|
||||
</div>
|
||||
<?php if ($userId && $access && $access->supportsReports()): ?>
|
||||
<form method="post" class="forum-inline-report">
|
||||
<input type="hidden" name="action" value="report_content">
|
||||
<input type="hidden" name="target_type" value="thread">
|
||||
<input type="hidden" name="target_id" value="<?= (int)$thread['id'] ?>">
|
||||
<input type="hidden" name="reason" value="Thread benötigt Moderation oder Prüfung.">
|
||||
<button class="btn ghost" type="submit">Thema melden</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!$posts): ?>
|
||||
<div class="forum-empty">Noch keine Antworten.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($userId): ?>
|
||||
<?php if ($userRestrictions['reply_blocked']): ?>
|
||||
<div class="forum-login-note">Du darfst aktuell keine Antworten schreiben. <?= !empty($userRestrictions['reason']) ? htmlspecialchars((string)$userRestrictions['reason'], ENT_QUOTES) : '' ?></div>
|
||||
<?php else: ?>
|
||||
<form method="post" class="forum-reply-form">
|
||||
<input type="hidden" name="action" value="reply">
|
||||
<div class="stack gap-6">
|
||||
<label class="label" for="replyBody">Antwort</label>
|
||||
<textarea id="replyBody" name="body" class="textarea" rows="4" required></textarea>
|
||||
</div>
|
||||
<button class="btn" type="submit">Antwort senden</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<div class="forum-login-note">Bitte <a href="/login">einloggen</a>, um zu antworten.</div>
|
||||
<?php endif; ?>
|
||||
<div class="forum-replies-head">
|
||||
<h2>Antworten</h2>
|
||||
<span><?= count($posts) ?> Beitrag/Beiträge</span>
|
||||
</div>
|
||||
|
||||
<div class="forum-replies">
|
||||
<?php foreach ($posts as $index => $p): ?>
|
||||
<?php
|
||||
$postAuthor = (string)($p['display_name'] ?: 'Mitglied');
|
||||
$summary = $feedbackSummary[(int)$p['id']] ?? ['helpful' => 0, 'unhelpful' => 0];
|
||||
$userVote = $userVotes[(int)$p['id']] ?? 0;
|
||||
$isHighlighted = !empty($p['highlighted_at']);
|
||||
?>
|
||||
<article class="forum-post<?= $isHighlighted ? ' forum-post--highlighted' : '' ?>">
|
||||
<aside class="forum-post__author">
|
||||
<div class="forum-post__avatar" aria-hidden="true"><?= strtoupper(mb_substr($postAuthor, 0, 1)) ?></div>
|
||||
<strong><?= htmlspecialchars($postAuthor, ENT_QUOTES) ?></strong>
|
||||
<?php if ($isHighlighted): ?>
|
||||
<span class="forum-highlight-badge">Hilfreich hervorgehoben</span>
|
||||
<?php endif; ?>
|
||||
<?php if ($isForumAdmin && $access && $access->supportsRestrictions()): ?>
|
||||
<form method="post" class="forum-admin-mini-form">
|
||||
<input type="hidden" name="action" value="restriction_set">
|
||||
<input type="hidden" name="target_user_id" value="<?= (int)$p['user_id'] ?>">
|
||||
<input type="hidden" name="restriction_type" value="reply_blocked">
|
||||
<input type="hidden" name="reason" value="Antworten in der Community vorübergehend gesperrt.">
|
||||
<button class="btn ghost" type="submit">Antworten sperren</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</aside>
|
||||
<div class="forum-post__body">
|
||||
<div class="forum-post__head">
|
||||
<span><?= htmlspecialchars((string)$p['created_at'], ENT_QUOTES) ?></span>
|
||||
<span>#<?= $index + 2 ?></span>
|
||||
</div>
|
||||
<div class="forum-post__content">
|
||||
<?php if ($editPostId === (int)$p['id'] && $isForumAdmin): ?>
|
||||
<form method="post" class="stack gap-10">
|
||||
<input type="hidden" name="action" value="post_update">
|
||||
<input type="hidden" name="post_id" value="<?= (int)$p['id'] ?>">
|
||||
<textarea name="body" class="textarea" rows="6" required><?= htmlspecialchars((string)$p['body'], ENT_QUOTES) ?></textarea>
|
||||
<div class="flex gap-12">
|
||||
<button class="btn" type="submit">Änderung speichern</button>
|
||||
<a class="btn ghost" href="/community_thread?id=<?= $threadId ?>">Abbrechen</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<?= nl2br(htmlspecialchars((string)$p['body'], ENT_QUOTES)) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="forum-post__toolbar">
|
||||
<?php if ($userId && $access && $access->supportsFeedback()): ?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="post_vote">
|
||||
<input type="hidden" name="post_id" value="<?= (int)$p['id'] ?>">
|
||||
<input type="hidden" name="value" value="1">
|
||||
<button class="btn ghost<?= $userVote === 1 ? ' is-active' : '' ?>" type="submit">Hilfreich (<?= (int)$summary['helpful'] ?>)</button>
|
||||
</form>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="post_vote">
|
||||
<input type="hidden" name="post_id" value="<?= (int)$p['id'] ?>">
|
||||
<input type="hidden" name="value" value="-1">
|
||||
<button class="btn ghost<?= $userVote === -1 ? ' is-active' : '' ?>" type="submit">Nicht hilfreich (<?= (int)$summary['unhelpful'] ?>)</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php if ($userId && $access && $access->supportsReports()): ?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="report_content">
|
||||
<input type="hidden" name="target_type" value="post">
|
||||
<input type="hidden" name="target_id" value="<?= (int)$p['id'] ?>">
|
||||
<input type="hidden" name="reason" value="Beitrag benötigt Moderation oder Prüfung.">
|
||||
<button class="btn ghost" type="submit">Melden</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($userId && $access && $access->canHighlightHelpful($community->computePoints((int)$userId))): ?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="highlight_post">
|
||||
<input type="hidden" name="post_id" value="<?= (int)$p['id'] ?>">
|
||||
<input type="hidden" name="highlight" value="<?= $isHighlighted ? '0' : '1' ?>">
|
||||
<button class="btn ghost" type="submit"><?= $isHighlighted ? 'Hervorhebung entfernen' : 'Als hilfreich hervorheben' ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($isForumAdmin): ?>
|
||||
<a class="btn ghost" href="/community_thread?id=<?= $threadId ?>&edit_post=<?= (int)$p['id'] ?>">Bearbeiten</a>
|
||||
<form method="post" onsubmit="return confirm('Beitrag wirklich löschen?');">
|
||||
<input type="hidden" name="action" value="post_delete">
|
||||
<input type="hidden" name="post_id" value="<?= (int)$p['id'] ?>">
|
||||
<button class="btn ghost" type="submit">Löschen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!$posts): ?>
|
||||
<div class="forum-empty">Noch keine Antworten.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($userId): ?>
|
||||
<?php if ($userRestrictions['reply_blocked']): ?>
|
||||
<div class="forum-login-note">Du darfst aktuell keine Antworten schreiben. <?= !empty($userRestrictions['reason']) ? htmlspecialchars((string)$userRestrictions['reason'], ENT_QUOTES) : '' ?></div>
|
||||
<?php else: ?>
|
||||
<form method="post" class="forum-reply-form">
|
||||
<input type="hidden" name="action" value="reply">
|
||||
<div class="stack gap-6">
|
||||
<label class="label" for="replyBody">Antwort</label>
|
||||
<textarea id="replyBody" name="body" class="textarea" rows="4" required></textarea>
|
||||
</div>
|
||||
<button class="btn" type="submit">Antwort senden</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<div class="forum-login-note">Bitte <a href="/login">einloggen</a>, um zu antworten.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user