This commit is contained in:
@@ -183,6 +183,7 @@ final class AccountPages
|
||||
$allowedSections = ['profile', 'children', 'events', 'places', 'community', 'settings'];
|
||||
if ($canManageSystemSettings) {
|
||||
$allowedSections[] = 'system';
|
||||
$allowedSections[] = 'categories';
|
||||
}
|
||||
if ($canManageProfileLevels) {
|
||||
$allowedSections[] = 'profile-levels';
|
||||
@@ -328,9 +329,13 @@ final class AccountPages
|
||||
if (!$canManageSystemSettings || !$listingCatalog) {
|
||||
throw new \RuntimeException('Keine Berechtigung für die Kategorien-Verwaltung.');
|
||||
}
|
||||
$targetCategorySlug = $listingCatalog->resolveExistingCategorySlug((string)($_POST['target_category_input'] ?? ''));
|
||||
if ($targetCategorySlug === null) {
|
||||
throw new \RuntimeException('Bitte wähle eine vorhandene Zielkategorie aus den Vorschlägen.');
|
||||
}
|
||||
$listingCatalog->mergeCategories(
|
||||
(string)($_POST['source_category_slug'] ?? ''),
|
||||
(string)($_POST['target_category_slug'] ?? '')
|
||||
$targetCategorySlug
|
||||
);
|
||||
$info = 'Kategorie zusammengeführt.';
|
||||
} elseif ($action === 'child_add' || $action === 'child_update') {
|
||||
@@ -852,7 +857,10 @@ final class AccountPages
|
||||
$restoreEventDraftActive = $section === 'events' && ((string)($_GET['restore_event_draft'] ?? '')) === '1' && self::hasStoredEventDraft();
|
||||
$restoredEventDraft = $restoreEventDraftActive ? self::getStoredEventDraft() : null;
|
||||
$listingCategories = $listingCatalog ? $listingCatalog->listCategories(['general', 'place', 'food', 'event', 'family']) : [];
|
||||
$categoryReviewItems = $listingCatalog && $canManageSystemSettings ? $listingCatalog->listCategoryReviewItems() : [];
|
||||
$categoryReviewItems = $listingCatalog && $canManageSystemSettings ? array_values(array_filter(
|
||||
$listingCatalog->listCategoryReviewItems(),
|
||||
static fn(array $item): bool => !empty($item['needs_review'])
|
||||
)) : [];
|
||||
$placeSuggestions = $listingCatalog ? $listingCatalog->listPlaceSuggestions(60) : [];
|
||||
$eventLocationOptions = $listingCatalog ? $listingCatalog->listEventLocationOptions(120) : [];
|
||||
$stmt = $pdo?->prepare(
|
||||
|
||||
@@ -368,6 +368,29 @@ final class ListingCatalog
|
||||
}
|
||||
}
|
||||
|
||||
public function resolveExistingCategorySlug(string $input): ?string
|
||||
{
|
||||
$this->ensureSchema();
|
||||
$input = trim($input);
|
||||
if ($input === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$stmt = $this->pdo->prepare(
|
||||
'SELECT slug
|
||||
FROM listing_categories
|
||||
WHERE slug = :slug OR LOWER(title) = LOWER(:title)
|
||||
ORDER BY sort_order ASC, id ASC
|
||||
LIMIT 1'
|
||||
);
|
||||
$stmt->execute([
|
||||
'slug' => $input,
|
||||
'title' => $input,
|
||||
]);
|
||||
$slug = $stmt->fetchColumn();
|
||||
return $slug !== false ? (string)$slug : null;
|
||||
}
|
||||
|
||||
public function listPublishedDirectoryEntries(): array
|
||||
{
|
||||
$this->ensureSchema();
|
||||
|
||||
Reference in New Issue
Block a user