v1.0.0.0
StocketBase
- <?php
-
- declare(strict_types=1);
-
- if (count(get_included_files()) === 1) {
- http_response_code(403);
- exit;
- }
-
- if (!Auth::hasRoleAtLeast(Auth::ROLE_STORE_OWNER)) {
- return;
- }
-
- $db = Database::site();
-
- $categoryId = (int) ($_POST['category_id'] ?? 0);
-
- if ($categoryId <= 0) {
- return;
- }
-
- $statement = $db->prepare('UPDATE categories SET show_in_menu = NOT show_in_menu WHERE id = :id');
- $statement->execute(['id' => $categoryId]);
-
- $current = $db->prepare('SELECT show_in_menu FROM categories WHERE id = :id LIMIT 1');
- $current->execute(['id' => $categoryId]);
- if ((int) $current->fetchColumn() === 1) {
- SiteFront::appendToCustomMenu('category', $categoryId);
- }
-