This commit is contained in:
@@ -309,6 +309,15 @@ final class AccountPages
|
||||
'place_data_provider' => $placeDataProvider,
|
||||
], $userId);
|
||||
$info = 'System-Einstellungen gespeichert.';
|
||||
} elseif ($action === 'category_merge') {
|
||||
if (!$canManageSystemSettings || !$listingCatalog) {
|
||||
throw new \RuntimeException('Keine Berechtigung für die Kategorien-Verwaltung.');
|
||||
}
|
||||
$listingCatalog->mergeCategories(
|
||||
(string)($_POST['source_category_slug'] ?? ''),
|
||||
(string)($_POST['target_category_slug'] ?? '')
|
||||
);
|
||||
$info = 'Kategorie zusammengeführt.';
|
||||
} elseif ($action === 'child_add' || $action === 'child_update') {
|
||||
$crypto = self::requireCrypto($crypto, 'Kinder');
|
||||
$childId = (int)($_POST['child_id'] ?? 0);
|
||||
@@ -459,12 +468,15 @@ final class AccountPages
|
||||
$imagePath = self::storeUploadedImage($_FILES['image_file'] ?? null, is_array($existingEvent) ? (string)($existingEvent['image_path'] ?? '') : '');
|
||||
$allowKids = ((string)($_POST['with_children'] ?? 'yes')) === 'yes' ? 1 : 0;
|
||||
$capacity = isset($_POST['max_participants']) && $_POST['max_participants'] !== '' ? (int)$_POST['max_participants'] : null;
|
||||
$categorySlug = trim((string)($_POST['category_slug'] ?? ''));
|
||||
$customCategoryTitle = trim((string)($_POST['category_custom_title'] ?? ''));
|
||||
if ($customCategoryTitle !== '') {
|
||||
$categorySlug = self::slugifyValue($customCategoryTitle);
|
||||
$categoryInput = trim((string)($_POST['category_input'] ?? $_POST['category_slug'] ?? ''));
|
||||
$categorySlug = '';
|
||||
if ($categoryInput !== '' && $listingCatalog) {
|
||||
$category = $listingCatalog->ensureCategoryForInput($categoryInput, 'event');
|
||||
$categorySlug = (string)($category['slug'] ?? '');
|
||||
}
|
||||
|
||||
$eventStartValue = self::normalizeDateForStorage((string)($_POST['starts_at'] ?? ''), true);
|
||||
|
||||
if ($action === 'event_add') {
|
||||
$stmt = $pdo?->prepare('INSERT INTO events (created_by, title, teaser_public, description, category_slug, image_path, location_label, street, zip, city, region, lat, lng, starts_at, max_participants, allow_kids, visibility, status, created_at, updated_at) VALUES (:uid, :title, :teaser, :descr, :categorySlug, :imagePath, :loc, :street, :zip, :city, :region, :lat, :lng, :start, :capacity, :allow, :vis, :status, NOW(), NOW())');
|
||||
$stmt?->execute([
|
||||
@@ -474,14 +486,14 @@ final class AccountPages
|
||||
'descr' => trim((string)$_POST['description']),
|
||||
'categorySlug' => $categorySlug !== '' ? $categorySlug : null,
|
||||
'imagePath' => $imagePath !== '' ? $imagePath : null,
|
||||
'loc' => trim((string)$_POST['location_label']),
|
||||
'loc' => null,
|
||||
'street' => $street ?: null,
|
||||
'zip' => $zip,
|
||||
'city' => $city,
|
||||
'region' => $region,
|
||||
'lat' => $lat,
|
||||
'lng' => $lng,
|
||||
'start' => $_POST['starts_at'] ?? null,
|
||||
'start' => $eventStartValue,
|
||||
'capacity' => $capacity,
|
||||
'allow' => $allowKids,
|
||||
'vis' => $_POST['visibility'] ?? 'public',
|
||||
@@ -506,14 +518,14 @@ final class AccountPages
|
||||
'descr' => trim((string)$_POST['description']),
|
||||
'categorySlug' => $categorySlug !== '' ? $categorySlug : null,
|
||||
'imagePath' => $imagePath !== '' ? $imagePath : null,
|
||||
'loc' => trim((string)$_POST['location_label']),
|
||||
'loc' => null,
|
||||
'street' => $street ?: null,
|
||||
'zip' => $zip,
|
||||
'city' => $city,
|
||||
'region' => $region,
|
||||
'lat' => $lat,
|
||||
'lng' => $lng,
|
||||
'start' => $_POST['starts_at'] ?? null,
|
||||
'start' => $eventStartValue,
|
||||
'capacity' => $capacity,
|
||||
'allow' => $allowKids,
|
||||
'vis' => $_POST['visibility'] ?? 'public',
|
||||
@@ -682,7 +694,8 @@ final class AccountPages
|
||||
$editEvent = null;
|
||||
$otherListings = [];
|
||||
$editListing = null;
|
||||
$listingCategories = $listingCatalog ? $listingCatalog->listCategories(['place', 'food', 'event', 'family']) : [];
|
||||
$listingCategories = $listingCatalog ? $listingCatalog->listCategories(['general', 'place', 'food', 'event', 'family']) : [];
|
||||
$categoryReviewItems = $listingCatalog && $canManageSystemSettings ? $listingCatalog->listCategoryReviewItems() : [];
|
||||
$placeSuggestions = $listingCatalog ? $listingCatalog->listPlaceSuggestions(60) : [];
|
||||
$stmt = $pdo?->prepare(
|
||||
'SELECT e.id, e.title, e.teaser_public, e.description, e.category_slug, e.image_path, e.location_label, e.street, e.zip, e.city, e.region, e.starts_at, e.max_participants, e.allow_kids, e.visibility, e.status, e.lat, e.lng,
|
||||
@@ -750,6 +763,7 @@ final class AccountPages
|
||||
'otherListings',
|
||||
'editListing',
|
||||
'listingCategories',
|
||||
'categoryReviewItems',
|
||||
'placeSuggestions',
|
||||
'communityPoints',
|
||||
'communityLevel',
|
||||
@@ -973,6 +987,20 @@ final class AccountPages
|
||||
return trim($value, '-');
|
||||
}
|
||||
|
||||
private static function normalizeDateForStorage(string $value, bool $endOfDay = false): ?string
|
||||
{
|
||||
$value = trim($value);
|
||||
if ($value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $value) === 1) {
|
||||
return $value . ($endOfDay ? ' 23:59:59' : ' 00:00:00');
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private static function reverseGeocodeAddress(float $lat, float $lng): ?array
|
||||
{
|
||||
$url = 'https://nominatim.openstreetmap.org/reverse?' . http_build_query([
|
||||
|
||||
Reference in New Issue
Block a user