Clean up
All checks were successful
Deploy / deploy (push) Successful in 54s

This commit is contained in:
2026-08-21 02:20:46 +02:00
parent fae2dcc830
commit c8ed8fab3b
12 changed files with 130 additions and 80 deletions

View File

@@ -178,19 +178,37 @@ final class AccountPages
$listingCatalog = $pdo ? new ListingCatalog($pdo) : null;
$calendarSync = $pdo ? new CalendarSync($app) : null;
$section = (string)($_GET['section'] ?? 'profile');
$area = (string)($_GET['area'] ?? '') === 'admin' ? 'admin' : 'profile';
$canManageSystemSettings = $communityAccess ? $communityAccess->canManageApplications($userId) : false;
$canManageProfileLevels = $communityAccess ? $communityAccess->canManageRoles($userId) : false;
$communityPointsForAccess = $community ? $community->computePoints($userId) : 0.0;
$canManageCategories = $communityAccess ? $communityAccess->canManageCategories($userId, $communityPointsForAccess) : false;
$canReviewListings = $communityAccess ? $communityAccess->canReviewListings($userId, $communityPointsForAccess) : false;
$allowedSections = ['profile', 'children', 'events', 'places', 'community', 'settings'];
if ($canManageSystemSettings) {
$canAccessCommunityAdmin = $communityAccess ? $communityAccess->canAccessCommunityAdmin($userId, $communityPointsForAccess) : false;
$canAccessAdminArea = $canAccessCommunityAdmin || $canManageCategories || $canManageSystemSettings || $canManageProfileLevels;
// Alte Deep Links zu Verwaltungssektionen bleiben gültig, landen aber im getrennten Admin-Bereich.
if ($area === 'profile' && in_array($section, ['categories', 'profile-levels', 'system'], true)) {
$area = 'admin';
}
if ($area === 'admin' && !isset($_GET['section'])) {
$section = 'admin-home';
}
if ($area === 'admin' && !$canAccessAdminArea) {
redirect('/dashboard?section=profile');
}
$allowedSections = $area === 'admin'
? ['admin-home']
: ['profile', 'children', 'events', 'places', 'community', 'settings'];
if ($area === 'admin' && $canManageSystemSettings) {
$allowedSections[] = 'system';
}
if ($canManageCategories) {
if ($area === 'admin' && $canManageCategories) {
$allowedSections[] = 'categories';
}
if ($canManageProfileLevels) {
if ($area === 'admin' && $canManageProfileLevels) {
$allowedSections[] = 'profile-levels';
}
@@ -353,14 +371,14 @@ final class AccountPages
$targetCategorySlug
);
$app->flash()->set('success', 'Kategorie zusammengeführt.');
redirect('/dashboard?section=categories');
redirect('/dashboard?area=admin&section=categories');
} elseif ($action === 'category_confirm') {
if (!$canManageCategories || !$listingCatalog) {
throw new \RuntimeException('Keine Berechtigung für die Kategorien-Verwaltung.');
}
$listingCatalog->confirmCategory((string)($_POST['source_category_slug'] ?? ''));
$app->flash()->set('success', 'Kategorie bestätigt.');
redirect('/dashboard?section=categories');
redirect('/dashboard?area=admin&section=categories');
} elseif ($action === 'child_add' || $action === 'child_update') {
$crypto = self::requireCrypto($crypto, 'Kinder');
$childId = (int)($_POST['child_id'] ?? 0);
@@ -1104,6 +1122,8 @@ final class AccountPages
'communityLevelRightDefinitions',
'communityRoles',
'canReviewListings',
'canAccessCommunityAdmin',
'canAccessAdminArea',
'systemRoleAssignments',
'recentHighLevelUsers',
'recentHighLevelThresholdLabel',
@@ -1122,6 +1142,7 @@ final class AccountPages
'calendarExportUrl',
'calendarFeedUrl',
'section',
'area',
'allowedSections'
);
}