This commit is contained in:
@@ -722,6 +722,12 @@ final class AccountPages
|
||||
}
|
||||
$listingCatalog->decideModerationRequest($userId, (int)($_POST['request_id'] ?? 0), (string)($_POST['decision'] ?? ''), (string)($_POST['review_note'] ?? ''));
|
||||
$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') {
|
||||
if (!$canManageSystemSettings || !$communityAccess) {
|
||||
throw new \RuntimeException('Keine Berechtigung für Bewerbungen.');
|
||||
@@ -1059,7 +1065,7 @@ final class AccountPages
|
||||
$communityRoles = $communityAccess ? $communityAccess->getUserRoles($userId) : [];
|
||||
$systemRoleAssignments = $communityAccess && $canManageUserManagement ? $communityAccess->listRoleAssignments() : [];
|
||||
$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') : [];
|
||||
$communityReports = $canModerateForum && $communityAccess && $communityAccess->supportsReports() ? $communityAccess->listOpenReports() : [];
|
||||
|
||||
@@ -893,6 +893,61 @@ final class ListingCatalog
|
||||
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
|
||||
{
|
||||
$this->ensureSchema();
|
||||
|
||||
Reference in New Issue
Block a user