This commit is contained in:
@@ -16,10 +16,6 @@ $access = $pdo ? new \App\CommunityAccess($pdo, $communityCfg) : null;
|
||||
$stats = $community ? $community->getStats() : ['threads' => 0, 'posts' => 0, 'members' => 0];
|
||||
$forumCategories = $community ? $community->listForumCategories() : [];
|
||||
$selectedBoard = ($community && $boardSlug !== '') ? $community->getBoardBySlug($boardSlug) : null;
|
||||
$userRoles = $access && $userId ? $access->getUserRoles((int)$userId) : [];
|
||||
$isForumAdmin = $access && $userId ? $access->canModerateForum((int)$userId) : false;
|
||||
$canManageApplications = $access && $userId ? ($access->canManageApplications((int)$userId) && $access->supportsApplications()) : false;
|
||||
$canManageRoles = $access && $userId ? $access->canManageRoles((int)$userId) : false;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
|
||||
$action = (string)($_POST['action'] ?? '');
|
||||
@@ -34,21 +30,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
|
||||
}
|
||||
$community->createThreadInBoard((int)$userId, (string)($_POST['board_slug'] ?? ''), (string)($_POST['title'] ?? ''), (string)($_POST['body'] ?? ''));
|
||||
redirect('/community' . ($boardSlug !== '' ? '?board=' . rawurlencode($boardSlug) : ''));
|
||||
} elseif ($action === 'application_decide') {
|
||||
$access->decideApplication((int)$userId, (int)($_POST['application_id'] ?? 0), (string)($_POST['decision'] ?? ''), (string)($_POST['decision_reason'] ?? ''));
|
||||
$info = 'Bewerbung wurde bearbeitet.';
|
||||
} elseif ($action === 'report_resolve') {
|
||||
$access->resolveReport((int)$userId, (int)($_POST['report_id'] ?? 0), (string)($_POST['moderator_note'] ?? ''));
|
||||
$info = 'Meldung wurde abgeschlossen.';
|
||||
} elseif ($action === 'role_revoke') {
|
||||
$access->revokeRole((int)$userId, (int)($_POST['target_user_id'] ?? 0), (string)($_POST['role'] ?? ''));
|
||||
$info = 'Rolle wurde entzogen.';
|
||||
} elseif ($action === 'restriction_set') {
|
||||
$access->setRestriction((int)$userId, (int)($_POST['target_user_id'] ?? 0), (string)($_POST['restriction_type'] ?? ''), (string)($_POST['reason'] ?? ''));
|
||||
$info = 'Community-Sperre wurde gesetzt.';
|
||||
} elseif ($action === 'restriction_clear') {
|
||||
$access->clearRestriction((int)$userId, (int)($_POST['target_user_id'] ?? 0), (string)($_POST['restriction_type'] ?? ''));
|
||||
$info = 'Community-Sperre wurde aufgehoben.';
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$error = $e->getMessage();
|
||||
@@ -58,9 +39,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
|
||||
$threads = $community
|
||||
? ($search !== '' ? $community->searchThreads($search, 50, $boardSlug !== '' ? $boardSlug : null) : $community->listThreads(50, $boardSlug !== '' ? $boardSlug : null))
|
||||
: [];
|
||||
$applications = $canManageApplications && $access ? $access->listApplications('open') : [];
|
||||
$reports = $isForumAdmin && $access ? $access->listOpenReports() : [];
|
||||
$roleAssignments = $canManageRoles && $access ? $access->listRoleAssignments() : [];
|
||||
?>
|
||||
<main class="section">
|
||||
<div class="container">
|
||||
@@ -117,198 +95,157 @@ $roleAssignments = $canManageRoles && $access ? $access->listRoleAssignments() :
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="forum-category-list">
|
||||
<?php foreach ($forumCategories as $category): ?>
|
||||
<section class="forum-category-card">
|
||||
<div class="forum-category-card__title"><?= htmlspecialchars((string)$category['title'], ENT_QUOTES) ?></div>
|
||||
<div class="forum-board-grid">
|
||||
<?php foreach ($category['boards'] as $board): ?>
|
||||
<?php $latest = $board['latest_thread'] ?? null; ?>
|
||||
<article class="forum-board-row">
|
||||
<div class="forum-board-row__main">
|
||||
<div class="forum-row__icon" aria-hidden="true"><?= htmlspecialchars((string)($board['icon'] ?? '💬'), ENT_QUOTES) ?></div>
|
||||
<div>
|
||||
<h3>
|
||||
<a href="/community?board=<?= rawurlencode((string)$board['slug']) ?>">
|
||||
<?= htmlspecialchars((string)$board['title'], ENT_QUOTES) ?>
|
||||
</a>
|
||||
</h3>
|
||||
<p><?= htmlspecialchars((string)$board['description'], ENT_QUOTES) ?></p>
|
||||
<div class="forum-row__meta">
|
||||
<span>Themen: <?= (int)($board['thread_count'] ?? 0) ?></span>
|
||||
<span>Beiträge: <?= (int)($board['post_count'] ?? 0) ?></span>
|
||||
<?php if ($selectedBoard): ?>
|
||||
<div class="forum-shell">
|
||||
<?php
|
||||
$sidebarCategories = $forumCategories;
|
||||
$sidebarCurrentBoardSlug = (string)$selectedBoard['slug'];
|
||||
require __DIR__ . '/sidebar.php';
|
||||
?>
|
||||
<div class="forum-shell__main">
|
||||
<div class="forum-board">
|
||||
<div class="forum-board__head">
|
||||
<div>
|
||||
<h2><?= htmlspecialchars($selectedBoard['title'], ENT_QUOTES) ?></h2>
|
||||
<p class="muted"><?= htmlspecialchars((string)$selectedBoard['description'], ENT_QUOTES) ?></p>
|
||||
</div>
|
||||
<a class="btn ghost" href="/community">Alle Bereiche anzeigen</a>
|
||||
</div>
|
||||
|
||||
<div class="forum-list">
|
||||
<div class="forum-list__header">
|
||||
<span>Thema</span>
|
||||
<span>Antworten</span>
|
||||
<span>Letzte Aktivität</span>
|
||||
</div>
|
||||
|
||||
<?php foreach ($threads as $t): ?>
|
||||
<?php
|
||||
$pts = ($community && $pdo) ? $community->computePoints((int)$t['uid']) : 0.0;
|
||||
$lvl = $community ? $community->membershipLevel($pts) : ['label'=>'','icon'=>''];
|
||||
$preview = mb_substr((string)$t['body'], 0, 220);
|
||||
?>
|
||||
<article class="forum-row">
|
||||
<div class="forum-row__topic">
|
||||
<div class="forum-row__icon" aria-hidden="true">💬</div>
|
||||
<div>
|
||||
<h3><a href="/community_thread?id=<?= (int)$t['id'] ?>"><?= htmlspecialchars((string)$t['title'], ENT_QUOTES) ?></a></h3>
|
||||
<div class="forum-row__meta">
|
||||
<span><?= htmlspecialchars((string)($t['display_name'] ?: 'Mitglied'), ENT_QUOTES) ?></span>
|
||||
<span><?= htmlspecialchars(trim((string)($lvl['icon'] ?? '') . ' ' . (string)($lvl['label'] ?? '')), ENT_QUOTES) ?></span>
|
||||
</div>
|
||||
<p><?= nl2br(htmlspecialchars($preview, ENT_QUOTES)) ?><?= mb_strlen((string)$t['body']) > 220 ? '…' : '' ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="forum-board-row__latest">
|
||||
<?php if ($latest): ?>
|
||||
<strong><a href="/community_thread?id=<?= (int)$latest['id'] ?>"><?= htmlspecialchars((string)$latest['title'], ENT_QUOTES) ?></a></strong>
|
||||
<span><?= htmlspecialchars((string)($latest['last_activity_by'] ?: 'Mitglied'), ENT_QUOTES) ?></span>
|
||||
<span><?= htmlspecialchars((string)$latest['last_activity_at'], ENT_QUOTES) ?></span>
|
||||
<?php else: ?>
|
||||
<span class="muted">Noch keine Themen</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
<div class="forum-row__count">
|
||||
<strong><?= (int)$t['answers'] ?></strong>
|
||||
<span>Antworten</span>
|
||||
</div>
|
||||
<div class="forum-row__activity">
|
||||
<strong><?= htmlspecialchars((string)($t['last_activity_by'] ?: 'Mitglied'), ENT_QUOTES) ?></strong>
|
||||
<span><?= htmlspecialchars((string)$t['last_activity_at'], ENT_QUOTES) ?></span>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (!$threads): ?>
|
||||
<div class="forum-empty">In diesem Bereich gibt es noch keine Themen.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="forum-board" style="margin-top:24px;">
|
||||
<div class="forum-board__head">
|
||||
<div>
|
||||
<h2><?= htmlspecialchars($selectedBoard['title'] ?? 'Neueste Themen', ENT_QUOTES) ?></h2>
|
||||
<p class="muted">
|
||||
<?= htmlspecialchars($selectedBoard['description'] ?? 'Hier siehst du die zuletzt erstellten oder zuletzt aktiven Themen aus der Community.', ENT_QUOTES) ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php if ($selectedBoard): ?>
|
||||
<a class="btn ghost" href="/community">Alle Bereiche anzeigen</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="forum-list">
|
||||
<div class="forum-list__header">
|
||||
<span>Thema</span>
|
||||
<span>Antworten</span>
|
||||
<span>Letzte Aktivität</span>
|
||||
</div>
|
||||
|
||||
<?php foreach ($threads as $t): ?>
|
||||
<?php
|
||||
$pts = ($community && $pdo) ? $community->computePoints((int)$t['uid']) : 0.0;
|
||||
$lvl = $community ? $community->membershipLevel($pts) : ['label'=>'','icon'=>''];
|
||||
$preview = mb_substr((string)$t['body'], 0, 220);
|
||||
?>
|
||||
<article class="forum-row">
|
||||
<div class="forum-row__topic">
|
||||
<div class="forum-row__icon" aria-hidden="true">💬</div>
|
||||
<div>
|
||||
<h3><a href="/community_thread?id=<?= (int)$t['id'] ?>"><?= htmlspecialchars((string)$t['title'], ENT_QUOTES) ?></a></h3>
|
||||
<div class="forum-row__meta">
|
||||
<span><?= htmlspecialchars((string)($t['display_name'] ?: 'Mitglied'), ENT_QUOTES) ?></span>
|
||||
<span><?= htmlspecialchars(trim((string)($lvl['icon'] ?? '') . ' ' . (string)($lvl['label'] ?? '')), ENT_QUOTES) ?></span>
|
||||
<?php if (!empty($t['board_title'])): ?>
|
||||
<span><?= htmlspecialchars((string)$t['board_title'], ENT_QUOTES) ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<p><?= nl2br(htmlspecialchars($preview, ENT_QUOTES)) ?><?= mb_strlen((string)$t['body']) > 220 ? '…' : '' ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="forum-row__count">
|
||||
<strong><?= (int)$t['answers'] ?></strong>
|
||||
<span>Antworten</span>
|
||||
</div>
|
||||
<div class="forum-row__activity">
|
||||
<strong><?= htmlspecialchars((string)($t['last_activity_by'] ?: 'Mitglied'), ENT_QUOTES) ?></strong>
|
||||
<span><?= htmlspecialchars((string)$t['last_activity_at'], ENT_QUOTES) ?></span>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (!$threads): ?>
|
||||
<div class="forum-empty">Keine Themen gefunden.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($canManageApplications || $isForumAdmin || $canManageRoles): ?>
|
||||
<div class="forum-admin-grid">
|
||||
<?php if ($canManageApplications): ?>
|
||||
<section class="forum-board">
|
||||
<div class="forum-board__head">
|
||||
<div>
|
||||
<h2>Offene Bewerbungen</h2>
|
||||
<p class="muted">Bewerbungen ab Rang Community-Vater prüfen.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="forum-admin-list">
|
||||
<?php foreach ($applications as $application): ?>
|
||||
<article class="forum-admin-item">
|
||||
<div>
|
||||
<strong><?= htmlspecialchars((string)($application['display_name'] ?: $application['email']), ENT_QUOTES) ?></strong>
|
||||
<p><?= nl2br(htmlspecialchars((string)$application['motivation'], ENT_QUOTES)) ?></p>
|
||||
</div>
|
||||
<form method="post" class="forum-admin-item__actions">
|
||||
<input type="hidden" name="action" value="application_decide">
|
||||
<input type="hidden" name="application_id" value="<?= (int)$application['id'] ?>">
|
||||
<textarea name="decision_reason" class="textarea" rows="3" placeholder="Begründung (optional bei Annahme, sinnvoll bei Ablehnung)"></textarea>
|
||||
<div class="flex gap-12">
|
||||
<button class="btn" type="submit" name="decision" value="approved">Annehmen</button>
|
||||
<button class="btn ghost" type="submit" name="decision" value="rejected">Ablehnen</button>
|
||||
<?php else: ?>
|
||||
<div class="forum-category-list">
|
||||
<?php foreach ($forumCategories as $category): ?>
|
||||
<section class="forum-category-card">
|
||||
<div class="forum-category-card__title"><?= htmlspecialchars((string)$category['title'], ENT_QUOTES) ?></div>
|
||||
<div class="forum-board-grid">
|
||||
<?php foreach ($category['boards'] as $board): ?>
|
||||
<?php $latest = $board['latest_thread'] ?? null; ?>
|
||||
<article class="forum-board-row">
|
||||
<div class="forum-board-row__main">
|
||||
<div class="forum-row__icon" aria-hidden="true"><?= htmlspecialchars((string)($board['icon'] ?? '💬'), ENT_QUOTES) ?></div>
|
||||
<div>
|
||||
<h3>
|
||||
<a href="/community?board=<?= rawurlencode((string)$board['slug']) ?>">
|
||||
<?= htmlspecialchars((string)$board['title'], ENT_QUOTES) ?>
|
||||
</a>
|
||||
</h3>
|
||||
<p><?= htmlspecialchars((string)$board['description'], ENT_QUOTES) ?></p>
|
||||
<div class="forum-row__meta">
|
||||
<span>Themen: <?= (int)($board['thread_count'] ?? 0) ?></span>
|
||||
<span>Beiträge: <?= (int)($board['post_count'] ?? 0) ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!$applications): ?>
|
||||
<div class="forum-empty">Keine offenen Bewerbungen.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($isForumAdmin && $access && $access->supportsReports()): ?>
|
||||
<section class="forum-board">
|
||||
<div class="forum-board__head">
|
||||
<div>
|
||||
<h2>Offene Meldungen</h2>
|
||||
<p class="muted">Gemeldete Inhalte prüfen und moderieren.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="forum-admin-list">
|
||||
<?php foreach ($reports as $report): ?>
|
||||
<article class="forum-admin-item">
|
||||
<div>
|
||||
<strong><?= htmlspecialchars((string)$report['target_type'], ENT_QUOTES) ?> #<?= (int)$report['target_id'] ?></strong>
|
||||
<p><?= nl2br(htmlspecialchars((string)$report['reason'], ENT_QUOTES)) ?></p>
|
||||
<p class="muted small">Gemeldet von <?= htmlspecialchars((string)($report['reporter_name'] ?: 'Mitglied'), ENT_QUOTES) ?> am <?= htmlspecialchars((string)$report['created_at'], ENT_QUOTES) ?></p>
|
||||
</div>
|
||||
<form method="post" class="forum-admin-item__actions">
|
||||
<input type="hidden" name="action" value="report_resolve">
|
||||
<input type="hidden" name="report_id" value="<?= (int)$report['id'] ?>">
|
||||
<textarea name="moderator_note" class="textarea" rows="3" placeholder="Moderationsnotiz (optional)"></textarea>
|
||||
<button class="btn" type="submit">Als erledigt markieren</button>
|
||||
</form>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!$reports): ?>
|
||||
<div class="forum-empty">Keine offenen Meldungen.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canManageRoles && $access && $access->hasModerationTables()): ?>
|
||||
<section class="forum-board">
|
||||
<div class="forum-board__head">
|
||||
<div>
|
||||
<h2>Rollenübersicht</h2>
|
||||
<p class="muted">Vergebene Community-Rollen im Blick behalten.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="forum-admin-list">
|
||||
<?php foreach ($roleAssignments as $assignment): ?>
|
||||
<article class="forum-admin-item">
|
||||
<div>
|
||||
<strong><?= htmlspecialchars((string)($assignment['display_name'] ?: $assignment['email']), ENT_QUOTES) ?></strong>
|
||||
<p class="muted small">Rolle: <?= htmlspecialchars((string)$assignment['role'], ENT_QUOTES) ?> · seit <?= htmlspecialchars((string)$assignment['assigned_at'], ENT_QUOTES) ?></p>
|
||||
<div class="forum-board-row__latest">
|
||||
<?php if ($latest): ?>
|
||||
<strong><a href="/community_thread?id=<?= (int)$latest['id'] ?>"><?= htmlspecialchars((string)$latest['title'], ENT_QUOTES) ?></a></strong>
|
||||
<span><?= htmlspecialchars((string)($latest['last_activity_by'] ?: 'Mitglied'), ENT_QUOTES) ?></span>
|
||||
<span><?= htmlspecialchars((string)$latest['last_activity_at'], ENT_QUOTES) ?></span>
|
||||
<?php else: ?>
|
||||
<span class="muted">Noch keine Themen</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="role_revoke">
|
||||
<input type="hidden" name="target_user_id" value="<?= (int)$assignment['user_id'] ?>">
|
||||
<input type="hidden" name="role" value="<?= htmlspecialchars((string)$assignment['role'], ENT_QUOTES) ?>">
|
||||
<button class="btn ghost" type="submit">Rolle entziehen</button>
|
||||
</form>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!$roleAssignments): ?>
|
||||
<div class="forum-empty">Keine Rollen vergeben.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="forum-board" style="margin-top:24px;">
|
||||
<div class="forum-board__head">
|
||||
<div>
|
||||
<h2>Neueste Themen</h2>
|
||||
<p class="muted">Hier siehst du die zuletzt erstellten oder zuletzt aktiven Themen aus der Community.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="forum-list">
|
||||
<div class="forum-list__header">
|
||||
<span>Thema</span>
|
||||
<span>Antworten</span>
|
||||
<span>Letzte Aktivität</span>
|
||||
</div>
|
||||
|
||||
<?php foreach ($threads as $t): ?>
|
||||
<?php
|
||||
$pts = ($community && $pdo) ? $community->computePoints((int)$t['uid']) : 0.0;
|
||||
$lvl = $community ? $community->membershipLevel($pts) : ['label'=>'','icon'=>''];
|
||||
$preview = mb_substr((string)$t['body'], 0, 220);
|
||||
?>
|
||||
<article class="forum-row">
|
||||
<div class="forum-row__topic">
|
||||
<div class="forum-row__icon" aria-hidden="true">💬</div>
|
||||
<div>
|
||||
<h3><a href="/community_thread?id=<?= (int)$t['id'] ?>"><?= htmlspecialchars((string)$t['title'], ENT_QUOTES) ?></a></h3>
|
||||
<div class="forum-row__meta">
|
||||
<span><?= htmlspecialchars((string)($t['display_name'] ?: 'Mitglied'), ENT_QUOTES) ?></span>
|
||||
<span><?= htmlspecialchars(trim((string)($lvl['icon'] ?? '') . ' ' . (string)($lvl['label'] ?? '')), ENT_QUOTES) ?></span>
|
||||
<?php if (!empty($t['board_title'])): ?>
|
||||
<span><?= htmlspecialchars((string)$t['board_title'], ENT_QUOTES) ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<p><?= nl2br(htmlspecialchars($preview, ENT_QUOTES)) ?><?= mb_strlen((string)$t['body']) > 220 ? '…' : '' ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="forum-row__count">
|
||||
<strong><?= (int)$t['answers'] ?></strong>
|
||||
<span>Antworten</span>
|
||||
</div>
|
||||
<div class="forum-row__activity">
|
||||
<strong><?= htmlspecialchars((string)($t['last_activity_by'] ?: 'Mitglied'), ENT_QUOTES) ?></strong>
|
||||
<span><?= htmlspecialchars((string)$t['last_activity_at'], ENT_QUOTES) ?></span>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (!$threads): ?>
|
||||
<div class="forum-empty">Keine Themen gefunden.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user