This commit is contained in:
@@ -174,8 +174,21 @@ final class AccountPages
|
||||
$communityAccess = $pdo ? new CommunityAccess($pdo, $communityConfig) : null;
|
||||
$communityMigration = $pdo ? new CommunityMigration($pdo) : null;
|
||||
$profileSettings = $pdo ? new ProfileSettings($pdo) : null;
|
||||
$systemSettings = $pdo ? new SystemSettings($pdo) : null;
|
||||
$listingCatalog = $pdo ? new ListingCatalog($pdo) : null;
|
||||
$section = (string)($_GET['section'] ?? 'profile');
|
||||
$canManageSystemSettings = $communityAccess ? $communityAccess->canManageApplications($userId) : false;
|
||||
$allowedSections = ['profile', 'children', 'events', 'community', 'settings'];
|
||||
if ($canManageSystemSettings) {
|
||||
$allowedSections[] = 'system';
|
||||
}
|
||||
|
||||
if ($systemSettings) {
|
||||
$systemSettings->ensureSchema();
|
||||
}
|
||||
if ($listingCatalog) {
|
||||
$listingCatalog->ensureSchema();
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = $_POST['action'] ?? '';
|
||||
@@ -273,6 +286,26 @@ final class AccountPages
|
||||
);
|
||||
}
|
||||
$info = 'Einstellungen gespeichert.';
|
||||
} elseif ($action === 'system_settings_update') {
|
||||
if (!$canManageSystemSettings || !$systemSettings) {
|
||||
throw new \RuntimeException('Keine Berechtigung für die System-Einstellungen.');
|
||||
}
|
||||
$siteMaintenanceMessage = trim((string)($_POST['site_maintenance_message'] ?? ''));
|
||||
if ($siteMaintenanceMessage === '') {
|
||||
$siteMaintenanceMessage = 'Papa-Kind-Treff ist gerade kurz in Wartung. Bitte versuche es in Kürze erneut.';
|
||||
}
|
||||
$placeDataProvider = (string)($_POST['place_data_provider'] ?? 'osm');
|
||||
if (!in_array($placeDataProvider, ['osm', 'osm_google_optional'], true)) {
|
||||
$placeDataProvider = 'osm';
|
||||
}
|
||||
$systemSettings->updateMany([
|
||||
'google_places_enabled' => isset($_POST['google_places_enabled']) ? '1' : '0',
|
||||
'forum_maintenance_mode' => isset($_POST['forum_maintenance_mode']) ? '1' : '0',
|
||||
'site_maintenance_mode' => isset($_POST['site_maintenance_mode']) ? '1' : '0',
|
||||
'site_maintenance_message' => $siteMaintenanceMessage,
|
||||
'place_data_provider' => $placeDataProvider,
|
||||
], $userId);
|
||||
$info = 'System-Einstellungen gespeichert.';
|
||||
} elseif ($action === 'child_add' || $action === 'child_update') {
|
||||
$crypto = self::requireCrypto($crypto, 'Kinder');
|
||||
$childId = (int)($_POST['child_id'] ?? 0);
|
||||
@@ -588,6 +621,8 @@ final class AccountPages
|
||||
'reply_blocked' => false,
|
||||
'reason' => null,
|
||||
];
|
||||
$systemSettingsValues = $systemSettings ? $systemSettings->getAll() : [];
|
||||
$listingCatalogStatus = $listingCatalog ? $listingCatalog->status() : ['complete' => false, 'missing' => [], 'tables' => []];
|
||||
if (!in_array($section, $allowedSections, true)) {
|
||||
$section = 'profile';
|
||||
}
|
||||
@@ -609,6 +644,9 @@ final class AccountPages
|
||||
'communityApplication',
|
||||
'communityCanApply',
|
||||
'communityRestrictions',
|
||||
'canManageSystemSettings',
|
||||
'systemSettingsValues',
|
||||
'listingCatalogStatus',
|
||||
'avatarBuilder',
|
||||
'section',
|
||||
'allowedSections'
|
||||
|
||||
Reference in New Issue
Block a user