prepare('SELECT * FROM users WHERE id = :id AND is_active = 1 LIMIT 1');␊ $stmt->execute([':id' => (int) $userId]);␊ $row = $stmt->fetch(PDO::FETCH_ASSOC);␊ return $row ?: null;␊ }␊ ␊ function current_restaurant_id(): ?int␊ {␊ $restaurantId = $_SESSION['restaurant_id'] ?? null;␊ return is_numeric($restaurantId) ? (int) $restaurantId : null;␊ }␊ ␊ function is_manager(): bool { $user = current_user();␊ $restaurantId = current_restaurant_id();␊ if (!$user || !$restaurantId) {␊ return false;␊ }␊ $pdo = schedule_get_pdo();␊ if (!$pdo instanceof PDO) {␊ return false;␊ }␊ $stmt = $pdo->prepare('SELECT role FROM user_restaurants WHERE user_id = :user_id AND restaurant_id = :restaurant_id AND is_active = 1 LIMIT 1');␊ $stmt->execute([␊ ':user_id' => (int) $user['id'],␊ ':restaurant_id' => $restaurantId,␊ ]);␊ $role = $stmt->fetchColumn();␊ $normalizedRole = function_exists('schedule_normalize_role')␊ ? schedule_normalize_role($role)␊ : strtolower((string) $role);␊ return in_array($normalizedRole, ['owner', 'manager'], true);␊ }␊ ␊ function require_login(): void␊ {␊ $user = current_user();␊ $restaurantId = current_restaurant_id();␊ ␊ // 1. Fully authenticated␊ if ($user && $restaurantId) {␊ return;␊ }␊ ␊ // 2. Allow Preview Mode (New Logic)␊ if (defined('SCHEDULE_PREVIEW_MODE') && SCHEDULE_PREVIEW_MODE === true) {␊ return;␊ }␊ ␊ // 3. Redirect to login␊ $next = urlencode($_SERVER['REQUEST_URI'] ?? '/schedule/index.php');␊ header('Location: /auth/login.php?next=' . $next);␊ exit;␊ }␊ ␊ function require_manager(): void␊ {␊ if (!is_manager()) {␊ header('Location: /403.php');␊ exit;␊ }␊ }
Fatal error: Uncaught Error: Call to undefined function require_login() in /home/hospneac/hospiedge.org/my.php:20 Stack trace: #0 {main} thrown in /home/hospneac/hospiedge.org/my.php on line 20