WebOrbiton
v1.0.0.9

Publisium

25 lines · 583 B
  1. <?php
  2. ​
  3. declare(strict_types=1);
  4. ​
  5. if (!Auth::hasRoleAtLeast(Auth::ROLE_EDITOR_IN_CHIEF)) {
  6. return;
  7. }
  8. ​
  9. $db = Database::site();
  10. ​
  11. $categoryId = (int) ($_POST['category_id'] ?? 0);
  12. ​
  13. if ($categoryId <= 0) {
  14. return;
  15. }
  16. ​
  17. $statement = $db->prepare('UPDATE categories SET show_in_menu = NOT show_in_menu WHERE id = :id');
  18. $statement->execute(['id' => $categoryId]);
  19. ​
  20. $state = $db->prepare('SELECT show_in_menu FROM categories WHERE id = :id');
  21. $state->execute(['id' => $categoryId]);
  22. if ((int) $state->fetchColumn() === 1) {
  23. SiteFront::appendToCustomNav('category', $categoryId);
  24. }
  25. ​