['name' => 'announcement', 'label' => t('system_announcements'), 'description' => t('system_announcements_desc')], 2 => ['name' => 'tips', 'label' => t('usage_tips'), 'description' => t('usage_tips_desc')], 3 => ['name' => 'feedback_result', 'label' => t('feedback_results'), 'description' => t('feedback_results_desc')], 4 => ['name' => 'image_feedback', 'label' => t('image_feedback'), 'description' => t('image_feedback_desc')] ]; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $dark_mode = isset($_POST['dark_mode']) ? 1 : 0; $language = $_POST['language'] ?? 'zh-CN'; $items_per_page = intval($_POST['items_per_page'] ?? 20); $email_notifications = isset($_POST['email_notifications']) ? 1 : 0; $browser_notifications = isset($_POST['browser_notifications']) ? 1 : 0; $notification_settings = []; foreach ($notificationTypes as $type_id => $type) { $notification_settings[$type_id] = isset($_POST['notification_' . $type_id]); } if ($items_per_page < 5 || $items_per_page > 100) { $error = t('items_per_page_range_error'); } else { $newSettings = [ 'dark_mode' => $dark_mode, 'language' => $language, 'items_per_page' => $items_per_page, 'email_notifications' => $email_notifications, 'browser_notifications' => $browser_notifications ]; if (updateUserSettings($_SESSION['user_id'], $newSettings) && updateUserNotificationSettings($_SESSION['user_id'], $notification_settings)) { $success = t('settings_saved'); $userSettings = $newSettings; $notificationSettings = $notification_settings; $_SESSION['language'] = $language; } else { $error = t('save_failed'); } } } ?>