This commit is contained in:
@@ -351,13 +351,15 @@ final class AccountPages
|
||||
$sourceCategorySlug,
|
||||
$targetCategorySlug
|
||||
);
|
||||
$info = 'Kategorie zusammengeführt.';
|
||||
$app->flash()->set('success', 'Kategorie zusammengeführt.');
|
||||
redirect('/dashboard?section=categories');
|
||||
} elseif ($action === 'category_confirm') {
|
||||
if (!$canManageCategories || !$listingCatalog) {
|
||||
throw new \RuntimeException('Keine Berechtigung für die Kategorien-Verwaltung.');
|
||||
}
|
||||
$listingCatalog->confirmCategory((string)($_POST['source_category_slug'] ?? ''));
|
||||
$info = 'Kategorie bestätigt.';
|
||||
$app->flash()->set('success', 'Kategorie bestätigt.');
|
||||
redirect('/dashboard?section=categories');
|
||||
} elseif ($action === 'child_add' || $action === 'child_update') {
|
||||
$crypto = self::requireCrypto($crypto, 'Kinder');
|
||||
$childId = (int)($_POST['child_id'] ?? 0);
|
||||
|
||||
@@ -385,7 +385,7 @@ final class ListingCatalog
|
||||
throw new \RuntimeException('Bitte zwei unterschiedliche Kategorien auswählen.');
|
||||
}
|
||||
|
||||
$lookup = $this->pdo->prepare('SELECT id, slug FROM listing_categories WHERE slug = :slug LIMIT 1');
|
||||
$lookup = $this->pdo->prepare('SELECT id, slug, title FROM listing_categories WHERE slug = :slug LIMIT 1');
|
||||
$lookup->execute(['slug' => $sourceSlug]);
|
||||
$source = $lookup->fetch(\PDO::FETCH_ASSOC);
|
||||
$lookup->execute(['slug' => $targetSlug]);
|
||||
@@ -396,6 +396,7 @@ final class ListingCatalog
|
||||
|
||||
$sourceId = (int)$source['id'];
|
||||
$targetId = (int)$target['id'];
|
||||
$sourceTitle = (string)($source['title'] ?? '');
|
||||
|
||||
$this->pdo->beginTransaction();
|
||||
try {
|
||||
@@ -420,7 +421,23 @@ final class ListingCatalog
|
||||
'target' => $targetSlug,
|
||||
'source' => $sourceSlug,
|
||||
]);
|
||||
$this->pdo->prepare('DELETE FROM listing_categories WHERE id = :id')->execute(['id' => $sourceId]);
|
||||
$deleteCategory = $this->pdo->prepare('DELETE FROM listing_categories WHERE id = :id');
|
||||
$deleteCategory->execute(['id' => $sourceId]);
|
||||
|
||||
$verifyStmt = $this->pdo->prepare(
|
||||
'SELECT COUNT(*)
|
||||
FROM listing_categories
|
||||
WHERE id = :id OR slug = :slug OR (LOWER(title) = LOWER(:title) AND id <> :targetId)'
|
||||
);
|
||||
$verifyStmt->execute([
|
||||
'id' => $sourceId,
|
||||
'slug' => $sourceSlug,
|
||||
'title' => $sourceTitle,
|
||||
'targetId' => $targetId,
|
||||
]);
|
||||
if ((int)$verifyStmt->fetchColumn() > 0) {
|
||||
throw new \RuntimeException('Die alte Kategorie konnte nicht vollständig entfernt werden.');
|
||||
}
|
||||
$this->pdo->commit();
|
||||
} catch (\Throwable $e) {
|
||||
if ($this->pdo->inTransaction()) {
|
||||
|
||||
Reference in New Issue
Block a user