ycxyxc
All checks were successful
Deploy / deploy (push) Successful in 1m3s

This commit is contained in:
2026-08-04 00:42:40 +02:00
parent fc34e87622
commit fa6e975df4
17 changed files with 701 additions and 3 deletions

View File

@@ -12,6 +12,9 @@ $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;
$systemSettings = $pdo ? new \App\SystemSettings($pdo) : null;
$forumMaintenanceMode = $systemSettings ? $systemSettings->getBool('forum_maintenance_mode') : false;
$isForumAdmin = ($access && $userId) ? $access->canModerateForum((int)$userId) : false;
$forumCategories = $community ? $community->listForumCategories() : [];
$selectedBoard = ($community && $boardSlug !== '') ? $community->getBoardBySlug($boardSlug) : null;
@@ -23,6 +26,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
if (!$userId) {
throw new \RuntimeException('Bitte einloggen, um Themen zu erstellen.');
}
if ($forumMaintenanceMode && !$isForumAdmin) {
throw new \RuntimeException('Die Community ist aktuell im Wartungsmodus. Neue Themen sind vorübergehend deaktiviert.');
}
if (!$access->canCreateThread((int)$userId)) {
$state = $access->getRestrictionState((int)$userId);
throw new \RuntimeException($state['reason'] ?: 'Du darfst aktuell keine Themen erstellen.');
@@ -67,8 +73,10 @@ $threads = $community
</div>
</form>
<div class="forum-hero__cta">
<?php if ($userId): ?>
<?php if ($userId && !$forumMaintenanceMode): ?>
<button class="btn" type="button" data-modal-open="modalThread">Neues Thema</button>
<?php elseif ($userId): ?>
<button class="btn ghost" type="button" disabled>Wartungsmodus aktiv</button>
<?php else: ?>
<a class="btn" href="/login">Einloggen und schreiben</a>
<?php endif; ?>
@@ -82,6 +90,11 @@ $threads = $community
<?php if ($info): ?>
<div class="toast-bar" style="margin-top:14px;"><?= htmlspecialchars($info, ENT_QUOTES) ?></div>
<?php endif; ?>
<?php if ($forumMaintenanceMode): ?>
<div class="toast-bar" style="margin-top:14px; border-color:#d4a857; color:#7c5a17;">
Die Community ist aktuell im Wartungsmodus. Lesen bleibt möglich, neue Themen und Antworten sind für normale Nutzer vorübergehend deaktiviert.
</div>
<?php endif; ?>
<?php if ($selectedBoard): ?>
<div class="forum-shell">
@@ -239,7 +252,7 @@ $threads = $community
</div>
</main>
<?php if ($userId): ?>
<?php if ($userId && !$forumMaintenanceMode): ?>
<div class="modal" id="modalThread">
<div class="panel">
<div class="head flex between center-y">

View File

@@ -12,6 +12,8 @@ $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;
$systemSettings = $pdo ? new \App\SystemSettings($pdo) : null;
$forumMaintenanceMode = $systemSettings ? $systemSettings->getBool('forum_maintenance_mode') : false;
$forumCategories = $community ? $community->listForumCategories() : [];
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
@@ -21,6 +23,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
if (!$userId) {
throw new \RuntimeException('Bitte einloggen, um zu antworten.');
}
if ($forumMaintenanceMode && !($access && $access->canModerateForum((int)$userId))) {
throw new \RuntimeException('Die Community ist aktuell im Wartungsmodus. Antworten sind vorübergehend deaktiviert.');
}
if (!$access->canReply((int)$userId)) {
$state = $access->getRestrictionState((int)$userId);
throw new \RuntimeException($state['reason'] ?: 'Du darfst aktuell nicht antworten.');
@@ -151,6 +156,11 @@ $userVotes = ($access && $userId) ? $access->getUserPostVotes((int)$userId, $pos
<?php if ($info): ?>
<div class="toast-bar" style="margin-bottom:14px;"><?= htmlspecialchars($info, ENT_QUOTES) ?></div>
<?php endif; ?>
<?php if ($forumMaintenanceMode): ?>
<div class="toast-bar" style="margin-bottom:14px; border-color:#d4a857; color:#7c5a17;">
Die Community ist aktuell im Wartungsmodus. Lesen bleibt möglich, neue Antworten nur für Admins.
</div>
<?php endif; ?>
<article class="forum-post forum-post--lead">
<aside class="forum-post__author">
@@ -290,7 +300,7 @@ $userVotes = ($access && $userId) ? $access->getUserPostVotes((int)$userId, $pos
<?php endif; ?>
</div>
<?php if ($userId): ?>
<?php if ($userId && !$forumMaintenanceMode): ?>
<?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: ?>
@@ -303,6 +313,8 @@ $userVotes = ($access && $userId) ? $access->getUserPostVotes((int)$userId, $pos
<button class="btn" type="submit">Antwort senden</button>
</form>
<?php endif; ?>
<?php elseif ($userId): ?>
<div class="forum-login-note">Die Community ist aktuell im Wartungsmodus. Antworten sind vorübergehend deaktiviert.</div>
<?php else: ?>
<div class="forum-login-note">Bitte <a href="/login">einloggen</a>, um zu antworten.</div>
<?php endif; ?>