adasd
All checks were successful
Deploy / deploy (push) Successful in 58s

This commit is contained in:
2026-08-17 00:05:18 +02:00
parent d3ebe6fa68
commit 9d5bad8294
14 changed files with 451 additions and 13 deletions

View File

@@ -142,6 +142,9 @@ $sectionLinks = [
'community' => 'Community',
'settings' => 'Einstellungen',
];
if (!empty($canManageProfileLevels)) {
$sectionLinks['profile-levels'] = 'Profil-Levels';
}
$showEventTypeChoice = !$editing && (($section ?? 'events') === 'places') && $requestedCreateListingKind === null;
$modalSectionTarget = ($editingListing || ($section ?? '') === 'places') ? 'places' : 'events';
if (!empty($canManageSystemSettings)) {
@@ -321,6 +324,141 @@ if (!empty($canManageSystemSettings)) {
</section>
<?php endif; ?>
<?php if ($section === 'profile-levels' && !empty($canManageProfileLevels)): ?>
<?php
$systemRoleAssignmentsByRole = [];
foreach (($systemRoleAssignments ?? []) as $assignment) {
$roleKey = (string)($assignment['role'] ?? '');
if ($roleKey === '') {
continue;
}
$systemRoleAssignmentsByRole[$roleKey][] = $assignment;
}
?>
<section class="account-panel">
<div class="account-panel__head">
<h2>Profil-Levels</h2>
</div>
<div class="account-panel__body">
<div class="card">
<strong>Community-Levels</strong>
<div class="stack gap-12" style="margin-top:14px;">
<?php foreach (($communityLevelDefinitions ?? []) as $levelDefinition): ?>
<details class="card" style="padding:14px;">
<summary style="cursor:pointer; font-weight:700;">
<?= htmlspecialchars((string)($levelDefinition['label'] ?? ''), ENT_QUOTES) ?> · ab <?= number_format((float)($levelDefinition['min'] ?? 0), 1, ',', '.') ?> Punkten
</summary>
<form method="post" class="stack gap-12" style="margin-top:14px;">
<input type="hidden" name="action" value="community_level_save">
<input type="hidden" name="level_id" value="<?= htmlspecialchars((string)($levelDefinition['id'] ?? ''), ENT_QUOTES) ?>">
<div class="form-grid">
<div class="stack gap-6">
<label class="label" for="communityLevelLabel<?= htmlspecialchars((string)($levelDefinition['id'] ?? ''), ENT_QUOTES) ?>">Name</label>
<input id="communityLevelLabel<?= htmlspecialchars((string)($levelDefinition['id'] ?? ''), ENT_QUOTES) ?>" name="label" class="input" value="<?= htmlspecialchars((string)($levelDefinition['label'] ?? ''), ENT_QUOTES) ?>" required>
</div>
<div class="stack gap-6">
<label class="label" for="communityLevelMin<?= htmlspecialchars((string)($levelDefinition['id'] ?? ''), ENT_QUOTES) ?>">Mindestpunkte</label>
<input id="communityLevelMin<?= htmlspecialchars((string)($levelDefinition['id'] ?? ''), ENT_QUOTES) ?>" name="min_points" class="input" type="number" min="0" step="0.1" value="<?= htmlspecialchars((string)($levelDefinition['min'] ?? '0'), ENT_QUOTES) ?>" required>
</div>
</div>
<div class="stack gap-6">
<label class="label" for="communityLevelIcon<?= htmlspecialchars((string)($levelDefinition['id'] ?? ''), ENT_QUOTES) ?>">Icon (optional)</label>
<input id="communityLevelIcon<?= htmlspecialchars((string)($levelDefinition['id'] ?? ''), ENT_QUOTES) ?>" name="icon" class="input" value="<?= htmlspecialchars((string)($levelDefinition['icon'] ?? ''), ENT_QUOTES) ?>">
</div>
<div class="stack gap-8">
<span class="label">Rechte</span>
<div class="chips" style="flex-wrap:wrap;">
<?php foreach (($communityLevelRightDefinitions ?? []) as $rightKey => $rightDefinition): ?>
<label class="chip" style="cursor:pointer;">
<input type="hidden" name="rights[<?= htmlspecialchars((string)$rightKey, ENT_QUOTES) ?>]" value="0">
<input type="checkbox" name="rights[<?= htmlspecialchars((string)$rightKey, ENT_QUOTES) ?>]" value="1" <?= !empty($levelDefinition['rights'][$rightKey]) ? 'checked' : '' ?> style="margin-right:6px;">
<?= htmlspecialchars((string)($rightDefinition['label'] ?? $rightKey), ENT_QUOTES) ?>
</label>
<?php endforeach; ?>
</div>
</div>
<div class="flex gap-12" style="flex-wrap:wrap;">
<button class="btn" type="submit">Speichern</button>
</div>
</form>
<form method="post" onsubmit="return confirm('Community-Level wirklich löschen?');">
<input type="hidden" name="action" value="community_level_delete">
<input type="hidden" name="level_id" value="<?= htmlspecialchars((string)($levelDefinition['id'] ?? ''), ENT_QUOTES) ?>">
<button class="btn ghost" type="submit">Löschen</button>
</form>
</details>
<?php endforeach; ?>
</div>
</div>
<div class="card" style="margin-top:18px;">
<strong>Neues Community-Level</strong>
<form method="post" class="stack gap-12" style="margin-top:14px;">
<input type="hidden" name="action" value="community_level_save">
<input type="hidden" name="level_id" value="">
<div class="form-grid">
<div class="stack gap-6">
<label class="label" for="communityLevelLabelNew">Name</label>
<input id="communityLevelLabelNew" name="label" class="input" required>
</div>
<div class="stack gap-6">
<label class="label" for="communityLevelMinNew">Mindestpunkte</label>
<input id="communityLevelMinNew" name="min_points" class="input" type="number" min="0" step="0.1" value="0" required>
</div>
</div>
<div class="stack gap-6">
<label class="label" for="communityLevelIconNew">Icon (optional)</label>
<input id="communityLevelIconNew" name="icon" class="input">
</div>
<div class="stack gap-8">
<span class="label">Rechte</span>
<div class="chips" style="flex-wrap:wrap;">
<?php foreach (($communityLevelRightDefinitions ?? []) as $rightKey => $rightDefinition): ?>
<label class="chip" style="cursor:pointer;">
<input type="hidden" name="rights[<?= htmlspecialchars((string)$rightKey, ENT_QUOTES) ?>]" value="0">
<input type="checkbox" name="rights[<?= htmlspecialchars((string)$rightKey, ENT_QUOTES) ?>]" value="1" style="margin-right:6px;">
<?= htmlspecialchars((string)($rightDefinition['label'] ?? $rightKey), ENT_QUOTES) ?>
</label>
<?php endforeach; ?>
</div>
</div>
<div class="flex gap-12">
<button class="btn" type="submit">Community-Level anlegen</button>
</div>
</form>
</div>
<div class="card" style="margin-top:18px;">
<strong>System-Level</strong>
<div class="stack gap-12" style="margin-top:14px;">
<?php foreach (($systemLevelDefinitions ?? []) as $systemLevel): ?>
<div class="card" style="padding:14px;">
<strong><?= htmlspecialchars((string)($systemLevel['label'] ?? ''), ENT_QUOTES) ?></strong>
<?php if (!empty($systemRoleAssignmentsByRole[(string)($systemLevel['key'] ?? '')])): ?>
<div class="muted small" style="margin-top:8px;">
Aktuell:
<?php
$assignmentLabels = [];
foreach ($systemRoleAssignmentsByRole[(string)$systemLevel['key']] as $assignment) {
$assignmentLabels[] = (string)($assignment['display_name'] ?? 'Mitglied');
}
echo htmlspecialchars(implode(', ', $assignmentLabels), ENT_QUOTES);
?>
</div>
<?php endif; ?>
<ul class="dash-list" style="margin-top:12px;">
<?php foreach (($systemLevel['rights'] ?? []) as $systemRight): ?>
<li><?= htmlspecialchars((string)$systemRight, ENT_QUOTES) ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</section>
<?php endif; ?>
<?php if ($section === 'events'): ?>
<section class="account-panel" id="events">
<div class="account-panel__head">

View File

@@ -78,7 +78,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && $community && $access) {
}
$points = $community->computePoints((int)$userId);
if (!$access->canHighlightHelpful($points) && !$access->canModerateForum((int)$userId)) {
throw new \RuntimeException('Dafür ist mindestens der Rang Mentor-Vater erforderlich.');
throw new \RuntimeException('Dein Community-Level darf hilfreiche Antworten aktuell noch nicht hervorheben.');
}
$postId = (int)($_POST['post_id'] ?? 0);
$highlight = ((string)($_POST['highlight'] ?? '1')) === '1';

View File

@@ -5,6 +5,7 @@ $displayName = 'Profil';
$profileInitial = 'P';
$showAdminLink = false;
$showSystemLink = false;
$showProfileLevelsLink = false;
if ($isLoggedIn) {
try {
@@ -27,6 +28,7 @@ if ($isLoggedIn) {
$communityAccess = new \App\CommunityAccess($pdo, $communityConfig);
$showAdminLink = $communityAccess->canModerateForum((int)$_SESSION['user_id']);
$showSystemLink = $communityAccess->canManageApplications((int)$_SESSION['user_id']);
$showProfileLevelsLink = $communityAccess->canManageRoles((int)$_SESSION['user_id']);
}
}
} catch (\Throwable) {
@@ -34,6 +36,7 @@ if ($isLoggedIn) {
$profileInitial = 'P';
$showAdminLink = false;
$showSystemLink = false;
$showProfileLevelsLink = false;
}
}
?>
@@ -65,6 +68,9 @@ if ($isLoggedIn) {
<a href="/dashboard?section=places" role="menuitem">Orte &amp; Veranstaltungen</a>
<a href="/dashboard?section=community" role="menuitem">Community</a>
<a href="/dashboard?section=settings" role="menuitem">Einstellungen</a>
<?php if ($showProfileLevelsLink): ?>
<a href="/dashboard?section=profile-levels" role="menuitem">Profil-Levels</a>
<?php endif; ?>
<?php if ($showSystemLink): ?>
<a href="/dashboard?section=system" role="menuitem">System</a>
<?php endif; ?>
@@ -92,6 +98,9 @@ if ($isLoggedIn) {
<a class="btn ghost" href="/dashboard?section=places">Orte &amp; Veranstaltungen</a>
<a class="btn ghost" href="/dashboard?section=community">Community</a>
<a class="btn ghost" href="/dashboard?section=settings">Einstellungen</a>
<?php if ($showProfileLevelsLink): ?>
<a class="btn ghost" href="/dashboard?section=profile-levels">Profil-Levels</a>
<?php endif; ?>
<?php if ($showSystemLink): ?>
<a class="btn ghost" href="/dashboard?section=system">System</a>
<?php endif; ?>