This commit is contained in:
@@ -12,6 +12,7 @@ if (!$userId) {
|
||||
$communityCfg = require __DIR__ . '/../../../config/community.php';
|
||||
$access = $pdo ? new \App\CommunityAccess($pdo, $communityCfg) : null;
|
||||
$migration = $pdo ? new \App\CommunityMigration($pdo) : null;
|
||||
$listingCatalog = $pdo ? new \App\ListingCatalog($pdo) : null;
|
||||
|
||||
if (!$access || !$access->canModerateForum((int)$userId)) {
|
||||
http_response_code(403);
|
||||
@@ -23,11 +24,18 @@ $error = '';
|
||||
$info = '';
|
||||
$canManageApplications = $access->canManageApplications((int)$userId) && $access->supportsApplications();
|
||||
$canManageRoles = $access->canManageRoles((int)$userId);
|
||||
$canReviewListings = $listingCatalog !== null && !$access->hasRole((int)$userId, 'owner');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = (string)($_POST['action'] ?? '');
|
||||
try {
|
||||
if ($action === 'application_decide') {
|
||||
if ($action === 'listing_request_decide') {
|
||||
if (!$canReviewListings || !$listingCatalog) {
|
||||
throw new \RuntimeException('Keine Berechtigung für Listing-Freigaben.');
|
||||
}
|
||||
$listingCatalog->decideModerationRequest((int)$userId, (int)($_POST['request_id'] ?? 0), (string)($_POST['decision'] ?? ''), (string)($_POST['review_note'] ?? ''));
|
||||
$info = 'Listing-Anfrage wurde bearbeitet.';
|
||||
} 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') {
|
||||
@@ -51,6 +59,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
}
|
||||
|
||||
$listingRequests = $canReviewListings && $listingCatalog ? $listingCatalog->listOpenModerationRequests() : [];
|
||||
$applications = $canManageApplications ? $access->listApplications('open') : [];
|
||||
$reports = $access->supportsReports() ? $access->listOpenReports() : [];
|
||||
$roleAssignments = $canManageRoles ? $access->listRoleAssignments() : [];
|
||||
@@ -84,6 +93,70 @@ $migrationStatus = ($migration && $canManageApplications) ? $migration->status()
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="forum-admin-grid">
|
||||
<?php if ($canReviewListings): ?>
|
||||
<section class="forum-board">
|
||||
<div class="forum-board__head">
|
||||
<div>
|
||||
<h2>Offene Orts- und Veranstaltungsanfragen</h2>
|
||||
<p class="muted">Neue Einträge sowie Änderungs- und Löschwünsche prüfen.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="forum-admin-list">
|
||||
<?php foreach ($listingRequests as $request): ?>
|
||||
<?php
|
||||
$payload = is_array($request['payload'] ?? null) ? $request['payload'] : [];
|
||||
$requestTypeLabel = match ((string)($request['request_type'] ?? '')) {
|
||||
'create' => 'Neu',
|
||||
'update' => 'Änderung',
|
||||
'delete' => 'Löschung',
|
||||
default => 'Anfrage',
|
||||
};
|
||||
?>
|
||||
<article class="forum-admin-item">
|
||||
<div>
|
||||
<strong><?= htmlspecialchars((string)$requestTypeLabel, ENT_QUOTES) ?> · <?= htmlspecialchars((string)$request['title'], ENT_QUOTES) ?></strong>
|
||||
<p class="muted small">Typ: <?= htmlspecialchars((string)(($request['listing_type'] ?? '') === 'place' ? 'Ort' : 'Veranstaltung'), ENT_QUOTES) ?> · Von <?= htmlspecialchars((string)($request['requested_by_name'] ?: 'Mitglied'), ENT_QUOTES) ?> · am <?= htmlspecialchars((string)$request['created_at'], ENT_QUOTES) ?></p>
|
||||
<?php if (!empty($request['request_reason'])): ?>
|
||||
<p><strong>Begründung:</strong><br><?= nl2br(htmlspecialchars((string)$request['request_reason'], ENT_QUOTES)) ?></p>
|
||||
<?php endif; ?>
|
||||
<p class="muted small">
|
||||
<?= htmlspecialchars(trim(implode(' · ', array_filter([
|
||||
trim(implode(', ', array_filter([
|
||||
(string)($request['street'] ?? ''),
|
||||
trim((string)($request['zip'] ?? '') . ' ' . (string)($request['city'] ?? '')),
|
||||
]))),
|
||||
(string)($request['region'] ?? ''),
|
||||
]))), ENT_QUOTES) ?>
|
||||
</p>
|
||||
<?php if ($payload !== []): ?>
|
||||
<div class="muted small" style="margin-top:8px;">
|
||||
Vorgeschlagener Titel: <?= htmlspecialchars((string)($payload['title'] ?? $request['title']), ENT_QUOTES) ?><br>
|
||||
Vorgeschlagene Adresse: <?= htmlspecialchars(trim(implode(', ', array_filter([
|
||||
(string)($payload['street'] ?? ''),
|
||||
trim((string)($payload['zip'] ?? '') . ' ' . (string)($payload['city'] ?? '')),
|
||||
(string)($payload['region'] ?? ''),
|
||||
]))), ENT_QUOTES) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<form method="post" class="forum-admin-item__actions">
|
||||
<input type="hidden" name="action" value="listing_request_decide">
|
||||
<input type="hidden" name="request_id" value="<?= (int)$request['id'] ?>">
|
||||
<textarea name="review_note" class="textarea" rows="3" placeholder="Hinweis für die Entscheidung"></textarea>
|
||||
<div class="flex gap-12">
|
||||
<button class="btn" type="submit" name="decision" value="approved">Freigeben</button>
|
||||
<button class="btn ghost" type="submit" name="decision" value="rejected">Ablehnen</button>
|
||||
</div>
|
||||
</form>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!$listingRequests): ?>
|
||||
<div class="forum-empty">Keine offenen Orts- oder Veranstaltungsanfragen.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canManageApplications): ?>
|
||||
<section class="forum-board">
|
||||
<div class="forum-board__head">
|
||||
|
||||
Reference in New Issue
Block a user