v1.0.0.6
Publisium
- <?php
-
- declare(strict_types=1);
-
- if (!Auth::hasRoleAtLeast(Auth::ROLE_EDITOR_IN_CHIEF)) {
- return;
- }
-
- $db = Database::site();
-
- $categoryId = (int) ($_POST['category_id'] ?? 0);
-
- if ($categoryId <= 0) {
- return;
- }
-
- $clearArticles = $db->prepare('UPDATE articles SET category_id = NULL WHERE category_id = :id');
- $clearArticles->execute(['id' => $categoryId]);
-
- $clearChildren = $db->prepare('UPDATE categories SET parent_id = NULL WHERE parent_id = :id');
- $clearChildren->execute(['id' => $categoryId]);
-
- $deleteCategory = $db->prepare('DELETE FROM categories WHERE id = :id');
- $deleteCategory->execute(['id' => $categoryId]);
-