This commit is contained in:
@@ -276,7 +276,7 @@ if ($isAdminArea && !empty($canManageSystemSettings)) {
|
|||||||
<p class="muted small">Eingereicht von <?= htmlspecialchars((string)($request['requested_by_name'] ?: 'Mitglied'), ENT_QUOTES) ?>.</p>
|
<p class="muted small">Eingereicht von <?= htmlspecialchars((string)($request['requested_by_name'] ?: 'Mitglied'), ENT_QUOTES) ?>.</p>
|
||||||
<div class="flex gap-12" style="flex-wrap:wrap; margin:14px 0;"><a class="btn ghost" href="/dashboard?area=admin&section=listing-review&edit_listing=<?= (int)$request['listing_id'] ?>">Bearbeiten</a></div>
|
<div class="flex gap-12" style="flex-wrap:wrap; margin:14px 0;"><a class="btn ghost" href="/dashboard?area=admin&section=listing-review&edit_listing=<?= (int)$request['listing_id'] ?>">Bearbeiten</a></div>
|
||||||
<form method="post" class="stack gap-8">
|
<form method="post" class="stack gap-8">
|
||||||
<input type="hidden" name="action" value="listing_request_decide"><input type="hidden" name="request_id" value="<?= (int)$request['id'] ?>">
|
<input type="hidden" name="action" value="pending_listing_decide"><input type="hidden" name="listing_id" value="<?= (int)$request['listing_id'] ?>">
|
||||||
<textarea name="review_note" class="textarea" rows="2" placeholder="Hinweis für die Entscheidung"></textarea>
|
<textarea name="review_note" class="textarea" rows="2" 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>
|
<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>
|
</form>
|
||||||
|
|||||||
@@ -722,6 +722,12 @@ final class AccountPages
|
|||||||
}
|
}
|
||||||
$listingCatalog->decideModerationRequest($userId, (int)($_POST['request_id'] ?? 0), (string)($_POST['decision'] ?? ''), (string)($_POST['review_note'] ?? ''));
|
$listingCatalog->decideModerationRequest($userId, (int)($_POST['request_id'] ?? 0), (string)($_POST['decision'] ?? ''), (string)($_POST['review_note'] ?? ''));
|
||||||
$info = 'Ort oder Veranstaltung wurde bearbeitet.';
|
$info = 'Ort oder Veranstaltung wurde bearbeitet.';
|
||||||
|
} elseif ($action === 'pending_listing_decide') {
|
||||||
|
if (!$canReviewListings || !$listingCatalog) {
|
||||||
|
throw new \RuntimeException('Keine Berechtigung für Listing-Freigaben.');
|
||||||
|
}
|
||||||
|
$listingCatalog->decidePendingApproval($userId, (int)($_POST['listing_id'] ?? 0), (string)($_POST['decision'] ?? ''), (string)($_POST['review_note'] ?? ''));
|
||||||
|
$info = 'Ort oder Veranstaltung wurde bearbeitet.';
|
||||||
} elseif ($action === 'application_decide') {
|
} elseif ($action === 'application_decide') {
|
||||||
if (!$canManageSystemSettings || !$communityAccess) {
|
if (!$canManageSystemSettings || !$communityAccess) {
|
||||||
throw new \RuntimeException('Keine Berechtigung für Bewerbungen.');
|
throw new \RuntimeException('Keine Berechtigung für Bewerbungen.');
|
||||||
@@ -1059,7 +1065,7 @@ final class AccountPages
|
|||||||
$communityRoles = $communityAccess ? $communityAccess->getUserRoles($userId) : [];
|
$communityRoles = $communityAccess ? $communityAccess->getUserRoles($userId) : [];
|
||||||
$systemRoleAssignments = $communityAccess && $canManageUserManagement ? $communityAccess->listRoleAssignments() : [];
|
$systemRoleAssignments = $communityAccess && $canManageUserManagement ? $communityAccess->listRoleAssignments() : [];
|
||||||
$listingReviewRequests = $canReviewListings && $listingCatalog
|
$listingReviewRequests = $canReviewListings && $listingCatalog
|
||||||
? array_values(array_filter($listingCatalog->listOpenModerationRequests(), static fn(array $request): bool => (string)($request['request_type'] ?? '') === 'create'))
|
? $listingCatalog->listPendingApprovalEntries()
|
||||||
: [];
|
: [];
|
||||||
$communityApplications = $canManageSystemSettings && $communityAccess ? $communityAccess->listApplications('open') : [];
|
$communityApplications = $canManageSystemSettings && $communityAccess ? $communityAccess->listApplications('open') : [];
|
||||||
$communityReports = $canModerateForum && $communityAccess && $communityAccess->supportsReports() ? $communityAccess->listOpenReports() : [];
|
$communityReports = $canModerateForum && $communityAccess && $communityAccess->supportsReports() ? $communityAccess->listOpenReports() : [];
|
||||||
|
|||||||
@@ -893,6 +893,61 @@ final class ListingCatalog
|
|||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function listPendingApprovalEntries(): array
|
||||||
|
{
|
||||||
|
$this->ensureSchema();
|
||||||
|
$stmt = $this->pdo->query(
|
||||||
|
'SELECT l.id AS listing_id, l.title, l.listing_type, l.status AS listing_status,
|
||||||
|
lp.street, lp.zip, lp.city, lp.region,
|
||||||
|
up.display_name AS requested_by_name,
|
||||||
|
mr.id AS moderation_request_id
|
||||||
|
FROM listings l
|
||||||
|
LEFT JOIN listing_places lp ON lp.id = l.primary_place_id
|
||||||
|
LEFT JOIN user_profiles up ON up.user_id = l.created_by
|
||||||
|
LEFT JOIN listing_moderation_requests mr
|
||||||
|
ON mr.id = (
|
||||||
|
SELECT sub.id
|
||||||
|
FROM listing_moderation_requests sub
|
||||||
|
WHERE sub.listing_id = l.id
|
||||||
|
AND sub.request_type = "create"
|
||||||
|
AND sub.request_status = "open"
|
||||||
|
ORDER BY sub.created_at ASC, sub.id ASC
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
|
WHERE l.listing_type IN ("place", "editorial_event")
|
||||||
|
AND l.status = "draft"
|
||||||
|
ORDER BY l.created_at ASC, l.id ASC'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $stmt ? ($stmt->fetchAll(\PDO::FETCH_ASSOC) ?: []) : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function decidePendingApproval(int $reviewerUserId, int $listingId, string $decision, ?string $reviewNote = null): void
|
||||||
|
{
|
||||||
|
$this->ensureSchema();
|
||||||
|
$entry = $this->getMemberEntry($listingId);
|
||||||
|
if (!$entry || (string)($entry['status'] ?? '') === 'published') {
|
||||||
|
throw new \RuntimeException('Eintrag nicht gefunden oder bereits veröffentlicht.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $this->pdo->prepare(
|
||||||
|
'SELECT id
|
||||||
|
FROM listing_moderation_requests
|
||||||
|
WHERE listing_id = :listingId
|
||||||
|
AND request_type = "create"
|
||||||
|
AND request_status = "open"
|
||||||
|
ORDER BY created_at ASC, id ASC
|
||||||
|
LIMIT 1'
|
||||||
|
);
|
||||||
|
$stmt->execute(['listingId' => $listingId]);
|
||||||
|
$requestId = (int)($stmt->fetchColumn() ?: 0);
|
||||||
|
if ($requestId <= 0) {
|
||||||
|
$requestId = $this->createModerationRequest($listingId, 'create', (int)($entry['created_by'] ?? 0), null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->decideModerationRequest($reviewerUserId, $requestId, $decision, $reviewNote);
|
||||||
|
}
|
||||||
|
|
||||||
public function decideModerationRequest(int $reviewerUserId, int $requestId, string $decision, ?string $reviewNote = null): void
|
public function decideModerationRequest(int $reviewerUserId, int $requestId, string $decision, ?string $reviewNote = null): void
|
||||||
{
|
{
|
||||||
$this->ensureSchema();
|
$this->ensureSchema();
|
||||||
|
|||||||
Reference in New Issue
Block a user