This commit is contained in:
@@ -153,6 +153,10 @@ final class AccountPages
|
||||
$info = '';
|
||||
$crypto = null;
|
||||
try { $crypto = new Crypto($app->config()); } catch (\Throwable) {}
|
||||
$communityCfg = dirname(__DIR__, 2) . '/config/community.php';
|
||||
$communityConfig = file_exists($communityCfg) ? require $communityCfg : [];
|
||||
$community = $pdo ? new Community($pdo, $communityConfig) : null;
|
||||
$communityAccess = $pdo ? new CommunityAccess($pdo, $communityConfig) : null;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = $_POST['action'] ?? '';
|
||||
@@ -282,6 +286,16 @@ final class AccountPages
|
||||
'id' => $eventId,
|
||||
]);
|
||||
$info = 'Event wurde abgesagt.';
|
||||
} elseif ($action === 'community_admin_apply') {
|
||||
if (!$community || !$communityAccess) {
|
||||
throw new \RuntimeException('Community-Funktionen sind aktuell nicht verfügbar.');
|
||||
}
|
||||
$points = $community->computePoints($userId);
|
||||
if (!$communityAccess->canApplyForForumAdmin($userId, $points)) {
|
||||
throw new \RuntimeException('Du kannst dich aktuell nicht als Forum-Admin bewerben.');
|
||||
}
|
||||
$communityAccess->submitApplication($userId, (string)($_POST['motivation'] ?? ''));
|
||||
$info = 'Deine Bewerbung wurde eingereicht.';
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$error = $e->getMessage();
|
||||
@@ -353,7 +367,33 @@ final class AccountPages
|
||||
$editEvent = $stmt?->fetch(\PDO::FETCH_ASSOC) ?: null;
|
||||
}
|
||||
|
||||
return compact('flash','info','error','profile','children','eventsUpcoming','eventsPast','editEvent');
|
||||
$communityPoints = $community ? $community->computePoints($userId) : 0.0;
|
||||
$communityLevel = $community ? $community->membershipLevel($communityPoints) : ['label' => '', 'icon' => ''];
|
||||
$communityRoles = $communityAccess ? $communityAccess->getUserRoles($userId) : [];
|
||||
$communityApplication = $communityAccess ? $communityAccess->getLatestApplication($userId) : null;
|
||||
$communityCanApply = $communityAccess ? $communityAccess->canApplyForForumAdmin($userId, $communityPoints) : false;
|
||||
$communityRestrictions = $communityAccess ? $communityAccess->getRestrictionState($userId) : [
|
||||
'thread_create_blocked' => false,
|
||||
'reply_blocked' => false,
|
||||
'reason' => null,
|
||||
];
|
||||
|
||||
return compact(
|
||||
'flash',
|
||||
'info',
|
||||
'error',
|
||||
'profile',
|
||||
'children',
|
||||
'eventsUpcoming',
|
||||
'eventsPast',
|
||||
'editEvent',
|
||||
'communityPoints',
|
||||
'communityLevel',
|
||||
'communityRoles',
|
||||
'communityApplication',
|
||||
'communityCanApply',
|
||||
'communityRestrictions'
|
||||
);
|
||||
}
|
||||
|
||||
private static function geocodeAddress(?string $street, ?string $zip, ?string $city, ?string $region): array
|
||||
|
||||
Reference in New Issue
Block a user