This commit is contained in:
@@ -13,9 +13,6 @@ $sectionLinks = [
|
|||||||
'community' => 'Community',
|
'community' => 'Community',
|
||||||
'settings' => 'Einstellungen',
|
'settings' => 'Einstellungen',
|
||||||
];
|
];
|
||||||
if (in_array('admin', $allowedSections ?? [], true)) {
|
|
||||||
$sectionLinks['admin'] = 'Admin';
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<main class="section">
|
<main class="section">
|
||||||
<div class="container" style="display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px;">
|
<div class="container" style="display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px;">
|
||||||
@@ -277,33 +274,6 @@ if (in_array('admin', $allowedSections ?? [], true)) {
|
|||||||
</section>
|
</section>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($section === 'admin' && in_array('admin', $allowedSections ?? [], true)): ?>
|
|
||||||
<section class="account-panel">
|
|
||||||
<div class="account-panel__head">
|
|
||||||
<h2>Community-Verwaltung</h2>
|
|
||||||
<p class="muted">Moderation, Bewerbungen, Rollen und Migration.</p>
|
|
||||||
</div>
|
|
||||||
<div class="account-panel__body">
|
|
||||||
<div class="flex gap-12" style="margin:0 0 16px 0; flex-wrap:wrap;">
|
|
||||||
<a class="btn" href="/community-admin">Zum Admin-Bereich</a>
|
|
||||||
</div>
|
|
||||||
<?php if ($communityMigrationStatus): ?>
|
|
||||||
<ul class="dash-list">
|
|
||||||
<li>Status: <?= !empty($communityMigrationStatus['complete']) ? 'Vollständig eingerichtet' : 'Migration noch offen' ?></li>
|
|
||||||
<li>Fehlende Bausteine: <?= !empty($communityMigrationStatus['missing']) ? htmlspecialchars(implode(', ', $communityMigrationStatus['missing']), ENT_QUOTES) : 'Keine' ?></li>
|
|
||||||
</ul>
|
|
||||||
<?php else: ?>
|
|
||||||
<p class="muted small">Migrationsstatus konnte nicht ermittelt werden.</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (!empty($communityIsSiteAdmin)): ?>
|
|
||||||
<form method="post" style="margin-top:12px;">
|
|
||||||
<input type="hidden" name="action" value="community_migrate">
|
|
||||||
<button class="btn" type="submit">Community-Migration ausführen</button>
|
|
||||||
</form>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ $app = app();
|
|||||||
$isLoggedIn = isset($_SESSION['user_id']);
|
$isLoggedIn = isset($_SESSION['user_id']);
|
||||||
$displayName = 'Profil';
|
$displayName = 'Profil';
|
||||||
$profileInitial = 'P';
|
$profileInitial = 'P';
|
||||||
|
$showAdminLink = false;
|
||||||
|
|
||||||
if ($isLoggedIn) {
|
if ($isLoggedIn) {
|
||||||
try {
|
try {
|
||||||
@@ -16,10 +17,18 @@ if ($isLoggedIn) {
|
|||||||
if ($firstChar !== '') {
|
if ($firstChar !== '') {
|
||||||
$profileInitial = mb_strtoupper($firstChar);
|
$profileInitial = mb_strtoupper($firstChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$communityCfg = dirname(__DIR__, 2) . '/config/community.php';
|
||||||
|
if (file_exists($communityCfg)) {
|
||||||
|
$communityConfig = require $communityCfg;
|
||||||
|
$communityAccess = new \App\CommunityAccess($pdo, $communityConfig);
|
||||||
|
$showAdminLink = $communityAccess->canModerateForum((int)$_SESSION['user_id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (\Throwable) {
|
} catch (\Throwable) {
|
||||||
$displayName = 'Profil';
|
$displayName = 'Profil';
|
||||||
$profileInitial = 'P';
|
$profileInitial = 'P';
|
||||||
|
$showAdminLink = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -50,6 +59,9 @@ if ($isLoggedIn) {
|
|||||||
<a href="/dashboard?section=events" role="menuitem">Termine</a>
|
<a href="/dashboard?section=events" role="menuitem">Termine</a>
|
||||||
<a href="/dashboard?section=community" role="menuitem">Community</a>
|
<a href="/dashboard?section=community" role="menuitem">Community</a>
|
||||||
<a href="/dashboard?section=settings" role="menuitem">Einstellungen</a>
|
<a href="/dashboard?section=settings" role="menuitem">Einstellungen</a>
|
||||||
|
<?php if ($showAdminLink): ?>
|
||||||
|
<a href="/community-admin" role="menuitem">Admin</a>
|
||||||
|
<?php endif; ?>
|
||||||
<a href="/logout" role="menuitem">Abmelden</a>
|
<a href="/logout" role="menuitem">Abmelden</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -70,6 +82,9 @@ if ($isLoggedIn) {
|
|||||||
<a class="btn ghost" href="/dashboard?section=events">Termine</a>
|
<a class="btn ghost" href="/dashboard?section=events">Termine</a>
|
||||||
<a class="btn ghost" href="/dashboard?section=community">Community</a>
|
<a class="btn ghost" href="/dashboard?section=community">Community</a>
|
||||||
<a class="btn ghost" href="/dashboard?section=settings">Einstellungen</a>
|
<a class="btn ghost" href="/dashboard?section=settings">Einstellungen</a>
|
||||||
|
<?php if ($showAdminLink): ?>
|
||||||
|
<a class="btn ghost" href="/community-admin">Admin</a>
|
||||||
|
<?php endif; ?>
|
||||||
<a class="btn block" href="/logout">Abmelden</a>
|
<a class="btn block" href="/logout">Abmelden</a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a class="btn ghost" href="/login">Anmelden</a>
|
<a class="btn ghost" href="/login">Anmelden</a>
|
||||||
|
|||||||
@@ -314,12 +314,6 @@ final class AccountPages
|
|||||||
}
|
}
|
||||||
$communityAccess->submitApplication($userId, (string)($_POST['motivation'] ?? ''));
|
$communityAccess->submitApplication($userId, (string)($_POST['motivation'] ?? ''));
|
||||||
$info = 'Deine Bewerbung wurde eingereicht.';
|
$info = 'Deine Bewerbung wurde eingereicht.';
|
||||||
} elseif ($action === 'community_migrate') {
|
|
||||||
if (!$communityAccess || !$communityMigration || !$communityAccess->canManageApplications($userId)) {
|
|
||||||
throw new \RuntimeException('Keine Berechtigung für die Community-Migration.');
|
|
||||||
}
|
|
||||||
$communityMigration->apply();
|
|
||||||
$info = 'Die Community-Migration wurde ausgeführt.';
|
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$error = $e->getMessage();
|
$error = $e->getMessage();
|
||||||
@@ -405,11 +399,6 @@ final class AccountPages
|
|||||||
'reply_blocked' => false,
|
'reply_blocked' => false,
|
||||||
'reason' => null,
|
'reason' => null,
|
||||||
];
|
];
|
||||||
$communityIsSiteAdmin = $communityAccess ? $communityAccess->canManageApplications($userId) : false;
|
|
||||||
$communityMigrationStatus = ($communityMigration && $communityIsSiteAdmin) ? $communityMigration->status() : null;
|
|
||||||
if (in_array('forum_admin', $communityRoles, true) || $communityIsSiteAdmin) {
|
|
||||||
$allowedSections[] = 'admin';
|
|
||||||
}
|
|
||||||
if (!in_array($section, $allowedSections, true)) {
|
if (!in_array($section, $allowedSections, true)) {
|
||||||
$section = 'profile';
|
$section = 'profile';
|
||||||
}
|
}
|
||||||
@@ -429,8 +418,6 @@ final class AccountPages
|
|||||||
'communityApplication',
|
'communityApplication',
|
||||||
'communityCanApply',
|
'communityCanApply',
|
||||||
'communityRestrictions',
|
'communityRestrictions',
|
||||||
'communityIsSiteAdmin',
|
|
||||||
'communityMigrationStatus',
|
|
||||||
'section',
|
'section',
|
||||||
'allowedSections'
|
'allowedSections'
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user