/home/techb158/workloadmatch.com/api/routes
NameSizeModeActions
ai_generate.php116420644editdlrm
assignments.php99310644editdlrm
auth.php66970644editdlrm
chat.php99340644editdlrm
courses.php72250644editdlrm
coursesessions.php67050644editdlrm
dashboard.php62320644editdlrm
groups.php110990644editdlrm
logs.php35870644editdlrm
managers.php96120644editdlrm
masters.php66850644editdlrm
notifications.php59750644editdlrm
preferences.php64870644editdlrm
programs.php48820644editdlrm
reports.php136960644editdlrm
roles.php85160644editdlrm
schedules.php110420644editdlrm
settings.php42950644editdlrm
teachers.php160130644editdlrm
timeslots.php48070644editdlrm
Edit: /home/techb158/workloadmatch.com/api/routes/settings.php (4295B)
'WorkloadMatch', 'app_version' => '1.0.0', 'php_version' => PHP_VERSION, 'db_host' => HOST, 'db_name' => DATABASE, 'secure' => (bool)SECURE, 'timezone' => date_default_timezone_get(), 'date_format' => 'Y-m-d', 'time_format' => 'H:i:s', ]; // Get page control settings $r = $mysqli->query("SELECT * FROM pages_control ORDER BY module, page_name"); $data['pages'] = $r->fetch_all(MYSQLI_ASSOC); $r->close(); Response::success($data); } function getSetting(string $id, mysqli $mysqli): void { Auth::requireRole('admin_profile'); if ($id === 'page' && !empty($_GET['key'])) { $stmt = $mysqli->prepare("SELECT * FROM pages_control WHERE page_key = ? LIMIT 1"); $stmt->bind_param('s', $_GET['key']); $stmt->execute(); $result = $stmt->get_result(); $item = $result->fetch_assoc(); $stmt->close(); if (!$item) Response::notFound('Page setting not found'); Response::success($item); } Response::notFound("Setting: $id"); } function updateSetting(?string $id, ?array $body, mysqli $mysqli): void { Auth::requireRole('admin_profile'); if ($id === 'password-policy') { // Placeholder for password policy settings Response::success(null, 'Settings updated'); } if ($id === 'page' && !empty($_GET['key']) && isset($body['status'])) { $stmt = $mysqli->prepare("UPDATE pages_control SET status = ? WHERE page_key = ?"); $stmt->bind_param('is', $body['status'], $_GET['key']); $stmt->execute(); $stmt->close(); log_activity($mysqli, 'update', 'page_settings', 0, "Page {$_GET['key']} status changed", 'Page setting updated via API'); Response::success(null, 'Page setting updated'); } Response::notFound("Setting: $id"); } function listPageSettings(mysqli $mysqli): void { Auth::requireAnyRole(['admin_profile', 'master_profile']); $module = $_GET['module'] ?? null; $wheres = []; $params = []; $types = ''; if ($module) { $wheres[] = 'module = ?'; $params[] = $module; $types .= 's'; } $whereClause = $wheres ? 'WHERE ' . implode(' AND ', $wheres) : ''; $stmt = $mysqli->prepare("SELECT * FROM pages_control $whereClause ORDER BY module, page_name"); if ($params) $stmt->bind_param($types, ...$params); $stmt->execute(); $result = $stmt->get_result(); $items = $result->fetch_all(MYSQLI_ASSOC); $stmt->close(); Response::success($items); } function updatePageSettings(?array $body, mysqli $mysqli): void { Auth::requireRole('admin_profile'); if (!$body || !isset($body['pages']) || !is_array($body['pages'])) { Response::validationError(['pages' => 'Array of page settings required']); } $updated = 0; foreach ($body['pages'] as $page) { if (!isset($page['page_key'], $page['status'])) continue; $stmt = $mysqli->prepare("UPDATE pages_control SET status = ? WHERE page_key = ?"); $stmt->bind_param('is', $page['status'], $page['page_key']); $stmt->execute(); if ($stmt->affected_rows > 0) $updated++; $stmt->close(); } log_activity($mysqli, 'update', 'page_settings', 0, "Updated $updated page settings", 'Bulk page update via API'); Response::success(null, "Updated $updated page setting(s)"); }