"MenĂ¼ anpassen", * assets/js/sidebar-editor.js). Antwortet als JSON. */ require_once __DIR__ . '/includes/bootstrap.php'; require_login(); header('Content-Type: application/json; charset=UTF-8'); if ($_SERVER['REQUEST_METHOD'] !== 'POST') { http_response_code(405); echo json_encode(['ok' => false]); exit; } verify_csrf(); $userId = (int) current_user()['id']; if (!empty($_POST['reset'])) { db()->prepare('UPDATE users SET sidebar_order = NULL WHERE id = ?')->execute([$userId]); echo json_encode(['ok' => true]); exit; } /** Nur bekannte Menuepunkte, jeder hoechstens einmal. */ $clean = static function ($keys, array $allowed): array { $keys = array_values(array_unique(array_filter((array) $keys, 'is_string'))); return array_values(array_filter($keys, static fn (string $key): bool => in_array($key, $allowed, true))); }; $order = [ 'main' => $clean($_POST['main'] ?? [], SIDEBAR_NAV_MAIN), 'admin' => $clean($_POST['admin'] ?? [], SIDEBAR_NAV_ADMIN), ]; db()->prepare('UPDATE users SET sidebar_order = ? WHERE id = ?') ->execute([json_encode($order, JSON_UNESCAPED_SLASHES), $userId]); echo json_encode(['ok' => true]);