Files
Wallos/includes/getsettings.php
Duc-Thomas f01685e0eb feat: Allow setting beginning of week as Sunday in calendar (#1010)
* Add week_starts_sunday setting functionality

- Implemented a new endpoint to update the week_starts_sunday setting.
- Modified the settings retrieval to include week_starts_sunday.
- Added translation for the week_starts_sunday label.
- Updated user creation to include week_starts_sunday in the settings.
- Created a migration to add week_starts_sunday column to the settings table.
- Updated registration and settings scripts to handle week_starts_sunday.
- Added a checkbox in the settings UI for users to set their preference for the week starting on Sunday.

* fix: validate week_starts_sunday input before reading it

---------

Co-authored-by: Miguel Ribeiro <k.d.mintnick@gmail.com>
2026-07-09 22:00:39 +02:00

64 lines
2.7 KiB
PHP

<?php
$query = "SELECT * FROM settings WHERE user_id = :userId";
$stmt = $db->prepare($query);
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
$result = $stmt->execute();
$settings = $result->fetchArray(SQLITE3_ASSOC);
if ($settings !== false) {
$themeMapping = array(0 => 'light', 1 => 'dark', 2 => 'automatic');
$themeKey = isset($settings['dark_theme']) ? $settings['dark_theme'] : 2;
$themeValue = $themeMapping[$themeKey];
$settings['update_theme_setttings'] = false;
if (isset($_COOKIE['inUseTheme']) && $settings['dark_theme'] == 2) {
$inUseTheme = $_COOKIE['inUseTheme'];
$settings['theme'] = $inUseTheme;
} else {
$settings['theme'] = $themeValue;
}
if ($themeValue == "automatic") {
$settings['update_theme_setttings'] = true;
}
$settings['color_theme'] = $settings['color_theme'] ? $settings['color_theme'] : "blue";
$settings['showMonthlyPrice'] = $settings['monthly_price'] ? 'true': 'false';
$settings['convertCurrency'] = $settings['convert_currency'] ? 'true': 'false';
$settings['removeBackground'] = $settings['remove_background'] ? 'true': 'false';
$settings['hideDisabledSubscriptions'] = $settings['hide_disabled'] ? 'true': 'false';
$settings['disabledToBottom'] = $settings['disabled_to_bottom'] ? 'true': 'false';
$settings['showOriginalPrice'] = $settings['show_original_price'] ? 'true': 'false';
$settings['mobileNavigation'] = $settings['mobile_nav'] ? 'true': 'false';
$settings['showSubscriptionProgress'] = $settings['show_subscription_progress'] ? 'true': 'false';
$settings['week_starts_sunday'] = isset($settings['week_starts_sunday']) ? $settings['week_starts_sunday'] : 0;
}
$query = "SELECT * FROM custom_colors WHERE user_id = :userId";
$stmt = $db->prepare($query);
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
$result = $stmt->execute();
$customColors = $result->fetchArray(SQLITE3_ASSOC);
if ($customColors !== false) {
$settings['customColors'] = $customColors;
}
$query = "SELECT * FROM custom_css_style WHERE user_id = :userId";
$stmt = $db->prepare($query);
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
$result = $stmt->execute();
$customCss = $result->fetchArray(SQLITE3_ASSOC);
if ($customCss !== false) {
$settings['customCss'] = $customCss['css'];
}
$query = "SELECT * FROM admin";
$result = $db->query($query);
$adminSettings = $result->fetchArray(SQLITE3_ASSOC);
if ($adminSettings !== false) {
$settings['disableLogin'] = $adminSettings['login_disabled'];
$settings['update_notification'] = $adminSettings['update_notification'];
$settings['latest_version'] = $adminSettings['latest_version'];
}
?>