= htmlspecialchars((string)$board['title'], ENT_QUOTES) ?>
= htmlspecialchars((string)$board['description'], ENT_QUOTES) ?>
pdo();
$userId = $_SESSION['user_id'] ?? null;
$error = '';
$info = '';
$search = trim((string)($_GET['q'] ?? ''));
$boardSlug = trim((string)($_GET['board'] ?? ''));
$communityCfg = require __DIR__ . '/../../../config/community.php';
$community = $pdo ? new \App\Community($pdo, $communityCfg) : null;
$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'] ?? '');
try {
if ($action === 'thread_create') {
if (!$userId) {
throw new \RuntimeException('Bitte einloggen, um Themen zu erstellen.');
}
if (!$access->canCreateThread((int)$userId)) {
$state = $access->getRestrictionState((int)$userId);
throw new \RuntimeException($state['reason'] ?: 'Du darfst aktuell keine Themen erstellen.');
}
$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();
}
}
$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() : [];
?>
Fragen stellen, Erfahrungen teilen, Antworten finden und gemeinsam weiterdenken. = htmlspecialchars((string)$board['description'], ENT_QUOTES) ?>
= htmlspecialchars($selectedBoard['description'] ?? 'Hier siehst du die zuletzt erstellten oder zuletzt aktiven Themen aus der Community.', ENT_QUOTES) ?>
= nl2br(htmlspecialchars($preview, ENT_QUOTES)) ?>= mb_strlen((string)$t['body']) > 220 ? '…' : '' ?> Bewerbungen ab Rang Community-Vater prüfen. = nl2br(htmlspecialchars((string)$application['motivation'], ENT_QUOTES)) ?> Gemeldete Inhalte prüfen und moderieren. = nl2br(htmlspecialchars((string)$report['reason'], ENT_QUOTES)) ?> Gemeldet von = htmlspecialchars((string)($report['reporter_name'] ?: 'Mitglied'), ENT_QUOTES) ?> am = htmlspecialchars((string)$report['created_at'], ENT_QUOTES) ?> Vergebene Community-Rollen im Blick behalten. Rolle: = htmlspecialchars((string)$assignment['role'], ENT_QUOTES) ?> · seit = htmlspecialchars((string)$assignment['assigned_at'], ENT_QUOTES) ?>Community
= htmlspecialchars((string)$board['title'], ENT_QUOTES) ?>
= htmlspecialchars($selectedBoard['title'] ?? 'Neueste Themen', ENT_QUOTES) ?>
= htmlspecialchars((string)$t['title'], ENT_QUOTES) ?>
Offene Bewerbungen
Offene Meldungen
Rollenübersicht