pdo(); if ($pdo) { $profileSettings = new \App\ProfileSettings($pdo); $profileSettings->ensureSchema(); $avatarColumns = implode(', ', array_map( static fn(string $column): string => $column, \App\Avatar\AvatarManager::allProfileColumns() )); $stmt = $pdo->prepare("SELECT user_id, display_name, $avatarColumns FROM user_profiles WHERE user_id = :id LIMIT 1"); $stmt->execute(['id' => (int)$_SESSION['user_id']]); $profileRow = $stmt->fetch(PDO::FETCH_ASSOC) ?: []; $displayName = trim((string)($profileRow['display_name'] ?? '')) ?: 'Profil'; $communityCfg = dirname(__DIR__, 2) . '/config/community.php'; if (file_exists($communityCfg)) { $communityConfig = require $communityCfg; $community = new \App\Community($pdo, $communityConfig); $communityAccess = new \App\CommunityAccess($pdo, $communityConfig); $navCommunityPoints = $community->computePoints((int)$_SESSION['user_id']); $showAdminSettingsLink = $communityAccess->canAccessCommunityAdmin((int)$_SESSION['user_id'], $navCommunityPoints) || $communityAccess->canManageCategories((int)$_SESSION['user_id'], $navCommunityPoints); } } } catch (\Throwable) { $displayName = 'Profil'; $profileInitial = 'P'; $showAdminSettingsLink = false; } } ?>