This commit is contained in:
221
partials/landing/account/community-admin.php
Normal file
221
partials/landing/account/community-admin.php
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
$app = app();
|
||||||
|
$pdo = $app->pdo();
|
||||||
|
$userId = $_SESSION['user_id'] ?? null;
|
||||||
|
|
||||||
|
if (!$userId) {
|
||||||
|
redirect('/login');
|
||||||
|
}
|
||||||
|
|
||||||
|
$communityCfg = require __DIR__ . '/../../../config/community.php';
|
||||||
|
$access = $pdo ? new \App\CommunityAccess($pdo, $communityCfg) : null;
|
||||||
|
$migration = $pdo ? new \App\CommunityMigration($pdo) : null;
|
||||||
|
|
||||||
|
if (!$access || !$access->canModerateForum((int)$userId)) {
|
||||||
|
http_response_code(403);
|
||||||
|
echo '<main class="section"><div class="container"><div class="card dash-card"><h1>Kein Zugriff</h1><p class="muted">Dieser Bereich ist nur für Community-Admins freigegeben.</p></div></div></main>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$error = '';
|
||||||
|
$info = '';
|
||||||
|
$canManageApplications = $access->canManageApplications((int)$userId) && $access->supportsApplications();
|
||||||
|
$canManageRoles = $access->canManageRoles((int)$userId);
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$action = (string)($_POST['action'] ?? '');
|
||||||
|
try {
|
||||||
|
if ($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 === 'role_assign') {
|
||||||
|
$access->assignRole((int)$userId, (int)($_POST['target_user_id'] ?? 0), (string)($_POST['role'] ?? ''));
|
||||||
|
$info = 'Rolle wurde vergeben.';
|
||||||
|
} elseif ($action === 'community_migrate') {
|
||||||
|
if (!$canManageApplications || !$migration) {
|
||||||
|
throw new \RuntimeException('Keine Berechtigung für die Community-Migration.');
|
||||||
|
}
|
||||||
|
$migration->apply();
|
||||||
|
$info = 'Die Community-Migration wurde ausgeführt.';
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$error = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$applications = $canManageApplications ? $access->listApplications('open') : [];
|
||||||
|
$reports = $access->supportsReports() ? $access->listOpenReports() : [];
|
||||||
|
$roleAssignments = $canManageRoles ? $access->listRoleAssignments() : [];
|
||||||
|
$migrationStatus = ($migration && $canManageApplications) ? $migration->status() : null;
|
||||||
|
?>
|
||||||
|
<main class="section">
|
||||||
|
<div class="container">
|
||||||
|
<div class="forum-breadcrumbs">
|
||||||
|
<a href="/">Home</a>
|
||||||
|
<span>/</span>
|
||||||
|
<a href="/dashboard">Mitgliederbereich</a>
|
||||||
|
<span>/</span>
|
||||||
|
<span>Community-Admin</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="forum-hero forum-hero--compact">
|
||||||
|
<div>
|
||||||
|
<h1>Community-Admin</h1>
|
||||||
|
<p class="forum-hero__copy">Moderation, Bewerbungen und Rollen an einem Ort.</p>
|
||||||
|
</div>
|
||||||
|
<div class="forum-hero__cta">
|
||||||
|
<a class="btn ghost" href="/dashboard">Zurück zum Mitgliederbereich</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($error): ?>
|
||||||
|
<div class="toast-bar" style="margin-top:14px; border-color:#f87171; color:#991b1b;"><?= htmlspecialchars($error, ENT_QUOTES) ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ($info): ?>
|
||||||
|
<div class="toast-bar" style="margin-top:14px;"><?= htmlspecialchars($info, ENT_QUOTES) ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<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 für die Forum-Moderation 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"></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>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</article>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php if (!$applications): ?>
|
||||||
|
<div class="forum-empty">Keine offenen Bewerbungen.</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<section class="forum-board">
|
||||||
|
<div class="forum-board__head">
|
||||||
|
<div>
|
||||||
|
<h2>Offene Meldungen</h2>
|
||||||
|
<p class="muted">Gemeldete Inhalte prüfen und abschließen.</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"></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 if ($canManageRoles): ?>
|
||||||
|
<section class="forum-board">
|
||||||
|
<div class="forum-board__head">
|
||||||
|
<div>
|
||||||
|
<h2>Rollen verwalten</h2>
|
||||||
|
<p class="muted">Community-Rollen vergeben und entziehen.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="padding:24px; border-bottom:1px solid var(--color-border);">
|
||||||
|
<form method="post" class="form-grid single">
|
||||||
|
<input type="hidden" name="action" value="role_assign">
|
||||||
|
<div class="stack gap-6">
|
||||||
|
<label class="label" for="adminTargetUserId">Benutzer-ID</label>
|
||||||
|
<input id="adminTargetUserId" name="target_user_id" class="input" type="number" min="1" required>
|
||||||
|
</div>
|
||||||
|
<div class="stack gap-6">
|
||||||
|
<label class="label" for="adminRole">Rolle</label>
|
||||||
|
<select id="adminRole" name="role" class="select">
|
||||||
|
<option value="forum_admin">forum_admin</option>
|
||||||
|
<option value="site_admin">site_admin</option>
|
||||||
|
<option value="owner">owner</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button class="btn" type="submit">Rolle vergeben</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</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>
|
||||||
|
<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 if ($canManageApplications && $migrationStatus): ?>
|
||||||
|
<section class="forum-board">
|
||||||
|
<div class="forum-board__head">
|
||||||
|
<div>
|
||||||
|
<h2>Migration</h2>
|
||||||
|
<p class="muted">Status der Community-Datenbank prüfen.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="padding:24px;">
|
||||||
|
<ul class="dash-list">
|
||||||
|
<li>Status: <?= !empty($migrationStatus['complete']) ? 'Vollständig eingerichtet' : 'Migration noch offen' ?></li>
|
||||||
|
<li>Fehlende Bausteine: <?= !empty($migrationStatus['missing']) ? htmlspecialchars(implode(', ', $migrationStatus['missing']), ENT_QUOTES) : 'Keine' ?></li>
|
||||||
|
</ul>
|
||||||
|
<form method="post" style="margin-top:14px;">
|
||||||
|
<input type="hidden" name="action" value="community_migrate">
|
||||||
|
<button class="btn" type="submit">Community-Migration ausführen</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
@@ -30,10 +30,13 @@ $allowNoKidsChecked = $editEvent ? ((int)$editEvent['allow_kids'] === 0) : false
|
|||||||
|
|
||||||
<div class="container dash-section">
|
<div class="container dash-section">
|
||||||
<div class="dash-grid">
|
<div class="dash-grid">
|
||||||
<?php if (!empty($communityIsSiteAdmin)): ?>
|
<?php if (in_array('forum_admin', $communityRoles ?? [], true) || !empty($communityIsSiteAdmin)): ?>
|
||||||
<div class="card dash-card">
|
<div class="card dash-card">
|
||||||
<div class="badge">Admin</div>
|
<div class="badge">Admin</div>
|
||||||
<h3>Community-Migration</h3>
|
<h3>Community-Verwaltung</h3>
|
||||||
|
<div class="flex gap-12" style="margin:12px 0; flex-wrap:wrap;">
|
||||||
|
<a class="btn" href="/community-admin">Zum Admin-Bereich</a>
|
||||||
|
</div>
|
||||||
<?php if ($communityMigrationStatus): ?>
|
<?php if ($communityMigrationStatus): ?>
|
||||||
<ul class="dash-list">
|
<ul class="dash-list">
|
||||||
<li>Status: <?= !empty($communityMigrationStatus['complete']) ? 'Vollständig eingerichtet' : 'Migration noch offen' ?></li>
|
<li>Status: <?= !empty($communityMigrationStatus['complete']) ? 'Vollständig eingerichtet' : 'Migration noch offen' ?></li>
|
||||||
@@ -42,13 +45,13 @@ $allowNoKidsChecked = $editEvent ? ((int)$editEvent['allow_kids'] === 0) : false
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p class="muted small">Migrationsstatus konnte nicht ermittelt werden.</p>
|
<p class="muted small">Migrationsstatus konnte nicht ermittelt werden.</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php if (!empty($communityIsSiteAdmin)): ?>
|
||||||
<form method="post" style="margin-top:12px;">
|
<form method="post" style="margin-top:12px;">
|
||||||
<input type="hidden" name="action" value="community_migrate">
|
<input type="hidden" name="action" value="community_migrate">
|
||||||
<button class="btn" type="submit">Community-Migration ausführen</button>
|
<button class="btn" type="submit">Community-Migration ausführen</button>
|
||||||
</form>
|
</form>
|
||||||
<p class="muted small" style="margin-top:10px;">
|
<?php endif; ?>
|
||||||
Führt die für Rollen, Bewerbungen, Meldungen, Bewertungen und Forenstruktur benötigten Datenbank-Erweiterungen aus.
|
<p class="muted small" style="margin-top:10px;">Bündelt Moderation, Bewerbungen, Rollen und bei Bedarf auch die Community-Migration.</p>
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,6 @@ $access = $pdo ? new \App\CommunityAccess($pdo, $communityCfg) : null;
|
|||||||
$stats = $community ? $community->getStats() : ['threads' => 0, 'posts' => 0, 'members' => 0];
|
$stats = $community ? $community->getStats() : ['threads' => 0, 'posts' => 0, 'members' => 0];
|
||||||
$forumCategories = $community ? $community->listForumCategories() : [];
|
$forumCategories = $community ? $community->listForumCategories() : [];
|
||||||
$selectedBoard = ($community && $boardSlug !== '') ? $community->getBoardBySlug($boardSlug) : null;
|
$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) {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
|
||||||
$action = (string)($_POST['action'] ?? '');
|
$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'] ?? ''));
|
$community->createThreadInBoard((int)$userId, (string)($_POST['board_slug'] ?? ''), (string)($_POST['title'] ?? ''), (string)($_POST['body'] ?? ''));
|
||||||
redirect('/community' . ($boardSlug !== '' ? '?board=' . rawurlencode($boardSlug) : ''));
|
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) {
|
} catch (\Throwable $e) {
|
||||||
$error = $e->getMessage();
|
$error = $e->getMessage();
|
||||||
@@ -58,9 +39,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
|
|||||||
$threads = $community
|
$threads = $community
|
||||||
? ($search !== '' ? $community->searchThreads($search, 50, $boardSlug !== '' ? $boardSlug : null) : $community->listThreads(50, $boardSlug !== '' ? $boardSlug : null))
|
? ($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">
|
<main class="section">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -117,6 +95,67 @@ $roleAssignments = $canManageRoles && $access ? $access->listRoleAssignments() :
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?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 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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
<div class="forum-category-list">
|
<div class="forum-category-list">
|
||||||
<?php foreach ($forumCategories as $category): ?>
|
<?php foreach ($forumCategories as $category): ?>
|
||||||
<section class="forum-category-card">
|
<section class="forum-category-card">
|
||||||
@@ -159,14 +198,9 @@ $roleAssignments = $canManageRoles && $access ? $access->listRoleAssignments() :
|
|||||||
<div class="forum-board" style="margin-top:24px;">
|
<div class="forum-board" style="margin-top:24px;">
|
||||||
<div class="forum-board__head">
|
<div class="forum-board__head">
|
||||||
<div>
|
<div>
|
||||||
<h2><?= htmlspecialchars($selectedBoard['title'] ?? 'Neueste Themen', ENT_QUOTES) ?></h2>
|
<h2>Neueste Themen</h2>
|
||||||
<p class="muted">
|
<p class="muted">Hier siehst du die zuletzt erstellten oder zuletzt aktiven Themen aus der Community.</p>
|
||||||
<?= htmlspecialchars($selectedBoard['description'] ?? 'Hier siehst du die zuletzt erstellten oder zuletzt aktiven Themen aus der Community.', ENT_QUOTES) ?>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<?php if ($selectedBoard): ?>
|
|
||||||
<a class="btn ghost" href="/community">Alle Bereiche anzeigen</a>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="forum-list">
|
<div class="forum-list">
|
||||||
@@ -213,103 +247,6 @@ $roleAssignments = $canManageRoles && $access ? $access->listRoleAssignments() :
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
|
||||||
</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>
|
|
||||||
<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; ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
32
partials/landing/community/sidebar.php
Normal file
32
partials/landing/community/sidebar.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
$sidebarCategories = $sidebarCategories ?? [];
|
||||||
|
$sidebarCurrentBoardSlug = (string)($sidebarCurrentBoardSlug ?? '');
|
||||||
|
?>
|
||||||
|
<aside class="forum-sidebar">
|
||||||
|
<div class="forum-sidebar__inner">
|
||||||
|
<div class="forum-sidebar__head">
|
||||||
|
<span class="badge">Themenbereiche</span>
|
||||||
|
<h2>Community-Navigation</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="forum-sidebar__tree">
|
||||||
|
<?php foreach ($sidebarCategories as $sidebarCategory): ?>
|
||||||
|
<section class="forum-sidebar__group">
|
||||||
|
<h3><?= htmlspecialchars((string)$sidebarCategory['title'], ENT_QUOTES) ?></h3>
|
||||||
|
<ul>
|
||||||
|
<?php foreach ($sidebarCategory['boards'] as $sidebarBoard): ?>
|
||||||
|
<li>
|
||||||
|
<a class="<?= $sidebarCurrentBoardSlug === (string)$sidebarBoard['slug'] ? 'is-active' : '' ?>" href="/community?board=<?= rawurlencode((string)$sidebarBoard['slug']) ?>">
|
||||||
|
<span><?= htmlspecialchars((string)$sidebarBoard['title'], ENT_QUOTES) ?></span>
|
||||||
|
<small><?= (int)($sidebarBoard['thread_count'] ?? 0) ?></small>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
@@ -12,6 +12,7 @@ $editPostId = (int)($_GET['edit_post'] ?? 0);
|
|||||||
$communityCfg = require __DIR__ . '/../../../config/community.php';
|
$communityCfg = require __DIR__ . '/../../../config/community.php';
|
||||||
$community = $pdo ? new \App\Community($pdo, $communityCfg) : null;
|
$community = $pdo ? new \App\Community($pdo, $communityCfg) : null;
|
||||||
$access = $pdo ? new \App\CommunityAccess($pdo, $communityCfg) : null;
|
$access = $pdo ? new \App\CommunityAccess($pdo, $communityCfg) : null;
|
||||||
|
$forumCategories = $community ? $community->listForumCategories() : [];
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
|
||||||
$action = (string)($_POST['action'] ?? '');
|
$action = (string)($_POST['action'] ?? '');
|
||||||
@@ -123,6 +124,13 @@ $userVotes = ($access && $userId) ? $access->getUserPostVotes((int)$userId, $pos
|
|||||||
<span><?= htmlspecialchars((string)$thread['title'], ENT_QUOTES) ?></span>
|
<span><?= htmlspecialchars((string)$thread['title'], ENT_QUOTES) ?></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<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 class="forum-thread-head">
|
||||||
<div>
|
<div>
|
||||||
<h1><?= htmlspecialchars((string)$thread['title'], ENT_QUOTES) ?></h1>
|
<h1><?= htmlspecialchars((string)$thread['title'], ENT_QUOTES) ?></h1>
|
||||||
@@ -299,6 +307,8 @@ $userVotes = ($access && $userId) ? $access->getUserPostVotes((int)$userId, $pos
|
|||||||
<div class="forum-login-note">Bitte <a href="/login">einloggen</a>, um zu antworten.</div>
|
<div class="forum-login-note">Bitte <a href="/login">einloggen</a>, um zu antworten.</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<?php if ($isForumAdmin): ?>
|
<?php if ($isForumAdmin): ?>
|
||||||
|
|||||||
@@ -177,6 +177,19 @@ body {
|
|||||||
.forum-board { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
|
.forum-board { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
|
||||||
.forum-board__head { display: flex; justify-content: space-between; gap: 20px; align-items: end; padding: 22px 24px; border-bottom: 1px solid var(--color-border); background: #fffdfa; }
|
.forum-board__head { display: flex; justify-content: space-between; gap: 20px; align-items: end; padding: 22px 24px; border-bottom: 1px solid var(--color-border); background: #fffdfa; }
|
||||||
.forum-board__head h2 { margin: 0 0 6px; }
|
.forum-board__head h2 { margin: 0 0 6px; }
|
||||||
|
.forum-shell { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 24px; margin-top: 24px; align-items: start; }
|
||||||
|
.forum-shell__main { min-width: 0; }
|
||||||
|
.forum-sidebar { position: sticky; top: 104px; }
|
||||||
|
.forum-sidebar__inner { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
|
||||||
|
.forum-sidebar__head { padding: 20px 20px 16px; border-bottom: 1px solid var(--color-border); background: linear-gradient(180deg, #fffdfa, #f8f4ec); }
|
||||||
|
.forum-sidebar__head h2 { margin: 10px 0 0; font-size: 22px; }
|
||||||
|
.forum-sidebar__tree { padding: 14px; display: grid; gap: 14px; }
|
||||||
|
.forum-sidebar__group h3 { margin: 0 0 10px; font-size: 15px; color: var(--color-primary); }
|
||||||
|
.forum-sidebar__group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
|
||||||
|
.forum-sidebar__group a { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--color-text); transition: background .15s ease, color .15s ease; }
|
||||||
|
.forum-sidebar__group a:hover { background: #f8f4ec; color: var(--color-primary); }
|
||||||
|
.forum-sidebar__group a.is-active { background: var(--color-primary); color: var(--color-primary-contrast); }
|
||||||
|
.forum-sidebar__group small { font-size: 12px; opacity: .8; }
|
||||||
.forum-search { display: grid; gap: 8px; min-width: min(100%, 360px); }
|
.forum-search { display: grid; gap: 8px; min-width: min(100%, 360px); }
|
||||||
.forum-search--hero { width: 100%; }
|
.forum-search--hero { width: 100%; }
|
||||||
.forum-search__row { display: flex; gap: 10px; }
|
.forum-search__row { display: flex; gap: 10px; }
|
||||||
@@ -227,6 +240,7 @@ body {
|
|||||||
.forum-admin-item:first-child { border-top: 0; }
|
.forum-admin-item:first-child { border-top: 0; }
|
||||||
.forum-admin-item p { margin: 8px 0 0; }
|
.forum-admin-item p { margin: 8px 0 0; }
|
||||||
.forum-admin-item__actions { display: grid; gap: 10px; }
|
.forum-admin-item__actions { display: grid; gap: 10px; }
|
||||||
|
.forum-hero--compact { padding-bottom: 8px; }
|
||||||
|
|
||||||
.flex { display:flex; }
|
.flex { display:flex; }
|
||||||
.between { justify-content: space-between; }
|
.between { justify-content: space-between; }
|
||||||
@@ -239,6 +253,8 @@ body {
|
|||||||
.forum-admin-item,
|
.forum-admin-item,
|
||||||
.forum-list__header,
|
.forum-list__header,
|
||||||
.forum-row { grid-template-columns: minmax(0, 1fr); }
|
.forum-row { grid-template-columns: minmax(0, 1fr); }
|
||||||
|
.forum-shell { grid-template-columns: 1fr; }
|
||||||
|
.forum-sidebar { position: static; }
|
||||||
.forum-row__count,
|
.forum-row__count,
|
||||||
.forum-row__activity { grid-auto-flow: column; justify-content: start; gap: 10px; align-items: baseline; }
|
.forum-row__activity { grid-auto-flow: column; justify-content: start; gap: 10px; align-items: baseline; }
|
||||||
.forum-post { grid-template-columns: 1fr; }
|
.forum-post { grid-template-columns: 1fr; }
|
||||||
|
|||||||
4
public/page/community-admin.php
Normal file
4
public/page/community-admin.php
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
tpl('community-admin', 'landing', 'account');
|
||||||
Reference in New Issue
Block a user