Customizable sidebar: reorder menu items per member via drag and drop, darker wiki chapter hover
- "Menü anpassen" at the bottom of the sidebar starts an edit mode: drag items (and the divider) with mouse or touch, save, reset to default or cancel; admin items stay in the admin section - Order stored per member (users.sidebar_order) and applied via CSS order, no reflow on load - Wiki chapter tiles get the same dark hover with gold border as the subpage tiles Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
1c58a463f7
commit
9ad013b4ab
8 changed files with 322 additions and 26 deletions
|
|
@ -128,6 +128,74 @@ a:hover { color: var(--gold-hover); text-decoration: underline; }
|
|||
/* Unbeschrifteter Trenner zwischen "Dashboard/Mein Profil/Mitglieder" und
|
||||
"Raids/Premades" - optisch etwas getrennter, aber ohne eigene Ueberschrift
|
||||
wie beim Admin-Bereich. */
|
||||
/* "Menü anpassen" (assets/js/sidebar-editor.js) */
|
||||
button.sidebar-edit-toggle {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
padding: 0.65rem 0.75rem;
|
||||
background: none;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
text-align: left;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.95rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
}
|
||||
button.sidebar-edit-toggle[hidden] { display: none; }
|
||||
button.sidebar-edit-toggle:hover { color: var(--text); box-shadow: none; }
|
||||
.sidebar-edit-toolbar {
|
||||
margin-bottom: 0.6rem;
|
||||
padding: 0.6rem 0.65rem;
|
||||
border: 1px solid rgba(201, 162, 39, 0.5);
|
||||
border-radius: 8px;
|
||||
background: rgba(201, 162, 39, 0.08);
|
||||
}
|
||||
.sidebar-edit-toolbar p { margin: 0 0 0.45rem; font-size: 0.8rem; color: var(--text-muted); }
|
||||
.sidebar-edit-buttons { display: flex; flex-wrap: wrap; gap: 0.35rem; }
|
||||
.sidebar-edit-buttons .button { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
|
||||
.sidebar-nav.is-editing [data-nav] {
|
||||
cursor: grab;
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
border: 1px dashed rgba(201, 162, 39, 0.35);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
}
|
||||
.sidebar-nav.is-editing [data-nav]::after {
|
||||
content: '⠿';
|
||||
margin-left: auto;
|
||||
color: var(--text-muted);
|
||||
font-size: 1rem;
|
||||
line-height: 1;
|
||||
}
|
||||
.sidebar-nav.is-editing [data-nav].is-dragging {
|
||||
cursor: grabbing;
|
||||
border-style: solid;
|
||||
border-color: var(--gold);
|
||||
background: rgba(201, 162, 39, 0.18);
|
||||
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
/* Die Trennlinie ist beim Anpassen ein greifbarer Balken */
|
||||
.sidebar-nav.is-editing .sidebar-nav-gap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: auto;
|
||||
margin: 0.3rem 0;
|
||||
padding: 0.35rem 0.75rem;
|
||||
border-radius: 6px;
|
||||
border-top: 1px dashed rgba(201, 162, 39, 0.35);
|
||||
}
|
||||
.sidebar-nav.is-editing .sidebar-nav-gap::before {
|
||||
content: 'Trennlinie';
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
.sidebar-nav.is-editing .sidebar-badge { display: none; }
|
||||
|
||||
.sidebar-nav-gap {
|
||||
height: 0;
|
||||
margin-top: 0.6rem;
|
||||
|
|
@ -4432,10 +4500,12 @@ body.home-page .navbar {
|
|||
margin: 0;
|
||||
padding: 1.1rem 1.2rem;
|
||||
color: var(--text);
|
||||
transition: border-color 0.15s ease, transform 0.15s ease;
|
||||
transition: background 0.15s ease, border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.wiki-chapter-card:hover { border-color: var(--gold); transform: translateY(-2px); text-decoration: none; color: var(--text); }
|
||||
/* Wie die Unterseiten-Kacheln: beim Drueberfahren dunkel mit Goldrand (kraeftiger, weil die Kachel
|
||||
selbst schon ein halbdunkles Panel ist) */
|
||||
.wiki-chapter-card:hover { background: rgba(10, 10, 10, 0.85); border-color: var(--gold); text-decoration: none; color: var(--text); }
|
||||
|
||||
.wiki-chapter-no {
|
||||
position: absolute;
|
||||
|
|
|
|||
148
assets/js/sidebar-editor.js
Normal file
148
assets/js/sidebar-editor.js
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/**
|
||||
* Menue anpassen: Menuepunkte der Seitenleiste per Drag & Drop umsortieren (Maus und Touch).
|
||||
* Die Reihenfolge wird pro Konto gespeichert (sidebar_action.php) und beim Laden ueber die
|
||||
* CSS-Eigenschaft "order" gesetzt (includes/header.php). Der Admin-Bereich wird fuer sich
|
||||
* sortiert und bleibt unter seiner Ueberschrift.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var toggle = document.getElementById('sidebar-edit-toggle');
|
||||
var nav = document.querySelector('.sidebar-nav');
|
||||
if (!toggle || !nav) return;
|
||||
|
||||
var csrf = (document.querySelector('meta[name="csrf-token"]') || {}).content || '';
|
||||
var editing = false;
|
||||
var toolbar = null;
|
||||
var dragItem = null;
|
||||
|
||||
function items() {
|
||||
return Array.prototype.slice.call(nav.children);
|
||||
}
|
||||
|
||||
function adminLabel() {
|
||||
return nav.querySelector('[data-nav-admin-label]');
|
||||
}
|
||||
|
||||
/** Liegt ein Element im Admin-Bereich (hinter der Ueberschrift)? */
|
||||
function inAdmin(el) {
|
||||
var label = adminLabel();
|
||||
return !!label && (label.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0;
|
||||
}
|
||||
|
||||
function blockClick(event) {
|
||||
if (editing && event.target.closest('.sidebar-nav a')) event.preventDefault();
|
||||
}
|
||||
|
||||
function start() {
|
||||
editing = true;
|
||||
// Sichtbare Reihenfolge (CSS order) in die echte Reihenfolge im Dokument uebernehmen
|
||||
items().sort(function (a, b) {
|
||||
return (parseInt(a.style.order, 10) || 0) - (parseInt(b.style.order, 10) || 0);
|
||||
}).forEach(function (el) {
|
||||
nav.appendChild(el);
|
||||
el.style.order = '';
|
||||
});
|
||||
nav.classList.add('is-editing');
|
||||
nav.querySelectorAll('[data-nav]').forEach(function (el) {
|
||||
el.setAttribute('aria-grabbed', 'false');
|
||||
el.addEventListener('pointerdown', onDown);
|
||||
});
|
||||
|
||||
toolbar = document.createElement('div');
|
||||
toolbar.className = 'sidebar-edit-toolbar';
|
||||
toolbar.innerHTML =
|
||||
'<p>Punkte an die gewünschte Stelle ziehen.</p>' +
|
||||
'<div class="sidebar-edit-buttons">' +
|
||||
'<button type="button" class="button button-small" data-do="save">Fertig</button>' +
|
||||
'<button type="button" class="button button-secondary button-small" data-do="reset">Standard</button>' +
|
||||
'<button type="button" class="button button-secondary button-small" data-do="cancel">Abbrechen</button>' +
|
||||
'</div>';
|
||||
nav.parentNode.insertBefore(toolbar, nav);
|
||||
toolbar.addEventListener('click', function (event) {
|
||||
var action = event.target.closest('[data-do]');
|
||||
if (!action) return;
|
||||
if (action.dataset.do === 'save') save();
|
||||
else if (action.dataset.do === 'reset') send({ reset: 1 });
|
||||
else window.location.reload();
|
||||
});
|
||||
toggle.hidden = true;
|
||||
}
|
||||
|
||||
// ---- Ziehen (Pointer Events: Maus, Stift und Finger) ----
|
||||
function onDown(event) {
|
||||
if (!editing || (event.button !== undefined && event.button !== 0)) return;
|
||||
dragItem = event.currentTarget;
|
||||
dragItem.classList.add('is-dragging');
|
||||
dragItem.setAttribute('aria-grabbed', 'true');
|
||||
dragItem.setPointerCapture(event.pointerId);
|
||||
dragItem.addEventListener('pointermove', onMove);
|
||||
dragItem.addEventListener('pointerup', onUp);
|
||||
dragItem.addEventListener('pointercancel', onUp);
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
function onMove(event) {
|
||||
if (!dragItem) return;
|
||||
var zoneAdmin = inAdmin(dragItem);
|
||||
// Nur zwischen Punkten desselben Bereichs verschieben
|
||||
var siblings = items().filter(function (el) {
|
||||
return el !== dragItem && el.hasAttribute('data-nav') && inAdmin(el) === zoneAdmin;
|
||||
});
|
||||
for (var i = 0; i < siblings.length; i++) {
|
||||
var rect = siblings[i].getBoundingClientRect();
|
||||
if (event.clientY < rect.top + rect.height / 2) {
|
||||
if (siblings[i].previousElementSibling !== dragItem) nav.insertBefore(dragItem, siblings[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Unterhalb aller Punkte: ans Ende des Bereichs
|
||||
var last = siblings[siblings.length - 1];
|
||||
if (last && last.nextElementSibling !== dragItem) nav.insertBefore(dragItem, last.nextElementSibling);
|
||||
}
|
||||
|
||||
function onUp(event) {
|
||||
if (!dragItem) return;
|
||||
dragItem.classList.remove('is-dragging');
|
||||
dragItem.setAttribute('aria-grabbed', 'false');
|
||||
dragItem.releasePointerCapture(event.pointerId);
|
||||
dragItem.removeEventListener('pointermove', onMove);
|
||||
dragItem.removeEventListener('pointerup', onUp);
|
||||
dragItem.removeEventListener('pointercancel', onUp);
|
||||
dragItem = null;
|
||||
}
|
||||
|
||||
// ---- Speichern ----
|
||||
function save() {
|
||||
var data = { main: [], admin: [] };
|
||||
nav.querySelectorAll('[data-nav]').forEach(function (el) {
|
||||
(inAdmin(el) ? data.admin : data.main).push(el.dataset.nav);
|
||||
});
|
||||
send(data);
|
||||
}
|
||||
|
||||
function send(data) {
|
||||
var body = new FormData();
|
||||
body.append('csrf_token', csrf);
|
||||
Object.keys(data).forEach(function (key) {
|
||||
if (Array.isArray(data[key])) data[key].forEach(function (v) { body.append(key + '[]', v); });
|
||||
else body.append(key, data[key]);
|
||||
});
|
||||
toolbar.querySelectorAll('button').forEach(function (b) { b.disabled = true; });
|
||||
fetch('/sidebar_action.php', { method: 'POST', body: body, credentials: 'same-origin' })
|
||||
.then(function (response) { return response.json(); })
|
||||
.then(function (result) {
|
||||
if (!result.ok) throw new Error();
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(function () {
|
||||
toolbar.querySelectorAll('button').forEach(function (b) { b.disabled = false; });
|
||||
window.alert('Speichern hat nicht geklappt - bitte noch einmal versuchen.');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('click', blockClick, true);
|
||||
toggle.addEventListener('click', function () {
|
||||
if (!editing) start();
|
||||
});
|
||||
})();
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<script src="<?= e(asset_url('/assets/js/nav.js')) ?>"></script>
|
||||
<script src="<?= e(asset_url('/assets/js/sidebar-editor.js')) ?>"></script>
|
||||
<script src="<?= e(asset_url('/assets/js/file-input.js')) ?>"></script>
|
||||
<?php else: ?>
|
||||
</main>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,18 @@ declare(strict_types=1);
|
|||
|
||||
// Spielbare Klassen (identisch zur Klassenauswahl des Discord-Bots), genutzt bei der
|
||||
// Raid-Anmeldung und der optionalen Klassenangabe in Premades.
|
||||
// Menuepunkte der Seitenleiste in ihrer Standard-Reihenfolge ("gap" = Trennlinie). Jedes Mitglied
|
||||
// kann sie unter "Menü anpassen" umsortieren (users.sidebar_order, sidebar_action.php) - der
|
||||
// Admin-Bereich wird getrennt sortiert und bleibt unter seiner Ueberschrift.
|
||||
const SIDEBAR_NAV_MAIN = [
|
||||
'/dashboard.php', '/profile.php', '/members.php', '/contributions.php', '/shop.php', 'gap',
|
||||
'/wiki.php', '/raids.php', '/premades.php', '/calendar.php', '/events.php', '/activity.php',
|
||||
'/map.php', '/gear.php', '/warehouse.php',
|
||||
];
|
||||
const SIDEBAR_NAV_ADMIN = [
|
||||
'/admin/users.php', '/admin/roles.php', '/reports.php', '/bugs.php', '/moderation.php', '/admin/audit.php', '/admin/reset.php',
|
||||
];
|
||||
|
||||
const AION_CLASSES = ['Templer', 'Gladiator', 'Assassine', 'Jäger', 'Magier', 'Beschwörer', 'Kleriker', 'Kantor'];
|
||||
|
||||
function e(?string $value): string
|
||||
|
|
|
|||
|
|
@ -132,6 +132,27 @@ $pageBackgrounds = [
|
|||
];
|
||||
$pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
|
||||
|
||||
// Eigene Reihenfolge der Menuepunkte (Seitenleiste -> "Menü anpassen", assets/js/sidebar-editor.js).
|
||||
// Umgesetzt ueber die CSS-Eigenschaft "order" - so steht die Reihenfolge schon beim Laden fest.
|
||||
$savedNavOrder = [];
|
||||
if ($shellUser) {
|
||||
try {
|
||||
$navStmt = db()->prepare('SELECT sidebar_order FROM users WHERE id = ?');
|
||||
$navStmt->execute([(int) $shellUser['id']]);
|
||||
$savedNavOrder = json_decode((string) $navStmt->fetchColumn(), true) ?: [];
|
||||
} catch (PDOException $e) {
|
||||
$savedNavOrder = [];
|
||||
}
|
||||
}
|
||||
$navOrder = static function (string $key) use ($savedNavOrder): string {
|
||||
$zone = in_array($key, SIDEBAR_NAV_ADMIN, true) ? 'admin' : 'main';
|
||||
$base = $zone === 'admin' ? 10010 : 0;
|
||||
$saved = array_search($key, (array) ($savedNavOrder[$zone] ?? []), true);
|
||||
// Gespeicherte Punkte in ihrer Reihenfolge; neue (noch nicht gespeicherte) an ihrem Standardplatz
|
||||
$position = $saved !== false ? $saved * 10 : (int) array_search($key, $zone === 'admin' ? SIDEBAR_NAV_ADMIN : SIDEBAR_NAV_MAIN, true) * 10 + 5;
|
||||
return ' style="order: ' . ($base + $position) . '"';
|
||||
};
|
||||
|
||||
// Erfolgsmeldungen ("Bestätigungen") bekommen ein zentriertes Popup mit Haken-Animation statt
|
||||
// des Balkens oben - andere Meldungstypen (z.B. Fehler) bleiben als Balken, da die dort meist
|
||||
// wichtige Details/Handlungsaufforderungen stehen, die man nicht nur kurz einblenden will.
|
||||
|
|
@ -192,24 +213,24 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
|||
<aside class="sidebar">
|
||||
<div class="sidebar-brand"><a href="/"><img src="<?= e(asset_url('/assets/images/logo-lumina-ascendens.webp')) ?>" alt="Lumina Ascendens" width="410" height="168"></a></div>
|
||||
<nav class="sidebar-nav">
|
||||
<a href="/dashboard.php" class="sidebar-link<?= $isDashboardActive ? ' active' : '' ?>" title="Dashboard">
|
||||
<a href="/dashboard.php" data-nav="/dashboard.php"<?= $navOrder('/dashboard.php') ?> class="sidebar-link<?= $isDashboardActive ? ' active' : '' ?>" title="Dashboard">
|
||||
<?= icon('home') ?><span class="label">Dashboard</span>
|
||||
</a>
|
||||
<a href="/profile.php" class="sidebar-link<?= $isProfileActive ? ' active' : '' ?>" title="Mein Profil">
|
||||
<a href="/profile.php" data-nav="/profile.php"<?= $navOrder('/profile.php') ?> class="sidebar-link<?= $isProfileActive ? ' active' : '' ?>" title="Mein Profil">
|
||||
<?= icon('profile') ?><span class="label">Mein Profil</span>
|
||||
</a>
|
||||
<?php if ($canViewMembers): ?>
|
||||
<a href="/members.php" class="sidebar-link<?= $isMembersActive ? ' active' : '' ?>" title="Mitglieder">
|
||||
<a href="/members.php" data-nav="/members.php"<?= $navOrder('/members.php') ?> class="sidebar-link<?= $isMembersActive ? ' active' : '' ?>" title="Mitglieder">
|
||||
<?= icon('users') ?><span class="label">Mitglieder</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewContributions): ?>
|
||||
<a href="/contributions.php" class="sidebar-link<?= $isContributionsActive ? ' active' : '' ?>" title="Lumipunkte">
|
||||
<a href="/contributions.php" data-nav="/contributions.php"<?= $navOrder('/contributions.php') ?> class="sidebar-link<?= $isContributionsActive ? ' active' : '' ?>" title="Lumipunkte">
|
||||
<?= icon('heart') ?><span class="label">Lumipunkte</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewShop): ?>
|
||||
<a href="/shop.php" class="sidebar-link<?= $isShopActive ? ' active' : '' ?>" title="Lumishop">
|
||||
<a href="/shop.php" data-nav="/shop.php"<?= $navOrder('/shop.php') ?> class="sidebar-link<?= $isShopActive ? ' active' : '' ?>" title="Lumishop">
|
||||
<?= icon('bag') ?><span class="label">Lumishop</span>
|
||||
<?php if ($shopPendingCount > 0): ?>
|
||||
<span class="sidebar-badge" title="Offene Anträge"><?= $shopPendingCount ?></span>
|
||||
|
|
@ -218,57 +239,57 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
|||
<?php endif; ?>
|
||||
|
||||
<?php if ($canViewWiki || $canViewRaids || $canViewPremades || $canViewEvents || $canViewMap || $canViewWarehouse || $canViewGear): ?>
|
||||
<div class="sidebar-nav-gap"></div>
|
||||
<div class="sidebar-nav-gap" data-nav="gap"<?= $navOrder('gap') ?>></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewWiki): ?>
|
||||
<a href="/wiki.php" class="sidebar-link<?= $isWikiActive ? ' active' : '' ?>" title="Wiki">
|
||||
<a href="/wiki.php" data-nav="/wiki.php"<?= $navOrder('/wiki.php') ?> class="sidebar-link<?= $isWikiActive ? ' active' : '' ?>" title="Wiki">
|
||||
<?= icon('book') ?><span class="label">Wiki</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewRaids): ?>
|
||||
<a href="/raids.php" class="sidebar-link<?= $isRaidsActive ? ' active' : '' ?>" title="Raids">
|
||||
<a href="/raids.php" data-nav="/raids.php"<?= $navOrder('/raids.php') ?> class="sidebar-link<?= $isRaidsActive ? ' active' : '' ?>" title="Raids">
|
||||
<?= icon('calendar') ?><span class="label">Raids</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewPremades): ?>
|
||||
<a href="/premades.php" class="sidebar-link<?= $isPremadesActive ? ' active' : '' ?>" title="Premades">
|
||||
<a href="/premades.php" data-nav="/premades.php"<?= $navOrder('/premades.php') ?> class="sidebar-link<?= $isPremadesActive ? ' active' : '' ?>" title="Premades">
|
||||
<?= icon('shield') ?><span class="label">Premades</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewRaids || $canViewEvents): ?>
|
||||
<a href="/calendar.php" class="sidebar-link<?= $isCalendarActive ? ' active' : '' ?>" title="Kalender">
|
||||
<a href="/calendar.php" data-nav="/calendar.php"<?= $navOrder('/calendar.php') ?> class="sidebar-link<?= $isCalendarActive ? ' active' : '' ?>" title="Kalender">
|
||||
<?= icon('calendar') ?><span class="label">Kalender</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewEvents): ?>
|
||||
<a href="/events.php" class="sidebar-link<?= $isEventsActive ? ' active' : '' ?>" title="Events">
|
||||
<a href="/events.php" data-nav="/events.php"<?= $navOrder('/events.php') ?> class="sidebar-link<?= $isEventsActive ? ' active' : '' ?>" title="Events">
|
||||
<?= icon('bell') ?><span class="label">Events</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canManageActivity): ?>
|
||||
<a href="/activity.php" class="sidebar-link<?= $isActivityActive ? ' active' : '' ?>" title="Aktivitätscheck">
|
||||
<a href="/activity.php" data-nav="/activity.php"<?= $navOrder('/activity.php') ?> class="sidebar-link<?= $isActivityActive ? ' active' : '' ?>" title="Aktivitätscheck">
|
||||
<?= icon('check') ?><span class="label">Aktivitätscheck</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewMap): ?>
|
||||
<a href="/map.php" class="sidebar-link<?= $isMapActive ? ' active' : '' ?>" title="Karte">
|
||||
<a href="/map.php" data-nav="/map.php"<?= $navOrder('/map.php') ?> class="sidebar-link<?= $isMapActive ? ' active' : '' ?>" title="Karte">
|
||||
<?= icon('map') ?><span class="label">Karte</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewGear): ?>
|
||||
<a href="/gear.php" class="sidebar-link<?= $isGearActive ? ' active' : '' ?>" title="Gear-Planer">
|
||||
<a href="/gear.php" data-nav="/gear.php"<?= $navOrder('/gear.php') ?> class="sidebar-link<?= $isGearActive ? ' active' : '' ?>" title="Gear-Planer">
|
||||
<?= icon('sword') ?><span class="label">Gear-Planer</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewWarehouse): ?>
|
||||
<a href="/warehouse.php" class="sidebar-link<?= $isWarehouseActive ? ' active' : '' ?>" title="Lagerhaus">
|
||||
<a href="/warehouse.php" data-nav="/warehouse.php"<?= $navOrder('/warehouse.php') ?> class="sidebar-link<?= $isWarehouseActive ? ' active' : '' ?>" title="Lagerhaus">
|
||||
<?= icon('box') ?><span class="label">Lagerhaus</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($showAdminMenu): ?>
|
||||
<div class="sidebar-section-label">Admin</div>
|
||||
<div class="sidebar-section-label" data-nav-admin-label style="order: 10000">Admin</div>
|
||||
<?php if ($canViewUsers): ?>
|
||||
<a href="/admin/users.php" class="sidebar-link<?= $isUsersActive ? ' active' : '' ?>" title="Benutzerverwaltung">
|
||||
<a href="/admin/users.php" data-nav="/admin/users.php"<?= $navOrder('/admin/users.php') ?> class="sidebar-link<?= $isUsersActive ? ' active' : '' ?>" title="Benutzerverwaltung">
|
||||
<?= icon('users') ?><span class="label">Benutzerverwaltung</span>
|
||||
<?php if ($pendingUserCount > 0): ?>
|
||||
<span class="sidebar-badge" title="Warten auf Freischaltung"><?= $pendingUserCount ?></span>
|
||||
|
|
@ -276,17 +297,17 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
|||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canManageRoles): ?>
|
||||
<a href="/admin/roles.php" class="sidebar-link<?= $isRolesActive ? ' active' : '' ?>" title="Berechtigungsgruppen">
|
||||
<a href="/admin/roles.php" data-nav="/admin/roles.php"<?= $navOrder('/admin/roles.php') ?> class="sidebar-link<?= $isRolesActive ? ' active' : '' ?>" title="Berechtigungsgruppen">
|
||||
<?= icon('shield') ?><span class="label">Berechtigungsgruppen</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewReports): ?>
|
||||
<a href="/reports.php" class="sidebar-link<?= $isReportsActive ? ' active' : '' ?>" title="Reports">
|
||||
<a href="/reports.php" data-nav="/reports.php"<?= $navOrder('/reports.php') ?> class="sidebar-link<?= $isReportsActive ? ' active' : '' ?>" title="Reports">
|
||||
<?= icon('flag') ?><span class="label">Reports</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canManageBugs): ?>
|
||||
<a href="/bugs.php" class="sidebar-link<?= $isBugsActive ? ' active' : '' ?>" title="Fehlermeldungen">
|
||||
<a href="/bugs.php" data-nav="/bugs.php"<?= $navOrder('/bugs.php') ?> class="sidebar-link<?= $isBugsActive ? ' active' : '' ?>" title="Fehlermeldungen">
|
||||
<?= icon('bug') ?><span class="label">Fehlermeldungen</span>
|
||||
<?php if ($bugOpenCount > 0): ?>
|
||||
<span class="sidebar-badge" title="Offene Fehlermeldungen"><?= $bugOpenCount ?></span>
|
||||
|
|
@ -294,7 +315,7 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
|||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canModerate): ?>
|
||||
<a href="/moderation.php" class="sidebar-link<?= $isModerationActive ? ' active' : '' ?>" title="Moderation">
|
||||
<a href="/moderation.php" data-nav="/moderation.php"<?= $navOrder('/moderation.php') ?> class="sidebar-link<?= $isModerationActive ? ' active' : '' ?>" title="Moderation">
|
||||
<?= icon('flag') ?><span class="label">Moderation</span>
|
||||
<?php if ($moderationCount > 0): ?>
|
||||
<span class="sidebar-badge" title="Warten auf Freigabe"><?= $moderationCount ?></span>
|
||||
|
|
@ -302,12 +323,12 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
|||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewAudit): ?>
|
||||
<a href="/admin/audit.php" class="sidebar-link<?= $isAuditActive ? ' active' : '' ?>" title="Audit-Log">
|
||||
<a href="/admin/audit.php" data-nav="/admin/audit.php"<?= $navOrder('/admin/audit.php') ?> class="sidebar-link<?= $isAuditActive ? ' active' : '' ?>" title="Audit-Log">
|
||||
<?= icon('shield-check') ?><span class="label">Audit-Log</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canResetData): ?>
|
||||
<a href="/admin/reset.php" class="sidebar-link<?= $isResetActive ? ' active' : '' ?>" title="Daten zurücksetzen">
|
||||
<a href="/admin/reset.php" data-nav="/admin/reset.php"<?= $navOrder('/admin/reset.php') ?> class="sidebar-link<?= $isResetActive ? ' active' : '' ?>" title="Daten zurücksetzen">
|
||||
<?= icon('restore') ?><span class="label">Daten zurücksetzen</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
|
@ -329,6 +350,9 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
|||
Angemeldet als<br><strong><?= e($currentUser['display_name'] !== '' ? $currentUser['display_name'] : $currentUser['username']) ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="sidebar-link sidebar-edit-toggle" id="sidebar-edit-toggle" title="Reihenfolge der Menüpunkte ändern">
|
||||
<?= icon('move') ?><span class="label">Menü anpassen</span>
|
||||
</button>
|
||||
<a href="/logout.php" class="sidebar-link" title="Abmelden">
|
||||
<?= icon('log-out') ?><span class="label">Abmelden</span>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
||||
const SCHEMA_VERSION = 28;
|
||||
const SCHEMA_VERSION = 29;
|
||||
|
||||
/**
|
||||
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
||||
|
|
@ -536,6 +536,8 @@ function schema_column_upgrades(): array
|
|||
{
|
||||
return [
|
||||
'users' => [
|
||||
// Eigene Reihenfolge der Menuepunkte (JSON, siehe SIDEBAR_NAV_MAIN)
|
||||
'sidebar_order' => "ALTER TABLE users ADD COLUMN sidebar_order TEXT NULL AFTER tour_completed_at",
|
||||
'password_login' => "ALTER TABLE users ADD COLUMN password_login TINYINT(1) NOT NULL DEFAULT 1 AFTER must_change_password",
|
||||
'is_admin' => "ALTER TABLE users ADD COLUMN is_admin TINYINT(1) NOT NULL DEFAULT 0 AFTER password_login",
|
||||
// Profilbild von Discord uebernehmen - wer schon ein eigenes hochgeladen hat, behaelt es.
|
||||
|
|
|
|||
37
sidebar_action.php
Normal file
37
sidebar_action.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* Eigene Reihenfolge der Menuepunkte speichern (Seitenleiste -> "Menü anpassen",
|
||||
* assets/js/sidebar-editor.js). Antwortet als JSON.
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_login();
|
||||
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
http_response_code(405);
|
||||
echo json_encode(['ok' => false]);
|
||||
exit;
|
||||
}
|
||||
verify_csrf();
|
||||
|
||||
$userId = (int) current_user()['id'];
|
||||
|
||||
if (!empty($_POST['reset'])) {
|
||||
db()->prepare('UPDATE users SET sidebar_order = NULL WHERE id = ?')->execute([$userId]);
|
||||
echo json_encode(['ok' => true]);
|
||||
exit;
|
||||
}
|
||||
|
||||
/** Nur bekannte Menuepunkte, jeder hoechstens einmal. */
|
||||
$clean = static function ($keys, array $allowed): array {
|
||||
$keys = array_values(array_unique(array_filter((array) $keys, 'is_string')));
|
||||
return array_values(array_filter($keys, static fn (string $key): bool => in_array($key, $allowed, true)));
|
||||
};
|
||||
$order = [
|
||||
'main' => $clean($_POST['main'] ?? [], SIDEBAR_NAV_MAIN),
|
||||
'admin' => $clean($_POST['admin'] ?? [], SIDEBAR_NAV_ADMIN),
|
||||
];
|
||||
|
||||
db()->prepare('UPDATE users SET sidebar_order = ? WHERE id = ?')
|
||||
->execute([json_encode($order, JSON_UNESCAPED_SLASHES), $userId]);
|
||||
echo json_encode(['ok' => true]);
|
||||
|
|
@ -37,6 +37,8 @@ CREATE TABLE IF NOT EXISTS users (
|
|||
discord_joined_at DATETIME NULL,
|
||||
-- Einfuehrung im Dashboard abgeschlossen (NULL = Tour wird beim naechsten Besuch gezeigt)
|
||||
tour_completed_at DATETIME NULL,
|
||||
-- Eigene Reihenfolge der Menuepunkte in der Seitenleiste (JSON: {main: [...], admin: [...]})
|
||||
sidebar_order TEXT NULL,
|
||||
avatar_filename VARCHAR(255) NULL,
|
||||
-- 1 = Profilbild wird von Discord uebernommen (0 nach eigenem Upload)
|
||||
avatar_sync TINYINT(1) NOT NULL DEFAULT 1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue