@@ -175,7 +175,7 @@ include __DIR__ . '/includes/header.php';
-
diff --git a/admin/gear_items.php b/admin/gear_items.php
index f929884..49ddc9f 100644
--- a/admin/gear_items.php
+++ b/admin/gear_items.php
@@ -149,7 +149,7 @@ include __DIR__ . '/../includes/header.php';
= (int) $item['used'] ?>
Abgleichen
-
-
+
= csrf_field() ?>
Ankündigung entfernen
diff --git a/admin/users.php b/admin/users.php
index acd2f4c..14a7b80 100644
--- a/admin/users.php
+++ b/admin/users.php
@@ -187,7 +187,8 @@ include __DIR__ . '/../includes/header.php';
['log-out', 'Abmelden erzwingen (alle Sitzungen beenden)', 'Alle Sitzungen dieses Kontos beenden?'], 'lock' => ['lock', 'Sperren und überall abmelden', 'Dieses Konto sperren und überall abmelden?']] as $secAction => [$secIcon, $secTitle, $secQuestion]): ?>
); if (r === null) return false; this.reason.value = r; return true;">
+ data-confirm="= e($secQuestion) ?>" data-confirm-title="= e($secTitle) ?>" data-confirm-input="reason"
+ data-confirm-placeholder="Grund (optional, erscheint im Audit-Log)"= $secAction === 'lock' ? ' data-confirm-danger data-confirm-ok="Sperren"' : ' data-confirm-ok="Abmelden"' ?>>
= csrf_field() ?>
@@ -197,7 +198,7 @@ include __DIR__ . '/../includes/header.php';
-
+
= csrf_field() ?>
= icon('trash') ?>
diff --git a/assets/css/style.css b/assets/css/style.css
index b645643..c927218 100644
--- a/assets/css/style.css
+++ b/assets/css/style.css
@@ -18,6 +18,16 @@
* { box-sizing: border-box; }
+/* Schmale goldene Scrollbalken ueberall (Listen in Popups, Tabellen, Textfelder ...) statt der hellen
+ Standardbalken des Browsers. Eigene Regeln (Seitenleiste, Wiki-Inhaltsverzeichnis, Seite mit
+ Fortschrittsleiste) gehen vor, weil * keine Spezifitaet hat. */
+* { scrollbar-width: thin; scrollbar-color: rgba(201, 162, 39, 0.3) transparent; }
+*::-webkit-scrollbar { width: 6px; height: 6px; }
+*::-webkit-scrollbar-track, *::-webkit-scrollbar-corner { background: transparent; }
+*::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
+*::-webkit-scrollbar-thumb { background: rgba(201, 162, 39, 0.3); border-radius: 999px; }
+*::-webkit-scrollbar-thumb:hover { background: rgba(201, 162, 39, 0.8); }
+
body {
margin: 0;
background: var(--bg);
@@ -839,6 +849,44 @@ input[type="datetime-local"]::-webkit-calendar-picker-indicator {
@keyframes success-mark-draw {
to { stroke-dashoffset: 0; }
}
+
+/* --- Rueckfragen und Meldungen im Lumina-Stil (assets/js/confirm-dialog.js) ---
+ Liegt ueber normalen Popups (1000), aber unter dem Erfolgs-Popup (1100). */
+.lumina-dialog-overlay {
+ position: fixed;
+ inset: 0;
+ z-index: 1050;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 1rem;
+ background: rgba(0, 0, 0, 0.6);
+ opacity: 0;
+ transition: opacity 0.18s ease;
+}
+.lumina-dialog-overlay.visible { opacity: 1; }
+.lumina-dialog {
+ width: 100%;
+ max-width: 440px;
+ max-height: 90vh;
+ overflow-y: auto;
+ padding: 1.5rem 1.75rem;
+ background: var(--bg-panel);
+ border: 1px solid var(--border);
+ border-top: 3px solid var(--gold);
+ border-radius: 12px;
+ box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
+ transform: scale(0.94);
+ transition: transform 0.18s ease;
+}
+.lumina-dialog-overlay.visible .lumina-dialog { transform: scale(1); }
+.lumina-dialog-danger, .lumina-dialog-error { border-top-color: var(--danger); }
+.lumina-dialog-title { margin: 0 0 0.6rem; font-size: 1.2rem; color: var(--gold); }
+.lumina-dialog-error .lumina-dialog-title, .lumina-dialog-danger .lumina-dialog-title { color: var(--danger); }
+.lumina-dialog-text { margin: 0 0 1rem; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; }
+.lumina-dialog-input { width: 100%; margin: 0 0 1rem; resize: vertical; font-family: inherit; }
+.lumina-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.6rem; }
+body.lumina-dialog-open { overflow: hidden; }
.text-muted.error { color: var(--danger); }
.hero {
@@ -1044,7 +1092,7 @@ input[type="datetime-local"]::-webkit-calendar-picker-indicator {
}
/* background explizit wiederholen: sonst gewinnt button:hover (Gold-Flaeche), siehe .icon-button */
-.user-filter-trigger:hover { background: var(--bg-panel-alt); border-color: var(--gold); }
+.user-filter-trigger:hover { background: var(--bg-panel-alt); border-color: var(--gold); color: var(--text); }
.user-filter-trigger.open {
border-color: var(--gold);
@@ -1139,7 +1187,7 @@ input[type="datetime-local"]::-webkit-calendar-picker-indicator {
transition: background 0.12s ease;
}
-.user-filter-option:hover { background: var(--bg-panel-alt); }
+.user-filter-option:hover { background: var(--bg-panel-alt); color: var(--text); }
.user-filter-option.selected {
background: rgba(201, 162, 39, 0.15);
@@ -1218,7 +1266,7 @@ input[type="datetime-local"]::-webkit-calendar-picker-indicator {
color: #fff;
}
-.discord-connect-button:hover { background: var(--discord-hover); }
+.discord-connect-button:hover { background: var(--discord-hover); color: #fff; }
.discord-connect-button .discord-logo { color: #fff; }
@media (max-width: 700px) {
@@ -1434,7 +1482,7 @@ input[type="datetime-local"]::-webkit-calendar-picker-indicator {
cursor: pointer;
}
-.premade-slot-invite-btn:hover { color: var(--gold); }
+.premade-slot-invite-btn:hover { background: none; box-shadow: none; color: var(--gold); }
/* Bearbeiten-Modus: Verwaltung (Einladen, Entfernen, Umbenennen, ...) erst nach Klick auf den Stift */
.premade-panel:not(.is-editing) .premade-edit-only,
@@ -1472,6 +1520,8 @@ input[type="datetime-local"]::-webkit-calendar-picker-indicator {
.premade-class-action:hover {
border-color: var(--gold);
background: rgba(201, 162, 39, 0.1);
+ color: var(--text);
+ box-shadow: none;
}
.premade-class-action-icon { color: var(--text-muted); }
@@ -1509,7 +1559,7 @@ input[type="datetime-local"]::-webkit-calendar-picker-indicator {
width: 100%;
}
-.premade-invite-option:hover { border-color: var(--gold); color: var(--gold); }
+.premade-invite-option:hover { border-color: var(--gold); color: #1a1a1a; }
.premade-invite-option[hidden] { display: none; }
.premade-slot-name {
@@ -2720,6 +2770,30 @@ button.contribution-chip-remove:hover { background: none; color: var(--danger);
a.button-small:hover { text-decoration: none; }
.raid-auto-points { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; }
+.raid-points-fixed { display: flex; align-items: center; gap: 0.35rem; margin: 0 0 1rem; }
+
+/* Raid erstellen: Gruppen mit optionaler Premade */
+.group-editor > .field-hint { margin: 0.25rem 0 0; }
+.group-editor-premade { flex: 0 1 13rem; width: auto; min-width: 0; }
+.group-editor-name[readonly] { color: var(--gold); }
+@media (max-width: 600px) {
+ .group-editor-row:has(.group-editor-premade) { flex-wrap: wrap; }
+ .group-editor-premade { flex: 1 1 100%; order: 3; }
+}
+
+/* Live-Aktualisierung: geaenderte Karte leuchtet kurz auf */
+.raid-card-updated { animation: raid-card-flash 1.6s ease; }
+@keyframes raid-card-flash {
+ from { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(201, 162, 39, 0.35); }
+}
+.raid-live-notice {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: 0.75rem;
+ margin-bottom: 1.5rem;
+}
.attendance-head {
display: flex;
@@ -5570,6 +5644,9 @@ strong.grade-common, strong.grade-rare, strong.grade-epic, strong.grade-unique,
linear-gradient(180deg, color-mix(in srgb, var(--grade) 14%, #121418), color-mix(in srgb, var(--grade) 42%, #121418));
}
.gear-doll-slot.is-active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.45), 0 0 14px rgba(201, 162, 39, 0.35); }
+/* Passt nicht (mehr) zum Set, z.B. nach einem Klassenwechsel: roter Rahmen innen (Seltenheit, Auswahl
+ und Fokus bleiben sichtbar) - geloescht wird nichts */
+.gear-doll-slot.is-mismatch::after { content: ''; position: absolute; inset: 0; border: 2px solid var(--danger); border-radius: 5px; pointer-events: none; }
.gear-doll-slot img { width: 84%; height: 84%; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6)); }
.gear-doll-silhouette { width: 58%; height: 58%; }
.gear-doll-initial { font-size: 1.6rem; font-weight: 700; color: var(--grade); }
@@ -5614,6 +5691,8 @@ strong.grade-common, strong.grade-rare, strong.grade-epic, strong.grade-unique,
.gear-set-card-stat-name { color: var(--text-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gear-set-card-stat-value { flex-shrink: 0; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.gear-set-card-profile:hover .gear-set-card-more { text-decoration: underline; }
+/* Build-Link unter der Karte (die Karte selbst ist schon ein Link) */
+.gear-set-card-build { display: inline-block; margin: 0 1rem 0.9rem; font-size: 0.82rem; }
@media (max-width: 800px) {
.gear-doll { grid-template-columns: repeat(6, minmax(0, 1fr)); max-width: 520px; margin: 0 auto; }
}
@@ -5989,7 +6068,16 @@ span.reaction { cursor: default; }
a.calendar-entry:hover { text-decoration: none; filter: brightness(1.25); }
.calendar-entry.is-past { opacity: 0.55; }
.calendar-time { font-weight: 700; font-variant-numeric: tabular-nums; }
-.calendar-more { font-size: 0.72rem; color: var(--text-muted); padding-left: 0.35rem; }
+.calendar-day-entries {
+ /* Alle Termine eines Tages: drei ganz, der vierte angeschnitten - dann scrollt die Zelle */
+ display: flex;
+ flex-direction: column;
+ gap: 3px;
+ max-height: 4.6rem;
+ overflow-y: auto;
+ min-width: 0;
+}
+.calendar-day-entries .calendar-entry { flex-shrink: 0; }
.calendar-dots { display: none; gap: 3px; margin-top: auto; }
.calendar-dots i { width: 7px; height: 7px; border-radius: 50%; }
@@ -6027,7 +6115,7 @@ a.calendar-agenda-entry:hover { text-decoration: none; filter: brightness(1.2);
@media (max-width: 700px) {
.calendar-day { min-height: 3.2rem; align-items: center; padding: 0.3rem 0.1rem; }
- .calendar-entry, .calendar-more { display: none; }
+ .calendar-entry, .calendar-day-entries { display: none; }
.calendar-dots { display: flex; }
.calendar-month { min-width: 8rem; }
.calendar-agenda-date { flex-basis: 3.6rem; }
@@ -6042,6 +6130,14 @@ a.calendar-agenda-entry:hover { text-decoration: none; filter: brightness(1.2);
/* Kalender: Termine der Mitglieder (gruen) */
.calendar-member { background: rgba(59, 165, 93, 0.18); border-left: 3px solid #3ba55d; }
.calendar-chip.calendar-member { border-left: none; }
+.calendar-audience-badge {
+ padding: 0.05rem 0.5rem;
+ border-radius: 999px;
+ background: rgba(201, 162, 39, 0.15);
+ color: var(--gold);
+ font-size: 0.75rem;
+ font-weight: 600;
+}
.calendar-dots i.calendar-member { background: #3ba55d; border: 0; }
.calendar-new { margin: 0.9rem 0 0.2rem; }
.calendar-new > summary { list-style: none; display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; }
diff --git a/assets/js/activity.js b/assets/js/activity.js
index 3c34b93..c0ee95f 100644
--- a/assets/js/activity.js
+++ b/assets/js/activity.js
@@ -80,14 +80,18 @@
radio.addEventListener('change', function () { f.color_custom.value = '#206694'; });
});
- form.addEventListener('submit', function (event) {
+ // Rueckfrage vor dem Posten (assets/js/confirm-dialog.js liest data-confirm beim Absenden)
+ function updateConfirm() {
var consequences = [];
if (dmToggle.checked) consequences.push('PN');
if (f.remove_role_id.value) consequences.push('Rolle entfernen');
if (f.add_role_id.value) consequences.push('Rolle geben');
- var text = 'Check jetzt im Discord posten?\n\nFolgen ohne Rückmeldung: ' + (consequences.length ? consequences.join(', ') : 'keine (nur Liste im Log-Kanal)');
- if (!window.confirm(text)) event.preventDefault();
- });
+ form.setAttribute('data-confirm', 'Folgen ohne Rückmeldung: ' + (consequences.length ? consequences.join(', ') : 'keine (nur Liste im Log-Kanal)'));
+ }
+ form.setAttribute('data-confirm-title', 'Check jetzt im Discord posten?');
+ form.setAttribute('data-confirm-ok', 'Posten');
+ form.addEventListener('change', updateConfirm);
+ updateConfirm();
update();
})();
diff --git a/assets/js/confirm-dialog.js b/assets/js/confirm-dialog.js
new file mode 100644
index 0000000..487c99e
--- /dev/null
+++ b/assets/js/confirm-dialog.js
@@ -0,0 +1,247 @@
+/**
+ * Rueckfragen und Meldungen im Lumina-Stil statt der Browser-Fenster confirm()/prompt()/alert().
+ * Wird auf allen Seiten geladen (includes/footer.php).
+ *
+ * Im Skript:
+ * luminaDialog.confirm('Termin löschen?', { title: 'Termin löschen', danger: true, okLabel: 'Löschen' })
+ * .then(function (ok) { ... }); // true / false
+ * luminaDialog.prompt('Warum?', { placeholder: '…', required: 5, multiline: true })
+ * .then(function (text) { ... }); // Text oder null (abgebrochen)
+ * luminaDialog.alert('Das hat nicht geklappt.', { tone: 'error' });
+ *
+ * Im HTML (ohne eigenes Skript) - an oder an einem Absende-Knopf:
+ * data-confirm="Text" Rueckfrage vor dem Absenden
+ * data-confirm-title="…" Ueberschrift (sonst "Bist du sicher?")
+ * data-confirm-ok="Löschen" Beschriftung des OK-Knopfs
+ * data-confirm-danger roter OK-Knopf (Loeschen & Co.)
+ * data-confirm-input="reason" zusaetzlich ein Textfeld - der Text landet im Formularfeld "reason"
+ * data-confirm-placeholder="…" Platzhalter dafuer
+ *
+ * Fehlermeldungen der Seite (set_flash('error', …)) zeigt includes/header.php als Daten-Block
+ * #flash-errors - sie erscheinen hier als Meldung, die man mit OK bestaetigen muss.
+ */
+(function () {
+ 'use strict';
+
+ var open = null; // gerade offener Dialog - es gibt immer nur einen
+ var queue = []; // weitere warten, bis er zu ist
+ var counter = 0;
+
+ function el(tag, className, text) {
+ var node = document.createElement(tag);
+ if (className) node.className = className;
+ if (text !== undefined) node.textContent = text;
+ return node;
+ }
+
+ function show(kind, message, opts) {
+ opts = opts || {};
+ return new Promise(function (resolve) {
+ var request = { kind: kind, message: String(message || ''), opts: opts, resolve: resolve };
+ if (open) {
+ queue.push(request);
+ } else {
+ render(request);
+ }
+ });
+ }
+
+ function render(request) {
+ var kind = request.kind;
+ var opts = request.opts;
+ var id = 'lumina-dialog-' + (++counter);
+ var previousFocus = document.activeElement;
+
+ var overlay = el('div', 'lumina-dialog-overlay');
+ var box = el('div', 'lumina-dialog' + (opts.tone === 'error' ? ' lumina-dialog-error' : '') + (opts.danger ? ' lumina-dialog-danger' : ''));
+ box.setAttribute('role', kind === 'alert' ? 'alertdialog' : 'dialog');
+ box.setAttribute('aria-modal', 'true');
+ box.setAttribute('aria-labelledby', id + '-title');
+ box.setAttribute('aria-describedby', id + '-text');
+
+ var defaultTitle = kind === 'alert'
+ ? (opts.tone === 'error' ? 'Das hat nicht geklappt' : 'Hinweis')
+ : (kind === 'prompt' ? 'Bitte angeben' : 'Bist du sicher?');
+ var title = el('h2', 'lumina-dialog-title', opts.title || defaultTitle);
+ title.id = id + '-title';
+ var text = el('p', 'lumina-dialog-text', request.message);
+ text.id = id + '-text';
+ box.appendChild(title);
+ if (request.message !== '') box.appendChild(text);
+
+ var field = null;
+ if (kind === 'prompt') {
+ field = opts.multiline ? el('textarea', 'lumina-dialog-input') : el('input', 'lumina-dialog-input');
+ if (!opts.multiline) field.type = 'text';
+ if (opts.multiline) field.rows = 3;
+ field.placeholder = opts.placeholder || '';
+ field.value = opts.value || '';
+ if (opts.maxlength) field.maxLength = opts.maxlength;
+ field.setAttribute('aria-label', opts.title || request.message || 'Eingabe');
+ box.appendChild(field);
+ }
+
+ var actions = el('div', 'lumina-dialog-actions');
+ var cancelBtn = null;
+ if (kind !== 'alert') {
+ cancelBtn = el('button', 'button-secondary', opts.cancelLabel || 'Abbrechen');
+ cancelBtn.type = 'button';
+ actions.appendChild(cancelBtn);
+ }
+ var okBtn = el('button', opts.danger ? 'button-danger' : '', opts.okLabel || (kind === 'alert' ? 'OK' : (opts.danger ? 'Löschen' : 'Bestätigen')));
+ okBtn.type = 'button';
+ actions.appendChild(okBtn);
+ box.appendChild(actions);
+ overlay.appendChild(box);
+
+ var minLength = kind === 'prompt' ? (parseInt(opts.required, 10) || 0) : 0;
+ function validate() {
+ if (field && minLength > 0) okBtn.disabled = field.value.trim().length < minLength;
+ }
+ if (field) field.addEventListener('input', validate);
+ validate();
+
+ function finish(confirmed) {
+ if (open !== overlay) return;
+ open = null;
+ window.removeEventListener('keydown', onKey, true);
+ document.body.classList.remove('lumina-dialog-open');
+ overlay.classList.remove('visible');
+ setTimeout(function () {
+ if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
+ }, 180);
+ if (previousFocus && typeof previousFocus.focus === 'function' && document.contains(previousFocus)) {
+ previousFocus.focus();
+ }
+ if (kind === 'confirm') request.resolve(!!confirmed);
+ else if (kind === 'prompt') request.resolve(confirmed ? field.value.trim() : null);
+ else request.resolve();
+ if (queue.length) render(queue.shift());
+ }
+
+ function onKey(e) {
+ if (e.key === 'Escape') {
+ // Nur diesen Dialog schliessen, nicht ein Popup darunter
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ finish(kind === 'alert');
+ return;
+ }
+ if (e.key === 'Enter' && field && e.target === field && !opts.multiline) {
+ e.preventDefault();
+ if (!okBtn.disabled) finish(true);
+ return;
+ }
+ if (e.key === 'Tab') {
+ // Fokus bleibt im Dialog
+ var focusable = Array.prototype.filter.call(box.querySelectorAll('button, input, textarea'), function (node) {
+ return !node.disabled;
+ });
+ if (!focusable.length) return;
+ var first = focusable[0];
+ var last = focusable[focusable.length - 1];
+ if (e.shiftKey && document.activeElement === first) {
+ e.preventDefault();
+ last.focus();
+ } else if (!e.shiftKey && document.activeElement === last) {
+ e.preventDefault();
+ first.focus();
+ }
+ }
+ }
+
+ okBtn.addEventListener('click', function () {
+ finish(true);
+ });
+ if (cancelBtn) {
+ cancelBtn.addEventListener('click', function () {
+ finish(false);
+ });
+ }
+ // Klick daneben bricht eine Rueckfrage ab - eine Meldung muss man mit OK bestaetigen.
+ overlay.addEventListener('click', function (e) {
+ if (e.target === overlay && kind !== 'alert') finish(false);
+ });
+
+ open = overlay;
+ window.addEventListener('keydown', onKey, true);
+ document.body.appendChild(overlay);
+ document.body.classList.add('lumina-dialog-open');
+ requestAnimationFrame(function () {
+ overlay.classList.add('visible');
+ });
+ // Bei Loeschen & Co. liegt der Fokus auf "Abbrechen", damit Enter nichts Endgueltiges tut.
+ (field || (opts.danger && cancelBtn) || okBtn).focus();
+ }
+
+ window.luminaDialog = {
+ confirm: function (message, opts) { return show('confirm', message, opts); },
+ prompt: function (message, opts) { return show('prompt', message, opts); },
+ alert: function (message, opts) { return show('alert', message, opts); }
+ };
+
+ // ---- Formulare mit data-confirm ----
+ var PASS_MS = 30000;
+
+ window.addEventListener('submit', function (event) {
+ var form = event.target;
+ if (!(form instanceof HTMLFormElement)) return;
+ var submitter = event.submitter || null;
+ var source = submitter && submitter.hasAttribute('data-confirm') ? submitter
+ : (form.hasAttribute('data-confirm') ? form : null);
+ if (!source) return;
+ // Schon bestaetigt (zweiter Durchlauf nach OK, z.B. auch nach dem Verkleinern von Bildern)?
+ if (Date.now() - (parseInt(form.dataset.confirmPassed || '0', 10)) < PASS_MS) return;
+
+ event.preventDefault();
+ event.stopImmediatePropagation();
+ if (open) return; // Doppelklick
+
+ var inputName = source.getAttribute('data-confirm-input');
+ var opts = {
+ title: source.getAttribute('data-confirm-title') || undefined,
+ okLabel: source.getAttribute('data-confirm-ok') || undefined,
+ danger: source.hasAttribute('data-confirm-danger'),
+ placeholder: source.getAttribute('data-confirm-placeholder') || '',
+ multiline: true,
+ maxlength: 255
+ };
+ var message = source.getAttribute('data-confirm');
+ var question = inputName ? window.luminaDialog.prompt(message, opts) : window.luminaDialog.confirm(message, opts);
+
+ question.then(function (result) {
+ if (result === false || result === null) return;
+ if (inputName) {
+ var field = form.elements.namedItem(inputName);
+ if (field) field.value = result;
+ }
+ form.dataset.confirmPassed = String(Date.now());
+ if (form.requestSubmit) {
+ if (submitter) form.requestSubmit(submitter); else form.requestSubmit();
+ } else {
+ form.submit();
+ }
+ });
+ }, true);
+
+ // Seite aus dem Zurueck-Cache: wieder nachfragen
+ window.addEventListener('pageshow', function () {
+ document.querySelectorAll('form[data-confirm-passed]').forEach(function (form) {
+ delete form.dataset.confirmPassed;
+ });
+ });
+
+ // ---- Fehlermeldungen der Seite ----
+ var errors = document.getElementById('flash-errors');
+ if (errors) {
+ var messages = [];
+ try {
+ messages = JSON.parse(errors.textContent || '[]');
+ } catch (e) {
+ messages = [];
+ }
+ if (messages.length) {
+ window.luminaDialog.alert(messages.join('\n\n'), { tone: 'error' });
+ }
+ }
+})();
diff --git a/assets/js/gear-admin.js b/assets/js/gear-admin.js
index bf0e94c..08a9706 100644
--- a/assets/js/gear-admin.js
+++ b/assets/js/gear-admin.js
@@ -161,9 +161,10 @@
return;
}
var pageCount = firsts.reduce(function (sum, f) { return sum + f.page.pages; }, 0);
- if (run.total > 100 && !window.confirm(run.total + ' Gegenstände auf ' + pageCount + ' Seiten gefunden'
+ if (run.total > 100 && !(await window.luminaDialog.confirm(run.total + ' Gegenstände auf ' + pageCount + ' Seiten gefunden'
+ (skipKnown.checked ? ' (schon vorhandene werden übersprungen)' : '') + '.\n\nIn voller Länge dauert das etwa '
- + Math.ceil((run.total + pageCount) * 1.3 / 60) + ' Minuten - die Seite muss so lange offen bleiben (Anhalten geht jederzeit). Starten?')) {
+ + Math.ceil((run.total + pageCount) * 1.3 / 60) + ' Minuten - die Seite muss so lange offen bleiben (Anhalten geht jederzeit).',
+ { title: 'Import starten?', okLabel: 'Starten' }))) {
setBusy(false);
progress.hidden = true;
return;
@@ -224,11 +225,12 @@
});
if (checkAllButton) {
- checkAllButton.addEventListener('click', function () {
+ checkAllButton.addEventListener('click', async function () {
var ids = JSON.parse(root.dataset.allIds || '[]');
if (!ids.length || running) return;
var minutes = Math.ceil(ids.length * 1.3 / 60);
- if (ids.length > 30 && !window.confirm(ids.length + ' Gegenstände abgleichen? Das dauert etwa ' + minutes + ' Minuten - die Seite muss so lange offen bleiben.')) return;
+ if (ids.length > 30 && !(await window.luminaDialog.confirm('Das dauert etwa ' + minutes + ' Minuten - die Seite muss so lange offen bleiben.',
+ { title: ids.length + ' Gegenstände abgleichen?', okLabel: 'Abgleichen' }))) return;
runIds(ids, 'check', 'alle');
});
}
diff --git a/assets/js/premades.js b/assets/js/premades.js
index 9f734bf..2a61504 100644
--- a/assets/js/premades.js
+++ b/assets/js/premades.js
@@ -85,15 +85,38 @@
var question = inviteDirect
? name + ' wirklich in die Premade einteilen?\n\nDas Mitglied wird per Discord-PN benachrichtigt.'
: name + ' wirklich in die Premade einladen?\n\nDas Mitglied wird per Discord-PN benachrichtigt.';
- if (!confirm(question)) {
- return;
- }
- inviteUserIdField.value = btn.getAttribute('data-user-id') || '';
- inviteForm.submit();
+ window.luminaDialog.confirm(question, {
+ title: inviteDirect ? 'Spieler einteilen' : 'Mitglied einladen',
+ okLabel: inviteDirect ? 'Einteilen' : 'Einladen'
+ }).then(function (ok) {
+ if (!ok) return;
+ inviteUserIdField.value = btn.getAttribute('data-user-id') || '';
+ inviteForm.submit();
+ });
});
});
}
+ // ---- Aufloesen durch die Leitung (mit Begruendung fuer den Lead) ----
+ var dissolveModal = document.getElementById('premade-dissolve-modal');
+ wireModal(dissolveModal);
+ if (dissolveModal) {
+ var dissolveCancel = dissolveModal.querySelector('.modal-cancel');
+ if (dissolveCancel) dissolveCancel.addEventListener('click', function () { closeModal(dissolveModal); });
+ }
+
+ document.querySelectorAll('.premade-dissolve-btn').forEach(function (btn) {
+ btn.addEventListener('click', function () {
+ if (!dissolveModal) return;
+ document.getElementById('premade-dissolve-premade-id').value = btn.getAttribute('data-premade-id') || '';
+ dissolveModal.querySelector('.premade-dissolve-name').textContent = btn.getAttribute('data-premade-name') || '';
+ var reason = document.getElementById('premade-dissolve-reason');
+ reason.value = '';
+ openModal(dissolveModal);
+ reason.focus();
+ });
+ });
+
// ---- Klasse festlegen/aendern ----
var classModal = document.getElementById('premade-class-modal');
var classForm = document.getElementById('premade-class-form');
diff --git a/assets/js/raid-search.js b/assets/js/raid-search.js
index cb1c218..b723d22 100644
--- a/assets/js/raid-search.js
+++ b/assets/js/raid-search.js
@@ -9,7 +9,6 @@
var input = document.getElementById('raid-search');
if (!input) return;
- var cards = Array.prototype.slice.call(document.querySelectorAll('.raid-card[data-search]'));
var count = document.getElementById('raid-search-count');
var empty = document.getElementById('raid-search-empty');
var tabs = document.querySelectorAll('.filter-tabs .filter-tab');
@@ -17,6 +16,8 @@
function apply() {
var q = input.value.trim().toLowerCase();
var shown = 0;
+ // Jedes Mal neu suchen - die Live-Aktualisierung ersetzt einzelne Karten.
+ var cards = Array.prototype.slice.call(document.querySelectorAll('.raid-card[data-search]'));
cards.forEach(function (card) {
var match = !q || card.dataset.search.indexOf(q) !== -1;
@@ -44,5 +45,6 @@
}
input.addEventListener('input', apply);
+ document.addEventListener('raids:updated', apply);
apply();
})();
diff --git a/assets/js/raids.js b/assets/js/raids.js
index 866b516..b60b808 100644
--- a/assets/js/raids.js
+++ b/assets/js/raids.js
@@ -30,7 +30,30 @@
return dateParts[2] + '.' + dateParts[1] + '.' + dateParts[0] + ' ' + parts[1];
}
- // ---- Anmelde-Popup ----
+ function parseJsonAttr(el, name) {
+ try {
+ var value = JSON.parse(el.getAttribute(name) || '[]');
+ return Array.isArray(value) ? value : [];
+ } catch (e) {
+ return [];
+ }
+ }
+
+ // Meldung im Lumina-Dialog (assets/js/confirm-dialog.js), sonst im Browser-Fenster.
+ function notify(message) {
+ if (window.luminaDialog) {
+ window.luminaDialog.alert(message);
+ } else {
+ alert(message);
+ }
+ }
+
+ // Raid-IDs sind 19-stellige Discord-IDs - sie bleiben ueberall Strings (als Zahl waeren sie ungenau).
+ function cardRaidId(card) {
+ return card.getAttribute('data-raid-id');
+ }
+
+ // ---- Anmelde-Popup (eins fuer alle Raids) ----
var modal = document.getElementById('raid-signup-modal');
var groupPicker = document.getElementById('raid-signup-group-picker');
var feedbackEl = document.getElementById('raid-signup-feedback');
@@ -61,21 +84,11 @@
function openSignupModal(card) {
if (!modal) return;
- currentRaidId = card.getAttribute('data-raid-id');
+ currentRaidId = cardRaidId(card);
selectedClass = card.getAttribute('data-my-class') || null;
- var groups = [];
- try {
- groups = JSON.parse(card.getAttribute('data-groups') || '[]');
- } catch (e) {
- groups = [];
- }
- var lockedGroups = [];
- try {
- lockedGroups = JSON.parse(card.getAttribute('data-locked-groups') || '[]');
- } catch (e) {
- lockedGroups = [];
- }
+ var groups = parseJsonAttr(card, 'data-groups');
+ var lockedGroups = parseJsonAttr(card, 'data-locked-groups');
var myGroup = card.getAttribute('data-my-group') || '';
selectedGroup = myGroup === '' ? null : parseInt(myGroup, 10);
// Eine bereits gewaehlte, aber inzwischen gesperrte Gruppe zaehlt nicht mehr als Auswahl.
@@ -97,20 +110,15 @@
feedbackEl.textContent = '';
feedbackEl.className = 'raid-modal-feedback';
+ confirmBtn.disabled = false;
modal.hidden = false;
}
function closeSignupModal() {
if (modal) modal.hidden = true;
+ currentRaidId = null;
}
- document.querySelectorAll('.raid-open-signup').forEach(function (btn) {
- btn.addEventListener('click', function () {
- var card = btn.closest('.raid-card');
- if (card) openSignupModal(card);
- });
- });
-
if (modal) {
modal.querySelector('.modal-close').addEventListener('click', closeSignupModal);
modal.addEventListener('click', function (e) {
@@ -144,7 +152,10 @@
feedbackEl.textContent = result.message || '';
feedbackEl.className = 'raid-modal-feedback ' + (result.status === 'success' ? 'success' : 'error');
if (result.status === 'success') {
- setTimeout(function () { window.location.reload(); }, 1400);
+ setTimeout(function () {
+ closeSignupModal();
+ refreshAfterAction();
+ }, 1400);
} else {
confirmBtn.disabled = false;
}
@@ -156,61 +167,13 @@
});
}
- // ---- Editor-Modus ----
- document.querySelectorAll('.raid-edit-toggle').forEach(function (btn) {
- btn.addEventListener('click', function () {
- var card = btn.closest('.raid-card');
- if (card) card.classList.toggle('editing');
- });
- });
-
// Gruppennamen gehen kommagetrennt an die API - ein Komma im Namen wuerde ihn in zwei
// Gruppen aufteilen und die gesperrten Gruppen verschieben.
function groupEditorName(row) {
return row.querySelector('.group-editor-name').value.replace(/,/g, ' ').replace(/\s+/g, ' ').trim();
}
- // ---- Raid bearbeiten (Formular) ----
- document.querySelectorAll('.raid-edit-form').forEach(function (form) {
- form.addEventListener('submit', function (e) {
- e.preventDefault();
- var feedback = form.querySelector('.raid-edit-feedback');
-
- var groupNames = [];
- var lockedGroups = [];
- form.querySelectorAll('.group-editor-row').forEach(function (row) {
- var name = groupEditorName(row);
- if (name === '') return; // leere Zeilen werden beim Speichern ignoriert
- groupNames.push(name);
- if (row.querySelector('.group-editor-lock-checkbox').checked) {
- lockedGroups.push(groupNames.length);
- }
- });
-
- feedback.textContent = 'Wird gespeichert …';
- postJson('/raid_edit_action.php', {
- raid_id: form.getAttribute('data-raid-id'),
- title: form.title.value,
- date_raw: formatDateRaw(form.date_local.value),
- requirements: form.requirements.value,
- gearscore: form.gearscore.value,
- group_names: groupNames.join(', '),
- max_slots: form.max_slots.value,
- locked_groups: lockedGroups,
- points_present: form.points_present ? form.points_present.value : 0,
- points_absent: form.points_absent ? form.points_absent.value : 0
- }).then(function (result) {
- feedback.textContent = result.message || '';
- if (result.status === 'success') {
- setTimeout(function () { window.location.reload(); }, 900);
- }
- }).catch(function () {
- feedback.textContent = 'Verbindung fehlgeschlagen.';
- });
- });
- });
-
- // ---- Gruppen-Editor: Zeilen hinzufuegen/entfernen ----
+ // ---- Gruppen-Editor: Zeilen hinzufuegen/entfernen, Premades zuordnen ----
// withLock=false blendet den Sperren-Toggle aus (z.B. beim Erstellen eines neuen
// Raids, wo "Gruppen sperren" von der API noch nicht unterstuetzt wird).
function createGroupEditorRow(name, withLock) {
@@ -226,80 +189,229 @@
return row;
}
- document.querySelectorAll('.group-editor').forEach(function (editor) {
+ // Auswahl "freie Gruppe / Premade" fuer eine Zeile (nur beim Erstellen eines Raids).
+ function addPremadeSelect(row, premades) {
+ var select = document.createElement('select');
+ select.className = 'group-editor-premade';
+ select.title = 'Feste Premade dieser Gruppe zuordnen';
+ var free = document.createElement('option');
+ free.value = '';
+ free.textContent = '– freie Gruppe –';
+ select.appendChild(free);
+ premades.forEach(function (premade) {
+ var option = document.createElement('option');
+ option.value = String(premade.id);
+ option.textContent = premade.name;
+ select.appendChild(option);
+ });
+ row.querySelector('.group-editor-name').insertAdjacentElement('afterend', select);
+ }
+
+ function initGroupEditor(editor) {
+ if (editor.dataset.wired) return;
+ editor.dataset.wired = '1';
+
var withLock = editor.getAttribute('data-locks') !== '0';
+ var maxGroups = parseInt(editor.getAttribute('data-max-groups') || '10', 10);
+ var premades = editor.hasAttribute('data-premades') ? parseJsonAttr(editor, 'data-premades') : [];
var rows = editor.querySelector('.group-editor-rows');
var addBtn = editor.querySelector('.group-editor-add');
+ function rowCount() {
+ return rows.querySelectorAll('.group-editor-row').length;
+ }
+
+ // Eine Premade kann nur einer Gruppe zugeordnet werden.
+ function syncPremadeOptions() {
+ var selects = rows.querySelectorAll('.group-editor-premade');
+ var used = {};
+ selects.forEach(function (select) {
+ if (select.value) used[select.value] = select;
+ });
+ selects.forEach(function (select) {
+ Array.prototype.forEach.call(select.options, function (option) {
+ option.disabled = option.value !== '' && used[option.value] !== undefined && used[option.value] !== select;
+ });
+ });
+ }
+
+ function changed() {
+ addBtn.hidden = rowCount() >= maxGroups;
+ syncPremadeOptions();
+ editor.dispatchEvent(new CustomEvent('groups:changed'));
+ }
+
+ if (premades.length) {
+ rows.querySelectorAll('.group-editor-row').forEach(function (row) {
+ addPremadeSelect(row, premades);
+ });
+ }
+
addBtn.addEventListener('click', function () {
- var row = createGroupEditorRow('', withLock);
+ if (rowCount() >= maxGroups) return;
+ var row = createGroupEditorRow('Gruppe ' + (rowCount() + 1), withLock);
+ if (premades.length) addPremadeSelect(row, premades);
rows.appendChild(row);
- row.querySelector('.group-editor-name').focus();
+ var input = row.querySelector('.group-editor-name');
+ input.focus();
+ input.select();
+ changed();
});
rows.addEventListener('click', function (e) {
var removeBtn = e.target.closest('.group-editor-remove');
if (!removeBtn) return;
- if (rows.querySelectorAll('.group-editor-row').length <= 1) return; // mindestens eine Gruppe muss bleiben
+ if (rowCount() <= 1) return; // mindestens eine Gruppe muss bleiben
removeBtn.closest('.group-editor-row').remove();
+ changed();
});
rows.addEventListener('change', function (e) {
- if (!e.target.classList.contains('group-editor-lock-checkbox')) return;
- e.target.closest('.group-editor-lock').classList.toggle('checked', e.target.checked);
- });
- });
-
- // ---- Neuen Raid erstellen ----
- var raidCreateToggle = document.getElementById('raid-create-toggle');
- var raidCreatePanel = document.getElementById('raid-create-panel');
- if (raidCreateToggle && raidCreatePanel) {
- raidCreateToggle.addEventListener('click', function () {
- raidCreatePanel.style.display = raidCreatePanel.style.display === 'none' ? 'block' : 'none';
- });
- }
-
- var raidCreateForm = document.getElementById('raid-create-form');
- if (raidCreateForm) {
- raidCreateForm.addEventListener('submit', function (e) {
- e.preventDefault();
- var feedback = raidCreateForm.querySelector('.raid-create-feedback');
-
- var groupNames = [];
- raidCreateForm.querySelectorAll('.group-editor-row').forEach(function (row) {
- var name = groupEditorName(row);
- if (name !== '') groupNames.push(name);
- });
- if (groupNames.length === 0) {
- feedback.textContent = 'Bitte mindestens eine Gruppe angeben.';
- feedback.className = 'raid-create-feedback text-muted error';
+ if (e.target.classList.contains('group-editor-lock-checkbox')) {
+ e.target.closest('.group-editor-lock').classList.toggle('checked', e.target.checked);
return;
}
+ if (e.target.classList.contains('group-editor-premade')) {
+ var select = e.target;
+ var row = select.closest('.group-editor-row');
+ var nameInput = row.querySelector('.group-editor-name');
+ if (select.value) {
+ // Die Gruppe heisst wie die Premade - der Bot benennt sie beim Einladen ohnehin so.
+ if (!nameInput.readOnly) row.dataset.freeName = nameInput.value;
+ nameInput.value = select.options[select.selectedIndex].textContent;
+ nameInput.readOnly = true;
+ } else {
+ nameInput.readOnly = false;
+ nameInput.value = row.dataset.freeName || nameInput.value;
+ }
+ syncPremadeOptions();
+ }
+ });
- feedback.textContent = 'Wird erstellt …';
- feedback.className = 'raid-create-feedback text-muted';
- postJson('/raid_create_action.php', {
- title: raidCreateForm.title.value,
- date_raw: formatDateRaw(raidCreateForm.date_local.value),
- requirements: raidCreateForm.requirements.value,
- gearscore: raidCreateForm.gearscore.value,
+ changed();
+ }
+
+ // "Max. Spieler" folgt der Zahl der Gruppen (je 5 Plaetze), solange niemand selbst einen Wert
+ // eintraegt. Beim Erstellen begrenzt das Feld die Eingabe gleich selbst; beim Bearbeiten prueft
+ // der Server (aeltere Raids duerfen ihren bisherigen Wert behalten).
+ function initSlotsAuto(form) {
+ var slots = form.querySelector('input[name="max_slots"]');
+ var editor = form.querySelector('.group-editor');
+ if (!slots || !editor) return;
+ var size = parseInt(editor.getAttribute('data-group-size') || '5', 10);
+ var maxGroups = parseInt(editor.getAttribute('data-max-groups') || '10', 10);
+ var limitField = !form.classList.contains('raid-edit-form');
+
+ function cap() {
+ return Math.min(maxGroups, editor.querySelectorAll('.group-editor-row').length) * size;
+ }
+
+ var auto = parseInt(slots.value, 10) === cap();
+ slots.addEventListener('input', function () {
+ auto = false;
+ });
+ function update() {
+ var value = cap();
+ if (limitField) slots.max = String(value);
+ if (auto) slots.value = String(value);
+ }
+ editor.addEventListener('groups:changed', update);
+ update();
+ }
+
+ // ---- Eine Raid-Karte verdrahten (beim Laden und nach jeder Live-Aktualisierung) ----
+ // Alle Handler suchen ihre Karte beim Ausloesen ueber closest() - das Bearbeiten-Formular
+ // wandert bei einer Live-Aktualisierung samt Eingaben in die neue Karte mit.
+ function initRaidCard(card, keepPanel) {
+ card.querySelectorAll('.raid-open-signup').forEach(function (btn) {
+ btn.addEventListener('click', function () {
+ openSignupModal(btn.closest('.raid-card'));
+ });
+ });
+
+ var toggle = card.querySelector('.raid-edit-toggle');
+ if (toggle) {
+ toggle.addEventListener('click', function () {
+ var owner = toggle.closest('.raid-card');
+ owner.classList.toggle('editing');
+ // Das Formular wurde bei einer Live-Aktualisierung mitgenommen und kann veraltet sein -
+ // nach dem Schliessen die Karte frisch holen.
+ if (!owner.classList.contains('editing') && owner.dataset.panelKept) {
+ owner.setAttribute('data-rev', 'stale');
+ live.soon();
+ }
+ });
+ }
+
+ if (!keepPanel) {
+ card.querySelectorAll('.raid-edit-form').forEach(initEditForm);
+ card.querySelectorAll('.raid-premade-form').forEach(initPremadeForm);
+ }
+
+ initDragAndDrop(card);
+ initMoveSelects(card);
+ }
+
+ // ---- Raid bearbeiten (Formular) ----
+ function initEditForm(form) {
+ initGroupEditor(form.querySelector('.group-editor'));
+ initSlotsAuto(form);
+
+ form.addEventListener('submit', function (e) {
+ e.preventDefault();
+ var card = form.closest('.raid-card');
+ var feedback = form.querySelector('.raid-edit-feedback');
+
+ var groupNames = [];
+ var lockedGroups = [];
+ form.querySelectorAll('.group-editor-row').forEach(function (row) {
+ var name = groupEditorName(row);
+ if (name === '') return; // leere Zeilen werden beim Speichern ignoriert
+ groupNames.push(name);
+ if (row.querySelector('.group-editor-lock-checkbox').checked) {
+ lockedGroups.push(groupNames.length);
+ }
+ });
+
+ var data = {
+ raid_id: form.getAttribute('data-raid-id'),
+ title: form.title.value,
+ date_raw: formatDateRaw(form.date_local.value),
+ requirements: form.requirements.value,
+ gearscore: form.gearscore.value,
group_names: groupNames.join(', '),
- max_slots: raidCreateForm.max_slots.value,
- points_present: raidCreateForm.points_present.value,
- points_absent: raidCreateForm.points_absent.value
- }).then(function (result) {
+ max_slots: form.max_slots.value,
+ locked_groups: lockedGroups
+ };
+ // Punkte schickt nur, wer sie festlegen darf (nur dann gibt es die Felder).
+ if (form.points_present && form.points_absent) {
+ data.points_present = form.points_present.value;
+ data.points_absent = form.points_absent.value;
+ }
+
+ feedback.textContent = 'Wird gespeichert …';
+ card.dataset.busy = '1';
+ postJson('/raid_edit_action.php', data).then(function (result) {
feedback.textContent = result.message || '';
+ var current = form.closest('.raid-card');
if (result.status === 'success') {
- setTimeout(function () { window.location.reload(); }, 900);
+ setTimeout(function () {
+ current.classList.remove('editing');
+ delete current.dataset.busy;
+ refreshAfterAction();
+ }, 900);
+ } else {
+ delete current.dataset.busy;
}
}).catch(function () {
feedback.textContent = 'Verbindung fehlgeschlagen.';
+ delete form.closest('.raid-card').dataset.busy;
});
});
}
// ---- Premade einladen ----
- document.querySelectorAll('.raid-premade-form').forEach(function (form) {
+ function initPremadeForm(form) {
form.addEventListener('submit', function (e) {
e.preventDefault();
var feedback = form.querySelector('.raid-premade-feedback');
@@ -312,32 +424,17 @@
}).then(function (result) {
feedback.textContent = result.message || '';
if (result.status === 'success') {
- setTimeout(function () { window.location.reload(); }, 1200);
+ setTimeout(function () {
+ var card = form.closest('.raid-card');
+ if (card) card.classList.remove('editing');
+ refreshAfterAction();
+ }, 1200);
}
}).catch(function () {
feedback.textContent = 'Verbindung fehlgeschlagen.';
});
});
- });
-
- // ---- Drag & Drop (nur im Editor-Modus) ----
- document.querySelectorAll('.raid-signup-item').forEach(function (item) {
- item.addEventListener('dragstart', function (e) {
- var card = item.closest('.raid-card');
- if (!card || !card.classList.contains('editing')) {
- e.preventDefault();
- return;
- }
- e.dataTransfer.setData('text/plain', JSON.stringify({
- raidId: card.getAttribute('data-raid-id'),
- userId: item.getAttribute('data-user-id')
- }));
- item.classList.add('dragging');
- });
- item.addEventListener('dragend', function () {
- item.classList.remove('dragging');
- });
- });
+ }
// Aktualisiert Mitgliederzahl, Leer-Hinweis und Liste einer Gruppe nach einem
// Verschieben, ohne die Seite neu zu laden - der Editor-Modus bleibt so
@@ -364,18 +461,21 @@
// Fuehrt das eigentliche Verschieben aus (API-Call + DOM-Patch) - gemeinsam
// genutzt von Drag&Drop (Maus) und dem Verschieben-Dropdown (Touch/Mobile,
- // da natives HTML5-Drag&Drop auf Touch-Geraeten nicht funktioniert).
+ // da natives HTML5-Drag&Drop auf Touch-Geraeten nicht funktioniert). Danach holt die
+ // Live-Aktualisierung den echten Stand (Notizen, Auswahllisten, Zaehler).
function moveSignupTo(card, itemEl, targetZone) {
var sourceZone = itemEl.closest('.raid-drop-zone');
if (!sourceZone || sourceZone === targetZone) {
return Promise.resolve();
}
+ card.dataset.busy = '1';
return postJson('/raid_move_action.php', {
- raid_id: card.getAttribute('data-raid-id'),
+ raid_id: cardRaidId(card),
user_id: itemEl.getAttribute('data-user-id'),
group: targetZone.getAttribute('data-group')
}).then(function (result) {
+ delete card.dataset.busy;
if (result.status !== 'success') {
throw new Error(result.message || 'Verschieben fehlgeschlagen.');
}
@@ -405,64 +505,82 @@
badge.textContent = active + ' / ' + match[2] + ' angemeldet';
}
}
+ var select = itemEl.querySelector('.raid-move-select');
+ if (select) select.value = targetZone.getAttribute('data-group');
+ live.soon();
+ }, function (err) {
+ delete card.dataset.busy;
+ throw err;
});
}
- document.querySelectorAll('.raid-drop-zone').forEach(function (zone) {
- var isLocked = zone.getAttribute('data-locked') === '1';
-
- zone.addEventListener('dragover', function (e) {
- var card = zone.closest('.raid-card');
- if (!card || !card.classList.contains('editing') || isLocked) return;
- e.preventDefault();
- zone.classList.add('drag-over');
- });
- zone.addEventListener('dragleave', function () {
- zone.classList.remove('drag-over');
- });
- zone.addEventListener('drop', function (e) {
- e.preventDefault();
- zone.classList.remove('drag-over');
- var card = zone.closest('.raid-card');
- if (!card || !card.classList.contains('editing') || isLocked) return;
-
- var raw = e.dataTransfer.getData('text/plain');
- if (!raw) return;
- var payload;
- try {
- payload = JSON.parse(raw);
- } catch (err) {
- return;
- }
-
- var itemEl = null;
- card.querySelectorAll('.raid-signup-item').forEach(function (li) {
- if (li.getAttribute('data-user-id') === String(payload.userId)) itemEl = li;
+ // ---- Drag & Drop (nur im Editor-Modus) ----
+ function initDragAndDrop(card) {
+ card.querySelectorAll('.raid-signup-item').forEach(function (item) {
+ item.addEventListener('dragstart', function (e) {
+ var owner = item.closest('.raid-card');
+ if (!owner || !owner.classList.contains('editing')) {
+ e.preventDefault();
+ return;
+ }
+ e.dataTransfer.setData('text/plain', JSON.stringify({
+ raidId: cardRaidId(owner),
+ userId: item.getAttribute('data-user-id')
+ }));
+ item.classList.add('dragging');
});
- if (!itemEl) return;
-
- moveSignupTo(card, itemEl, zone).catch(function (err) {
- alert(err.message || 'Verschieben fehlgeschlagen.');
+ item.addEventListener('dragend', function () {
+ item.classList.remove('dragging');
});
});
- });
+
+ card.querySelectorAll('.raid-drop-zone').forEach(function (zone) {
+ var isLocked = zone.getAttribute('data-locked') === '1';
+
+ zone.addEventListener('dragover', function (e) {
+ var owner = zone.closest('.raid-card');
+ if (!owner || !owner.classList.contains('editing') || isLocked) return;
+ e.preventDefault();
+ zone.classList.add('drag-over');
+ });
+ zone.addEventListener('dragleave', function () {
+ zone.classList.remove('drag-over');
+ });
+ zone.addEventListener('drop', function (e) {
+ e.preventDefault();
+ zone.classList.remove('drag-over');
+ var owner = zone.closest('.raid-card');
+ if (!owner || !owner.classList.contains('editing') || isLocked) return;
+
+ var raw = e.dataTransfer.getData('text/plain');
+ if (!raw) return;
+ var payload;
+ try {
+ payload = JSON.parse(raw);
+ } catch (err) {
+ return;
+ }
+ if (String(payload.raidId) !== cardRaidId(owner)) return;
+
+ var itemEl = null;
+ owner.querySelectorAll('.raid-signup-item').forEach(function (li) {
+ if (li.getAttribute('data-user-id') === String(payload.userId)) itemEl = li;
+ });
+ if (!itemEl) return;
+
+ moveSignupTo(owner, itemEl, zone).catch(function (err) {
+ notify(err.message || 'Verschieben fehlgeschlagen.');
+ });
+ });
+ });
+ }
// ---- Verschieben-Dropdown pro Spieler (Mobile/Touch-Alternative zum Drag&Drop) ----
- document.querySelectorAll('.raid-card').forEach(function (card) {
+ function initMoveSelects(card) {
if (!card.querySelector('.raid-edit-toggle')) return; // kein Editor-Modus fuer diesen Raid
- var groups = [];
- try {
- groups = JSON.parse(card.getAttribute('data-groups') || '[]');
- } catch (e) {
- groups = [];
- }
- var lockedGroups = [];
- try {
- lockedGroups = JSON.parse(card.getAttribute('data-locked-groups') || '[]');
- } catch (e) {
- lockedGroups = [];
- }
+ var groups = parseJsonAttr(card, 'data-groups');
+ var lockedGroups = parseJsonAttr(card, 'data-locked-groups');
card.querySelectorAll('.raid-signup-item[draggable="true"]').forEach(function (item) {
var currentZone = item.closest('.raid-drop-zone');
@@ -495,15 +613,16 @@
select.addEventListener('click', function (e) { e.stopPropagation(); });
select.addEventListener('change', function () {
- var targetZone = card.querySelector('.raid-drop-zone[data-group="' + select.value + '"]');
+ var owner = item.closest('.raid-card');
+ var targetZone = owner.querySelector('.raid-drop-zone[data-group="' + select.value + '"]');
+ var sourceZone = item.closest('.raid-drop-zone');
+ var previousValue = sourceZone ? sourceZone.getAttribute('data-group') : '';
if (!targetZone) return;
- var previousValue = currentGroup;
select.disabled = true;
- moveSignupTo(card, item, targetZone).then(function () {
- currentGroup = select.value;
+ moveSignupTo(owner, item, targetZone).then(function () {
select.disabled = false;
}).catch(function (err) {
- alert(err.message || 'Verschieben fehlgeschlagen.');
+ notify(err.message || 'Verschieben fehlgeschlagen.');
select.value = previousValue;
select.disabled = false;
});
@@ -511,5 +630,286 @@
item.appendChild(select);
});
- });
+ }
+
+ // ---- Neuen Raid erstellen ----
+ var raidCreateToggle = document.getElementById('raid-create-toggle');
+ var raidCreatePanel = document.getElementById('raid-create-panel');
+ if (raidCreateToggle && raidCreatePanel) {
+ raidCreateToggle.addEventListener('click', function () {
+ raidCreatePanel.style.display = raidCreatePanel.style.display === 'none' ? 'block' : 'none';
+ });
+ }
+
+ var raidCreateForm = document.getElementById('raid-create-form');
+ if (raidCreateForm) {
+ initGroupEditor(raidCreateForm.querySelector('.group-editor'));
+ initSlotsAuto(raidCreateForm);
+
+ raidCreateForm.addEventListener('submit', function (e) {
+ e.preventDefault();
+ var feedback = raidCreateForm.querySelector('.raid-create-feedback');
+
+ var groupNames = [];
+ var premades = [];
+ raidCreateForm.querySelectorAll('.group-editor-row').forEach(function (row) {
+ var name = groupEditorName(row);
+ if (name === '') return;
+ groupNames.push(name);
+ var premadeSelect = row.querySelector('.group-editor-premade');
+ if (premadeSelect && premadeSelect.value) {
+ premades.push({ group: groupNames.length, premade_id: premadeSelect.value });
+ }
+ });
+ if (groupNames.length === 0) {
+ feedback.textContent = 'Bitte mindestens eine Gruppe angeben.';
+ feedback.className = 'raid-create-feedback text-muted error';
+ return;
+ }
+
+ var data = {
+ title: raidCreateForm.title.value,
+ date_raw: formatDateRaw(raidCreateForm.date_local.value),
+ requirements: raidCreateForm.requirements.value,
+ gearscore: raidCreateForm.gearscore.value,
+ group_names: groupNames.join(', '),
+ max_slots: raidCreateForm.max_slots.value,
+ premades: premades
+ };
+ if (raidCreateForm.points_present && raidCreateForm.points_absent) {
+ data.points_present = raidCreateForm.points_present.value;
+ data.points_absent = raidCreateForm.points_absent.value;
+ }
+
+ feedback.textContent = premades.length ? 'Wird erstellt und die Premades werden eingeladen …' : 'Wird erstellt …';
+ feedback.className = 'raid-create-feedback text-muted';
+ postJson('/raid_create_action.php', data).then(function (result) {
+ feedback.textContent = result.message || '';
+ feedback.className = 'raid-create-feedback text-muted' + (result.status === 'success' ? '' : ' error');
+ if (result.status === 'success') {
+ setTimeout(function () { window.location.reload(); }, premades.length ? 2200 : 900);
+ }
+ }).catch(function () {
+ feedback.textContent = 'Verbindung fehlgeschlagen.';
+ });
+ });
+ }
+
+ // ---- Live-Aktualisierung ----
+ // Solange die Seite sichtbar ist, fragt sie alle 15 Sekunden nach, ob sich ein Raid geaendert hat
+ // (auch im Discord). Geaenderte Karten werden einzeln ersetzt; was gerade bearbeitet wird, bleibt
+ // unangetastet. Kommt ein Raid dazu oder faellt weg, laedt die Seite neu - oder zeigt einen
+ // Hinweis, wenn gerade etwas offen ist.
+ var raidList = document.getElementById('raid-list');
+ var liveStatus = raidList ? raidList.getAttribute('data-status') : null;
+ var POLL_MS = 15000;
+ var BACKOFF_MS = 60000;
+ var STOP = {};
+ var live = {
+ enabled: !!(raidList && liveStatus === 'active' && window.fetch),
+ timer: null,
+ soonTimer: null,
+ running: false,
+ again: false,
+ stopped: false,
+ soon: function () {
+ if (!live.enabled) return;
+ clearTimeout(live.soonTimer);
+ live.soonTimer = setTimeout(pollNow, 700);
+ }
+ };
+
+ function refreshAfterAction() {
+ if (live.enabled) {
+ pollNow();
+ } else {
+ window.location.reload();
+ }
+ }
+
+ function schedule(ms) {
+ clearTimeout(live.timer);
+ if (!live.stopped && document.visibilityState === 'visible') {
+ live.timer = setTimeout(poll, ms);
+ }
+ }
+
+ function pollNow() {
+ if (!live.enabled || live.stopped) return;
+ clearTimeout(live.timer);
+ poll();
+ }
+
+ function currentCards() {
+ return Array.prototype.slice.call(raidList.querySelectorAll('.raid-card'));
+ }
+
+ function poll() {
+ if (live.running) {
+ live.again = true;
+ return;
+ }
+ live.running = true;
+ var known = currentCards().map(function (card) {
+ return cardRaidId(card) + ':' + (card.getAttribute('data-rev') || '');
+ }).join(',');
+
+ fetch('/raids_live.php?status=' + encodeURIComponent(liveStatus) + '&known=' + encodeURIComponent(known), {
+ headers: { 'Accept': 'application/json' },
+ cache: 'no-store',
+ credentials: 'same-origin'
+ }).then(function (response) {
+ if (response.status === 401) {
+ window.location.reload(); // abgemeldet - die Seite fuehrt zur Anmeldung
+ throw STOP;
+ }
+ if (response.status === 403) {
+ live.stopped = true;
+ throw STOP;
+ }
+ return response.json();
+ }).then(function (data) {
+ if (!data || data.status !== 'success') throw new Error('Unerwartete Antwort');
+ applyUpdate(data);
+ return POLL_MS;
+ }).catch(function (err) {
+ return err === STOP ? null : BACKOFF_MS;
+ }).then(function (nextDelay) {
+ live.running = false;
+ if (live.again) {
+ live.again = false;
+ pollNow();
+ } else if (nextDelay !== null) {
+ schedule(nextDelay);
+ }
+ });
+ }
+
+ // Darf die Karte jetzt ersetzt werden? Nicht mitten im Ziehen, waehrend eine Anfrage laeuft,
+ // bei offenem Anmelde-Popup fuer diesen Raid, bei einer offenen Rueckfrage (sie gehoert evtl. zu
+ // einem Formular dieser Karte) oder mit dem Cursor in einem Feld der Karte.
+ function canSwap(card) {
+ if (document.body.classList.contains('lumina-dialog-open')) return false;
+ if (card.dataset.busy || card.querySelector('.dragging')) return false;
+ if (modal && !modal.hidden && currentRaidId === cardRaidId(card)) return false;
+ var active = document.activeElement;
+ return !(active && card.contains(active) && active.matches('input, textarea, select'));
+ }
+
+ function swapCard(oldCard, html) {
+ if (!canSwap(oldCard)) return false;
+ var template = document.createElement('template');
+ template.innerHTML = html;
+ var newCard = template.content.querySelector('.raid-card');
+ if (!newCard) return false;
+
+ var keepPanel = false;
+ if (oldCard.classList.contains('editing')) {
+ var oldPanel = oldCard.querySelector('.raid-edit-panel');
+ var newPanel = newCard.querySelector('.raid-edit-panel');
+ if (oldPanel && newPanel) {
+ // Das offene Bearbeiten-Formular samt Eingaben uebernehmen - der Rest wird frisch.
+ newPanel.replaceWith(oldPanel);
+ newCard.classList.add('editing');
+ newCard.dataset.panelKept = '1';
+ keepPanel = true;
+ if (oldCard.getAttribute('data-fields-rev') !== newCard.getAttribute('data-fields-rev')) {
+ var feedback = oldPanel.querySelector('.raid-edit-feedback');
+ if (feedback) feedback.textContent = 'Der Raid wurde inzwischen geändert – Speichern überschreibt das.';
+ }
+ }
+ }
+ newCard.hidden = oldCard.hidden;
+ oldCard.replaceWith(newCard);
+ initRaidCard(newCard, keepPanel);
+ newCard.classList.add('raid-card-updated');
+ setTimeout(function () {
+ newCard.classList.remove('raid-card-updated');
+ }, 1600);
+ return true;
+ }
+
+ function pageIsBusy() {
+ if (document.body.classList.contains('lumina-dialog-open')) return true;
+ if (raidList.querySelector('.raid-card.editing')) return true;
+ if (modal && !modal.hidden) return true;
+ if (raidCreatePanel && raidCreatePanel.style.display !== 'none') return true;
+ var active = document.activeElement;
+ return !!(active && active.matches && active.matches('input:not([type="search"]), textarea, select'));
+ }
+
+ function showChangedNotice() {
+ if (document.getElementById('raid-live-notice')) return;
+ var notice = document.createElement('div');
+ notice.id = 'raid-live-notice';
+ notice.className = 'flash flash-info raid-live-notice';
+ notice.innerHTML = 'Es gibt neue oder entfernte Raids. ';
+ var button = document.createElement('button');
+ button.type = 'button';
+ button.className = 'button-secondary button-small';
+ button.textContent = 'Seite aktualisieren';
+ button.addEventListener('click', function () {
+ window.location.reload();
+ });
+ notice.appendChild(button);
+ raidList.insertBefore(notice, raidList.firstChild);
+ }
+
+ function applyUpdate(data) {
+ var cards = {};
+ currentCards().forEach(function (card) {
+ cards[cardRaidId(card)] = card;
+ });
+ var order = Array.isArray(data.order) ? data.order.map(String) : [];
+
+ // Raid dazugekommen, weggefallen (archiviert/geloescht) oder neu gepostet (neue ID)?
+ var sameSet = order.length === Object.keys(cards).length && order.every(function (id) {
+ return cards[id] !== undefined;
+ });
+ if (!sameSet) {
+ if (pageIsBusy()) {
+ showChangedNotice();
+ } else {
+ window.location.reload();
+ }
+ return;
+ }
+
+ var swapped = false;
+ Object.keys(data.cards || {}).forEach(function (id) {
+ if (cards[id] && swapCard(cards[id], data.cards[id])) swapped = true;
+ });
+
+ // Termin verschoben? Dann die Reihenfolge anpassen (nur wenn gerade nichts offen ist).
+ var domOrder = currentCards().map(cardRaidId);
+ if (domOrder.join(',') !== order.join(',') && !pageIsBusy()) {
+ order.forEach(function (id) {
+ var card = raidList.querySelector('.raid-card[data-raid-id="' + id + '"]');
+ if (card) raidList.appendChild(card);
+ });
+ swapped = true;
+ }
+
+ if (swapped) {
+ document.dispatchEvent(new CustomEvent('raids:updated'));
+ }
+ }
+
+ // ---- Start ----
+ if (raidList) {
+ currentCards().forEach(function (card) {
+ initRaidCard(card, false);
+ });
+ }
+
+ if (live.enabled) {
+ schedule(POLL_MS);
+ document.addEventListener('visibilitychange', function () {
+ if (document.visibilityState === 'visible') {
+ pollNow();
+ } else {
+ clearTimeout(live.timer);
+ }
+ });
+ }
})();
diff --git a/assets/js/reactions.js b/assets/js/reactions.js
index 074a315..6cb873b 100644
--- a/assets/js/reactions.js
+++ b/assets/js/reactions.js
@@ -24,7 +24,7 @@
.then(function (response) { return response.json(); })
.then(function (data) {
if (!data.ok) {
- alert(data.error || 'Das hat nicht geklappt.');
+ window.luminaDialog.alert(data.error || 'Das hat nicht geklappt.', { tone: 'error' });
bar.classList.remove('is-busy');
return;
}
diff --git a/assets/js/shop.js b/assets/js/shop.js
index 622b34b..2130589 100644
--- a/assets/js/shop.js
+++ b/assets/js/shop.js
@@ -103,17 +103,7 @@
}
}
- // ---- Antraege: Grund abfragen (Ablehnen / Stornieren) ----
- document.querySelectorAll('form[data-prompt]').forEach(function (form) {
- form.addEventListener('submit', function (event) {
- var reason = window.prompt(form.dataset.prompt, '');
- if (reason === null) {
- event.preventDefault();
- return;
- }
- form.querySelector('input[name="reason"]').value = reason;
- });
- });
+ // Antraege ablehnen/stornieren: den Grund fragt data-confirm-input ab (assets/js/confirm-dialog.js).
// ---- Antraege: Teilbewilligung - Kosten passend zur eingegebenen Anzahl anzeigen ----
document.querySelectorAll('.shop-approve-quantity').forEach(function (input) {
diff --git a/assets/js/sidebar-editor.js b/assets/js/sidebar-editor.js
index 1906025..faec940 100644
--- a/assets/js/sidebar-editor.js
+++ b/assets/js/sidebar-editor.js
@@ -179,7 +179,7 @@
})
.catch(function () {
toolbar.querySelectorAll('button').forEach(function (b) { b.disabled = false; });
- window.alert('Speichern hat nicht geklappt - bitte noch einmal versuchen.');
+ window.luminaDialog.alert('Speichern hat nicht geklappt - bitte noch einmal versuchen.', { tone: 'error' });
});
}
diff --git a/assets/js/wiki-editor.js b/assets/js/wiki-editor.js
index a3dc074..7b394cb 100644
--- a/assets/js/wiki-editor.js
+++ b/assets/js/wiki-editor.js
@@ -61,21 +61,27 @@
} else if (btn.dataset.insert === 'table') {
insertBlock('| Spalte 1 | Spalte 2 | Spalte 3 |\n| --- | --- | --- |\n| Wert | Wert | Wert |\n| Wert | Wert | Wert |');
} else if (btn.dataset.insert === 'link') {
- var url = window.prompt('Adresse des Links (https://…):', 'https://');
- if (url) replaceSelection('[', '](' + url.trim() + ')', 'Linktext');
+ window.luminaDialog.prompt('Adresse des Links (https://…):', { title: 'Link einfügen', value: 'https://', okLabel: 'Einfügen' }).then(function (url) {
+ area.focus();
+ if (url) replaceSelection('[', '](' + url.trim() + ')', 'Linktext');
+ });
} else if (btn.dataset.insert === 'wikilink') {
- var title = window.prompt('Titel der Wiki-Seite, auf die verlinkt werden soll:');
- if (title) replaceSelection('', '', '[[' + title.trim() + ']]');
+ window.luminaDialog.prompt('Titel der Wiki-Seite, auf die verlinkt werden soll:', { title: 'Wiki-Link einfügen', okLabel: 'Einfügen' }).then(function (title) {
+ area.focus();
+ if (title) replaceSelection('', '', '[[' + title.trim() + ']]');
+ });
} else if (btn.dataset.insert === 'image') {
imageInput.click();
} else if (btn.dataset.insert === 'video') {
- var video = window.prompt('Link zum Video - YouTube, Twitch (Clip oder Video), Vimeo oder eine Videodatei (.mp4/.webm):', 'https://');
- if (video && /^https?:\/\/\S+$/.test(video.trim())) {
- // Allein in einer Zeile wird der Link zum eingebetteten Player
- insertBlock(video.trim());
- } else if (video && video.trim() !== 'https://') {
- window.alert('Das sieht nicht nach einem Link aus. Bitte die komplette Adresse einfügen (https://…).');
- }
+ window.luminaDialog.prompt('Link zum Video - YouTube, Twitch (Clip oder Video), Vimeo oder eine Videodatei (.mp4/.webm):', { title: 'Video einfügen', value: 'https://', okLabel: 'Einfügen' }).then(function (video) {
+ area.focus();
+ if (video && /^https?:\/\/\S+$/.test(video.trim())) {
+ // Allein in einer Zeile wird der Link zum eingebetteten Player
+ insertBlock(video.trim());
+ } else if (video && video.trim() !== 'https://') {
+ window.luminaDialog.alert('Das sieht nicht nach einem Link aus. Bitte die komplette Adresse einfügen (https://…).', { tone: 'error' });
+ }
+ });
}
});
@@ -105,12 +111,12 @@
.then(function (res) {
var replacement = res.ok ? '![' + file.name.replace(/\.[^.]+$/, '') + '](' + res.url + ')' : '';
area.value = area.value.replace(marker, replacement);
- if (!res.ok) window.alert(res.message || 'Upload fehlgeschlagen.');
+ if (!res.ok) window.luminaDialog.alert(res.message || 'Upload fehlgeschlagen.', { tone: 'error' });
area.dispatchEvent(new Event('input'));
})
.catch(function () {
area.value = area.value.replace(marker, '');
- window.alert('Upload fehlgeschlagen.');
+ window.luminaDialog.alert('Upload fehlgeschlagen.', { tone: 'error' });
});
imageInput.value = '';
});
diff --git a/assets/map/index.html b/assets/map/index.html
index b363a3b..e6873b5 100644
--- a/assets/map/index.html
+++ b/assets/map/index.html
@@ -1,9 +1,9 @@
-
+
- Aion 2 - Interactive Map Viewer
+ Aion 2 – Interaktive Karte
@@ -14,7 +14,7 @@
-
Loading map data...
+
Karte wird geladen …
@@ -32,16 +32,16 @@
👁
- +
- −
- ⟲
+ +
+ −
+ ⟲
▾
-
Categories
+ Kategorien
@@ -57,9 +57,11 @@
▾
Taktiken
+
+ Gelöschte
+ Neu
-
+
✋
✏️
@@ -70,7 +72,7 @@
📍
T
⌫
-
+ ↶
dünn
@@ -78,8 +80,6 @@
dick
sehr dick
-
- ↶
@@ -87,9 +87,14 @@
-
- ✎
- 🗑
+
+
+ ⧉
+
+ 🕘
+ ✎
+ 🗑
+
diff --git a/assets/map/js/config.js b/assets/map/js/config.js
index 471c2a6..d484343 100644
--- a/assets/map/js/config.js
+++ b/assets/map/js/config.js
@@ -44,6 +44,17 @@ const CONFIG = {
// Local maps list (generated by download scripts to avoid CORS)
MAPS_LIST: 'data/maps.json',
+ // Icons, die unter ihrem Dateinamen nicht (richtig) in data/icons liegen:
+ // Pfad aus den Markerdaten (ohne ?...) -> Dateiname in data/icons.
+ // - Die Quelle hat zwei verschiedene kibelisk.png: /admin/... (blauer Elyos-Kisk, Verteron und
+ // Abyss) und .../location/kibelisk.png (lila Asmodier-Kisk, Morheim). Lokal liegt nur die lila
+ // Datei - Verteron und Abyss bekommen deshalb den blauen kibelisk-light.png (wie Eltnen).
+ // - kibelisk2.png (Altgard) fehlt in data/icons - bis dahin der lila Asmodier-Kisk kibelisk.png.
+ ICON_ALIASES: {
+ '/admin/assets/icons/kibelisk.png': 'kibelisk-light.png',
+ '/admin/assets/icons/kibelisk2.png': 'kibelisk.png',
+ },
+
// Category symbols (emoji)
CATEGORY_SYMBOLS: {
'Settlement': '🏘️',
diff --git a/assets/map/js/controllers/LocationController.js b/assets/map/js/controllers/LocationController.js
index 2ef0e08..9242780 100644
--- a/assets/map/js/controllers/LocationController.js
+++ b/assets/map/js/controllers/LocationController.js
@@ -56,9 +56,12 @@ class LocationController {
const y = parseFloat(this.params.get('y'));
if (!this.requestedMap() || !isFinite(x) || !isFinite(y)) return;
const zoom = parseInt(this.params.get('zoom'), 10);
- this.view.zoom = Math.min(CONFIG.MAX_ZOOM, Math.max(CONFIG.MIN_ZOOM, isFinite(zoom) ? zoom : CONFIG.MIN_ZOOM + 3));
+ // Hoechstens bis zur letzten Zoomstufe dieser Karte (alte Links mit zoom=6 auf Karten bis 5)
+ this.view.zoom = Math.min(this.view.maxZoom, Math.max(CONFIG.MIN_ZOOM, isFinite(zoom) ? zoom : CONFIG.MIN_ZOOM + 3));
this.view.centerWorldX = x;
this.view.centerWorldY = y;
+ // Ort am Kartenrand: Ansicht in der Karte halten, der Pin ist dann nicht ganz mittig
+ this.view.clampView();
this.setPin(x, y, (this.params.get('ort') || '').slice(0, 60));
this.map.render();
if (this.pickMode) this.showPanel();
diff --git a/assets/map/js/controllers/MapController.js b/assets/map/js/controllers/MapController.js
index 7806e33..663fe2d 100644
--- a/assets/map/js/controllers/MapController.js
+++ b/assets/map/js/controllers/MapController.js
@@ -196,6 +196,8 @@ class MapController {
// Load tile manifest
await this.tileService.loadManifest(slug);
+ // Nur so weit zoomen, wie es Kacheln gibt (manche Karten enden bei Stufe 5)
+ this.view.maxZoom = this.tileService.maxZoom(slug);
// Load markers
try {
@@ -225,7 +227,7 @@ class MapController {
const categories = this.mapData.categories;
if (Object.keys(categories).length === 0) {
- this.categoriesList.innerHTML = '
No categories available
';
+ this.categoriesList.innerHTML = '
Für diese Karte gibt es noch keine Markierungen.
';
return;
}
@@ -256,14 +258,14 @@ class MapController {
`;
cats.forEach(cat => {
- // Use icon image if available, otherwise fallback to emoji
+ // Icon-Grafik, sonst (oder wenn sie nicht laedt, siehe unten) das Emoji der Kategorie
+ const symbol = CONFIG.CATEGORY_SYMBOLS[cat.name] || '📍';
let iconHtml = '';
if (cat.iconImage) {
const filename = cat.iconImage.split('/').pop();
- iconHtml = `
`;
+ iconHtml = `
`;
} else {
- const symbol = CONFIG.CATEGORY_SYMBOLS[cat.name] || '📍';
- iconHtml = `
${symbol} `;
+ iconHtml = `
${symbol} `;
}
html += `
@@ -281,10 +283,36 @@ class MapController {
this.categoriesList.innerHTML = html;
+ // Fehlt eine Icon-Datei, statt des kaputten Bildes das Emoji zeigen (wie auf der Karte)
+ this.categoriesList.querySelectorAll('img.category-icon').forEach(img => {
+ img.addEventListener('error', () => {
+ const span = document.createElement('span');
+ span.className = 'category-symbol';
+ span.textContent = img.dataset.symbol || '📍';
+ img.replaceWith(span);
+ }, { once: true });
+ });
+
+ // Herkunft der Markerdaten: die Zahlen kommen 1:1 von dort und sind nicht immer vollstaendig
+ const source = document.createElement('p');
+ source.className = 'category-source';
+ const stand = this.formatDate(this.mapData.extractedAt);
+ source.textContent = 'Markerdaten: interactivemap.app' + (stand ? `, Stand ${stand}` : '')
+ + ' – kann unvollständig sein';
+ this.categoriesList.appendChild(source);
+
// Attach event listeners to checkboxes
this.attachCategoryListeners();
}
+ /**
+ * "2026-09-20T14:57:12Z" -> "20.09.2026" (leer, wenn kein Datum erkennbar ist)
+ */
+ formatDate(iso) {
+ const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || ''));
+ return match ? `${match[3]}.${match[2]}.${match[1]}` : '';
+ }
+
/**
* Attach event listeners to category checkboxes
*/
diff --git a/assets/map/js/controllers/TacticController.js b/assets/map/js/controllers/TacticController.js
index 5daec45..5f8a72c 100644
--- a/assets/map/js/controllers/TacticController.js
+++ b/assets/map/js/controllers/TacticController.js
@@ -3,9 +3,12 @@
*
* Eine Taktik gehoert zu einer Region und besteht aus Schritten (Schritt 1, Schritt 2 ...),
* jeder Schritt ist eine eigene Zeichenebene. Jeder mit map.view legt eigene Taktiken an -
- * privat oder oeffentlich. Fremde oeffentliche bearbeitet nur, wer map.tactics hat, und mit
- * map.tactics.highlight lassen sie sich als "Empfohlen"/"Offiziell" markieren. Was erlaubt
- * ist, entscheidet der Server (can_create, can_highlight, pro Taktik can_edit).
+ * privat oder oeffentlich - und kann jede sichtbare Taktik als eigene Kopie anlegen. Fremde
+ * oeffentliche bearbeiten Strategen (map.tactics); mit map.tactics.highlight lassen sie sich
+ * als "Empfohlen"/"Offiziell" markieren, und nur damit bearbeitet man fremde offizielle bzw.
+ * loescht hervorgehobene. Vor Aenderungen sichert der Server den bisherigen Stand (Verlauf),
+ * geloeschte Taktiken liegen eine Weile im Papierkorb ("Gelöschte"). Was erlaubt ist,
+ * entscheidet der Server (can_create, can_highlight, pro Taktik can_edit/can_delete/...).
*/
class TacticController {
@@ -17,6 +20,7 @@ class TacticController {
this.slug = null;
this.tactics = [];
+ this.deleted = []; // Papierkorb der Region: was dieses Konto wiederherstellen darf
this.canCreate = false;
this.canHighlight = false;
this.selectedId = null;
@@ -37,6 +41,7 @@ class TacticController {
body: $('tp-body'),
collapse: $('tp-collapse'),
newBtn: $('tp-new'),
+ trash: $('tp-trash'),
list: $('tp-list'),
message: $('tp-message'),
detail: $('tp-detail'),
@@ -45,6 +50,8 @@ class TacticController {
meta: $('tp-meta'),
highlight: $('tp-highlight'),
highlightSelect: $('tp-highlight-select'),
+ copy: $('tp-copy'),
+ history: $('tp-history'),
edit: $('tp-edit'),
del: $('tp-delete'),
steps: $('tp-steps'),
@@ -90,7 +97,10 @@ class TacticController {
return this.tactics.find(t => t.id === this.selectedId) || null;
}
- /** Darf das Konto die gewaehlte Taktik bearbeiten (eigene bzw. als Leitung)? */
+ /**
+ * Darf das Konto die gewaehlte Taktik bearbeiten (eigene; fremde oeffentliche als Stratege,
+ * fremde offizielle nur mit dem Recht zum Hervorheben)?
+ */
canEditCurrent() {
const tactic = this.currentTactic();
return !!(tactic && tactic.can_edit);
@@ -121,11 +131,13 @@ class TacticController {
const data = await this.service.list(this.slug);
if (token !== this.loadToken) return;
this.tactics = data.tactics || [];
+ this.deleted = data.deleted || [];
this.canCreate = !!data.can_create;
this.canHighlight = !!data.can_highlight;
} catch (e) {
if (token !== this.loadToken) return;
this.tactics = [];
+ this.deleted = [];
this.canCreate = false;
this.canHighlight = false;
error = e;
@@ -193,6 +205,11 @@ class TacticController {
this.el.panel.classList.toggle('can-edit', this.canEditCurrent());
this.el.newBtn.classList.toggle('hidden', !this.canCreate);
+ // Papierkorb nur, wenn es hier etwas gibt, das man wiederherstellen darf
+ this.el.trash.classList.toggle('hidden', this.deleted.length === 0);
+ this.el.trash.title = this.deleted.length === 1
+ ? '1 gelöschte Taktik wiederherstellen'
+ : `${this.deleted.length} gelöschte Taktiken wiederherstellen`;
// Liste der Taktiken - hervorgehobene zuerst, dann die eigenen, dann die der anderen
if (this.tactics.length === 0) {
@@ -231,6 +248,13 @@ class TacticController {
].filter(Boolean);
this.el.meta.innerHTML = TacticController.badges(tactic) + `
${esc(meta.join(' · '))} `;
+ this.el.copy.classList.toggle('hidden', !this.canCreate);
+ // Hervorgehobene Taktiken loescht nur, wer Taktiken hervorheben darf - auch nicht der Ersteller.
+ this.el.del.disabled = !tactic.can_delete;
+ this.el.del.title = tactic.can_delete
+ ? 'Taktik löschen'
+ : 'Hervorgehobene Taktiken kann nur löschen, wer Taktiken hervorheben darf';
+
// Hervorheben: nur mit Berechtigung und nur bei oeffentlichen Taktiken
const canHighlight = this.canHighlight && tactic.visibility === 'public';
this.el.highlight.classList.toggle('hidden', !canHighlight);
@@ -364,12 +388,18 @@ class TacticController {
{ name: 'name', label: 'Name', required: true, max: 120, value: tactic.name },
{ name: 'description', label: 'Beschreibung (optional)', type: 'textarea', max: 5000, value: tactic.description }
];
- // Die Sichtbarkeit legt nur der Ersteller fest.
- if (tactic.is_mine) fields.push(TacticController.visibilityField(tactic.visibility));
- const values = await this.dialog('Taktik bearbeiten', fields);
+ // Die Sichtbarkeit legt nur der Ersteller fest - bei hervorgehobenen Taktiken nur mit dem
+ // Recht zum Hervorheben (sonst waere eine offizielle Taktik mit einem Klick fuer alle weg).
+ if (tactic.can_change_visibility) fields.push(TacticController.visibilityField(tactic.visibility));
+ const message = tactic.is_mine && !tactic.can_change_visibility
+ ? 'Die Taktik ist hervorgehoben und bleibt deshalb öffentlich – privat stellen kann sie nur, wer Taktiken hervorheben darf.'
+ : '';
+ const values = await this.dialog('Taktik bearbeiten', fields, 'Speichern', { message });
if (!values) return;
if (values.visibility === 'private' && tactic.visibility === 'public' && tactic.highlight !== 'none'
- && !confirm('Die Taktik ist hervorgehoben. Wird sie privat, geht die Hervorhebung verloren. Trotzdem privat stellen?')) {
+ && !(await this.confirmDialog('Hervorhebung geht verloren',
+ 'Die Taktik ist hervorgehoben. Wird sie privat, geht die Hervorhebung verloren und nur du siehst sie noch. Trotzdem privat stellen?',
+ 'Privat stellen'))) {
return;
}
if (await this.run('tactic_update', { tactic_id: tactic.id, ...values })) {
@@ -387,14 +417,91 @@ class TacticController {
async deleteTactic() {
const tactic = this.currentTactic();
- if (!tactic || !confirm(`Taktik „${tactic.name}“ mit allen Schritten und Zeichnungen löschen?`)) return;
+ if (!tactic || !tactic.can_delete) return;
+ const confirmed = await this.confirmDialog('Taktik löschen',
+ `Taktik „${tactic.name}“ mit allen Schritten und Zeichnungen löschen?\n`
+ + 'Unter „Gelöschte“ lässt sie sich 90 Tage lang wiederherstellen.', 'Löschen', true);
+ if (!confirmed) return;
if (await this.run('tactic_delete', { tactic_id: tactic.id })) {
this.selectedId = null;
await this.reload();
- this.toast('Taktik gelöscht.');
+ this.toast('Taktik gelöscht – unter „Gelöschte“ lässt sie sich wiederherstellen.');
}
}
+ /** Ganze Taktik als eigene Kopie anlegen - geht bei jeder Taktik, die man sehen kann. */
+ async copyTactic() {
+ const tactic = this.currentTactic();
+ if (!tactic) return;
+ const values = await this.dialog('Taktik kopieren', [
+ { name: 'name', label: 'Name der Kopie', required: true, max: 120,
+ value: Array.from(`Kopie von ${tactic.name}`).slice(0, 120).join('') },
+ TacticController.visibilityField('private')
+ ], 'Kopieren', {
+ message: 'Legt eine eigene Taktik mit allen Schritten und Zeichnungen an. Die Vorlage bleibt unverändert.'
+ });
+ if (!values) return;
+
+ const result = await this.run('tactic_copy', { tactic_id: tactic.id, ...values });
+ if (!result) return;
+ this.cancelDraft();
+ this.selectedId = result.tactic_id;
+ this.stepIndex = 0;
+ await this.reload();
+ this.toast(values.visibility === 'public'
+ ? 'Kopie angelegt – für alle sichtbar.'
+ : 'Kopie angelegt – nur du siehst sie.');
+ }
+
+ /** Verlauf: gesicherte Staende der gewaehlten Taktik ansehen und einen wiederherstellen. */
+ async showHistory() {
+ const tactic = this.currentTactic();
+ if (!tactic || !tactic.can_edit) return;
+ const result = await this.run('revision_list', { tactic_id: tactic.id });
+ if (!result) return;
+ const revisions = result.revisions || [];
+ if (revisions.length === 0) {
+ this.toast('Noch keine gesicherten Stände – sie entstehen automatisch, sobald jemand etwas ändert.');
+ return;
+ }
+
+ const values = await this.dialog(`Verlauf: ${tactic.name}`, [
+ { name: 'revision_id', label: 'Stand', type: 'select', value: String(revisions[0].id),
+ options: revisions.map(r => ({ value: String(r.id), label: r.label })) }
+ ], 'Wiederherstellen', {
+ message: 'Vor Änderungen wird der bisherige Stand automatisch gesichert (höchstens alle 30 Minuten je Person). '
+ + 'Beim Wiederherstellen kommt auch der jetzige Stand in den Verlauf – es geht also nichts verloren.'
+ });
+ if (!values) return;
+ await this.restoreRevision(parseInt(values.revision_id, 10));
+ }
+
+ /** Papierkorb: eine geloeschte Taktik dieser Region zurueckholen. */
+ async showTrash() {
+ if (this.deleted.length === 0) return;
+ const values = await this.dialog('Gelöschte Taktiken', [
+ { name: 'revision_id', label: 'Taktik', type: 'select', value: String(this.deleted[0].revision_id),
+ options: this.deleted.map(d => ({ value: String(d.revision_id), label: d.label })) }
+ ], 'Wiederherstellen', {
+ message: 'Gelöschte Taktiken lassen sich 90 Tage lang wiederherstellen – mit allen Schritten und Zeichnungen, '
+ + 'Ersteller und Sichtbarkeit wie vor dem Löschen.'
+ });
+ if (!values) return;
+ await this.restoreRevision(parseInt(values.revision_id, 10));
+ }
+
+ async restoreRevision(revisionId) {
+ const result = await this.run('revision_restore', { revision_id: revisionId });
+ if (!result) return;
+ // Schritte und Zeichnungen haben danach neue IDs - die Rueckgaengig-Liste passt nicht mehr.
+ this.cancelDraft();
+ this.undoStacks = {};
+ this.selectedId = result.tactic_id;
+ this.stepIndex = 0;
+ await this.reload();
+ this.toast(result.message || 'Wiederhergestellt.');
+ }
+
async addStep(copyCurrent) {
const tactic = this.currentTactic();
const current = this.currentStep();
@@ -435,7 +542,11 @@ class TacticController {
async deleteStep(step, index) {
const label = TacticController.stepLabel(step, index);
- if (!confirm(`Schritt ${index + 1} („${label}“) mit ${step.shapes.length} Zeichnung(en) löschen?`)) return;
+ const count = step.shapes.length;
+ const confirmed = await this.confirmDialog('Schritt löschen',
+ `Schritt ${index + 1} („${label}“) mit ${count} ${count === 1 ? 'Zeichnung' : 'Zeichnungen'} löschen?\n`
+ + 'Ein früherer Stand lässt sich über 🕘 Verlauf wiederherstellen.', 'Löschen', true);
+ if (!confirmed) return;
if (await this.run('step_delete', { step_id: step.id })) {
await this.reload();
}
@@ -684,17 +795,26 @@ class TacticController {
/**
* Zeigt einen kleinen Dialog mit Eingabefeldern. Liefert die (getrimmten) Werte oder
- * null bei Abbruch.
+ * null bei Abbruch. options.message: Text ueber den Feldern, options.danger: roter
+ * Bestaetigungsknopf. Ohne Felder ist es eine reine Rueckfrage (siehe confirmDialog).
*/
- dialog(title, fields, submitLabel = 'Speichern') {
+ dialog(title, fields, submitLabel = 'Speichern', options = {}) {
if (this.dialogCancel) this.dialogCancel();
return new Promise(resolve => {
const el = this.el;
el.dTitle.textContent = title;
el.dSubmit.textContent = submitLabel;
+ el.dSubmit.classList.toggle('td-danger', !!options.danger);
el.dFields.innerHTML = '';
+ if (options.message) {
+ const message = document.createElement('p');
+ message.className = 'td-message';
+ message.textContent = options.message;
+ el.dFields.appendChild(message);
+ }
+
fields.forEach(field => {
const label = document.createElement('label');
label.className = 'td-field';
@@ -747,11 +867,21 @@ class TacticController {
this.dialogOpen = true;
el.dialog.classList.remove('hidden');
- const first = el.dFields.querySelector('input, textarea');
- if (first) first.focus();
+ // Erstes Feld - ohne Felder der Knopf, bei Loeschfragen "Abbrechen" (Enter loescht dann nichts).
+ const first = el.dFields.querySelector('input, textarea, select')
+ || (options.danger ? el.dCancel : el.dSubmit);
+ first.focus();
});
}
+ /**
+ * Rueckfrage im Stil der Karte statt des Browser-confirm(): true bei Bestaetigung.
+ * danger: roter Knopf, z.B. mit okLabel "Löschen".
+ */
+ async confirmDialog(title, message, okLabel = 'OK', danger = false) {
+ return (await this.dialog(title, [], okLabel, { message, danger })) !== null;
+ }
+
// ------------------------------------------------------------------
// Ereignisse
// ------------------------------------------------------------------
@@ -765,6 +895,9 @@ class TacticController {
el.collapse.setAttribute('aria-expanded', String(!collapsed));
});
el.newBtn.addEventListener('click', () => this.newTactic());
+ el.trash.addEventListener('click', () => this.showTrash());
+ el.copy.addEventListener('click', () => this.copyTactic());
+ el.history.addEventListener('click', () => this.showHistory());
el.edit.addEventListener('click', () => this.editTactic());
el.del.addEventListener('click', () => this.deleteTactic());
el.highlightSelect.addEventListener('change', () => this.setHighlight(el.highlightSelect.value));
diff --git a/assets/map/js/models/MapData.js b/assets/map/js/models/MapData.js
index 816bdd2..bf79a43 100644
--- a/assets/map/js/models/MapData.js
+++ b/assets/map/js/models/MapData.js
@@ -9,6 +9,7 @@ class MapData {
this.markers = []; // Markers for current map
this.categories = {}; // Category metadata (group/name -> info)
this.visibleCategories = new Set();
+ this.extractedAt = ''; // Stand der Markerdaten (extracted_at_utc), fuer den Hinweis unter den Kategorien
}
/**
@@ -33,6 +34,7 @@ class MapData {
this.markers = [];
this.categories = {};
this.visibleCategories.clear();
+ this.extractedAt = '';
}
return map;
}
@@ -45,6 +47,7 @@ class MapData {
// Parse and normalize marker data
const rawMarkers = jsonData.markers || [];
+ this.extractedAt = jsonData.extracted_at_utc || '';
this.markers = rawMarkers.map(m => ({
id: m.id,
@@ -58,7 +61,7 @@ class MapData {
iconText: m.properties?.icon_text || '',
nt: m.properties?.nt || '',
iconName: m.properties?.icon_name || '',
- iconImage: m.properties?.icon_image ? m.properties.icon_image.split('?')[0] : ''
+ iconImage: this.iconPath(m.properties?.icon_image)
}));
// Build category metadata
@@ -80,6 +83,16 @@ class MapData {
// (einzeln, per Gruppe oder mit "Alle anzeigen").
}
+ /**
+ * Icon-Pfad aus den Markerdaten ohne ?... - ueber CONFIG.ICON_ALIASES auf die passende Datei
+ * in data/icons umgebogen. Karte und Kategorienliste lesen beide iconImage.
+ */
+ iconPath(raw) {
+ if (!raw) return '';
+ const path = String(raw).split('?')[0];
+ return CONFIG.ICON_ALIASES[path] || path;
+ }
+
/**
* Toggle visibility of a category
*/
diff --git a/assets/map/js/services/TileService.js b/assets/map/js/services/TileService.js
index 30f7c64..46ab8d9 100644
--- a/assets/map/js/services/TileService.js
+++ b/assets/map/js/services/TileService.js
@@ -27,6 +27,24 @@ class TileService {
}
}
+ /**
+ * Hoechste Zoomstufe dieser Karte = hoechste Stufe mit Kacheln im Manifest. Eltnen, Morheim
+ * und die beiden Chaotic-Karten haben nur Kacheln bis Stufe 5 - darueber waere alles leer.
+ * Ohne Manifest (oder ohne Kacheln darin) gilt CONFIG.MAX_ZOOM.
+ */
+ maxZoom(slug) {
+ const manifest = this.manifests[slug];
+ if (!manifest || manifest.size === 0) return CONFIG.MAX_ZOOM;
+
+ let max = CONFIG.MIN_ZOOM;
+ for (const key of manifest) {
+ // Schluessel "zoom_x_y", z.B. "5_12_7"
+ const zoom = parseInt(key, 10);
+ if (zoom > max) max = zoom;
+ }
+ return Math.min(max, CONFIG.MAX_ZOOM);
+ }
+
/**
* Check if a tile exists in the manifest
*/
diff --git a/assets/map/js/views/MapView.js b/assets/map/js/views/MapView.js
index 3ba0fac..86dc04c 100644
--- a/assets/map/js/views/MapView.js
+++ b/assets/map/js/views/MapView.js
@@ -9,12 +9,18 @@ class MapView {
// View state
this.zoom = CONFIG.MIN_ZOOM + 1;
+ // Hoechste Zoomstufe der aktuellen Karte - MapController.loadMap setzt sie aus dem
+ // Kachel-Manifest (manche Karten haben nur Kacheln bis Stufe 5).
+ this.maxZoom = CONFIG.MAX_ZOOM;
this.centerWorldX = (CONFIG.WORLD_MIN_X + CONFIG.WORLD_MAX_X) / 2;
this.centerWorldY = (CONFIG.WORLD_MIN_Y + CONFIG.WORLD_MAX_Y) / 2;
// Icon cache
this.iconCache = {};
- this.loadingIcons = new Set();
+ this.loadingIcons = new Map(); // Dateiname -> Promise des laufenden Ladens
+ // Icons, die nicht geladen werden konnten - nicht bei jedem Neuzeichnen wieder anfragen,
+ // sondern gleich das Emoji zeichnen.
+ this.failedIcons = new Set();
// Interaction state
this.isDragging = false;
@@ -29,6 +35,8 @@ class MapView {
resize() {
this.canvas.width = window.innerWidth;
this.canvas.height = window.innerHeight;
+ // Anderes Seitenverhaeltnis (z.B. Handy gedreht): Ansicht wieder in die Karte holen
+ this.clampView();
}
/**
@@ -112,6 +120,10 @@ class MapView {
const camOffsetX = -this.centerWorldX * scale + width / 2;
const camOffsetY = -this.centerWorldY * scale + height / 2;
+ // Aendert sich die Ansicht, waehrend dieses Bild noch auf Kacheln oder Icons wartet, hoert
+ // es auf (sonst landen Kacheln und Marker an der alten Stelle ueber dem neuen Bild).
+ const isStale = this.staleCheck(tileService, mapData);
+
// Draw tiles at current zoom level
const tilesPerSide = Math.pow(2, this.zoom);
const tileWorldSize = worldWidth / tilesPerSide;
@@ -136,6 +148,7 @@ class MapView {
}
const tileImg = await tileService.loadTile(slug, this.zoom, tx, ty);
+ if (isStale()) return;
if (tileImg) {
ctx.drawImage(tileImg, screenX, screenY, tileScreenSize, tileScreenSize);
@@ -148,13 +161,41 @@ class MapView {
}
// Draw markers
- this.drawMarkers(mapData);
+ this.drawMarkers(mapData, isStale);
// Preload adjacent zoom levels in background
const viewBounds = this.getViewBounds();
tileService.preloadAdjacentZoomLevels(slug, this.zoom, viewBounds);
}
+ /**
+ * Prueft fuer ein laufendes Bild, ob sich die Ansicht (Karte, Zoom, Position, Groesse) seit
+ * seinem Start geaendert hat. Dann ist es veraltet und stoesst einmal ein frisches Bild an -
+ * so erscheint, was es gerade fertig geladen hat, trotzdem an der richtigen Stelle.
+ * Ein Kartenwechsel zeichnet loadMap selbst neu, sobald die neue Karte geladen ist.
+ */
+ staleCheck(tileService, mapData) {
+ const map = mapData.currentMap;
+ const zoom = this.zoom;
+ const centerX = this.centerWorldX;
+ const centerY = this.centerWorldY;
+ const width = this.canvas.width;
+ const height = this.canvas.height;
+ let stale = false;
+
+ return () => {
+ if (stale) return true;
+ if (mapData.currentMap === map && this.zoom === zoom
+ && this.centerWorldX === centerX && this.centerWorldY === centerY
+ && this.canvas.width === width && this.canvas.height === height) {
+ return false;
+ }
+ stale = true;
+ if (mapData.currentMap === map) this.requestRender(tileService, mapData);
+ return true;
+ };
+ }
+
/**
* Load an icon image from local data directory
*/
@@ -167,37 +208,42 @@ class MapView {
return this.iconCache[filename];
}
+ // Datei fehlt oder ist kaputt: nicht erneut anfragen, gleich das Emoji zeichnen
+ if (this.failedIcons.has(filename)) {
+ return null;
+ }
+
+ // Laedt schon (z.B. fuer ein frueheres Bild): auf dasselbe Laden warten
if (this.loadingIcons.has(filename)) {
- await new Promise(r => setTimeout(r, 10));
- return this.iconCache[filename] || null;
+ return this.loadingIcons.get(filename);
}
-
- this.loadingIcons.add(filename);
-
- try {
+
+ const loading = new Promise(resolve => {
const img = new Image();
+ // Langsam: vorerst das Emoji - kommt das Bild spaeter doch noch, nimmt es das naechste Bild
+ const timer = setTimeout(() => resolve(null), 3000);
+ img.onload = () => {
+ clearTimeout(timer);
+ this.iconCache[filename] = img;
+ resolve(img);
+ };
+ img.onerror = () => {
+ clearTimeout(timer);
+ this.failedIcons.add(filename);
+ resolve(null);
+ };
img.src = `${CONFIG.ICONS_DIR}/${filename}`;
-
- await new Promise((resolve, reject) => {
- img.onload = resolve;
- img.onerror = () => reject(new Error('Load failed'));
- setTimeout(() => reject(new Error('Timeout')), 3000);
- });
-
- this.iconCache[filename] = img;
- } catch (e) {
- // Silently fail for missing icons
- } finally {
- this.loadingIcons.delete(filename);
- }
-
- return this.iconCache[filename] || null;
+ });
+ this.loadingIcons.set(filename, loading);
+ loading.then(() => this.loadingIcons.delete(filename));
+
+ return loading;
}
/**
* Draw all visible markers using icon images
*/
- async drawMarkers(mapData) {
+ async drawMarkers(mapData, isStale = () => false) {
const ctx = this.ctx;
for (const marker of mapData.markers) {
@@ -206,14 +252,17 @@ class MapView {
const iconSize = this.markerSize();
- const screen = this.worldToScreen(marker.worldX, marker.worldY);
-
// Try to load and draw icon image
let iconImg = null;
if (marker.iconImage) {
iconImg = await this.loadIcon(marker.iconImage);
+ // Ansicht hat sich beim Warten geaendert: nicht an der alten Stelle weiterzeichnen
+ if (isStale()) return;
}
+ // Position erst nach dem Warten bestimmen
+ const screen = this.worldToScreen(marker.worldX, marker.worldY);
+
if (iconImg) {
// Draw icon image centered at marker position
ctx.drawImage(iconImg,
@@ -247,8 +296,10 @@ class MapView {
* Zoom in
*/
zoomIn() {
- if (this.zoom < CONFIG.MAX_ZOOM) {
+ // Nur bis zur hoechsten Stufe dieser Karte - darueber gibt es keine Kacheln
+ if (this.zoom < this.maxZoom) {
this.zoom++;
+ this.clampView();
return true;
}
return false;
@@ -260,6 +311,7 @@ class MapView {
zoomOut() {
if (this.zoom > CONFIG.MIN_ZOOM) {
this.zoom--;
+ this.clampView();
return true;
}
return false;
@@ -283,19 +335,18 @@ class MapView {
* Reset view to default
*/
resetView() {
- this.zoom = CONFIG.MIN_ZOOM + 1;
+ this.zoom = Math.min(CONFIG.MIN_ZOOM + 1, this.maxZoom);
this.centerWorldX = (CONFIG.WORLD_MIN_X + CONFIG.WORLD_MAX_X) / 2;
this.centerWorldY = (CONFIG.WORLD_MIN_Y + CONFIG.WORLD_MAX_Y) / 2;
+ this.clampView();
}
/**
* Pan by screen delta
*/
panBy(dx, dy) {
- const worldWidth = CONFIG.WORLD_MAX_X - CONFIG.WORLD_MIN_X;
- const zoomScale = Math.pow(2, this.zoom - CONFIG.MIN_ZOOM);
- const visibleWidth = worldWidth / zoomScale;
- const scale = this.canvas.width / visibleWidth;
+ const scale = this.worldScale();
+ if (!scale) return;
// Each screen pixel represents 1/scale world units
const worldDx = -(dx / scale);
@@ -304,16 +355,37 @@ class MapView {
this.centerWorldX += worldDx;
this.centerWorldY += worldDy;
- // Clamp to world bounds
- const margin = 0.1;
- this.centerWorldX = Math.max(
- CONFIG.WORLD_MIN_X + worldWidth * margin,
- Math.min(CONFIG.WORLD_MAX_X - worldWidth * margin, this.centerWorldX)
- );
- this.centerWorldY = Math.max(
- CONFIG.WORLD_MIN_Y + (CONFIG.WORLD_MAX_Y - CONFIG.WORLD_MIN_Y) * margin,
- Math.min(CONFIG.WORLD_MAX_Y - (CONFIG.WORLD_MAX_Y - CONFIG.WORLD_MIN_Y) * margin, this.centerWorldY)
- );
+ // Nicht ueber den Kartenrand hinaus ziehen
+ this.clampView();
+ }
+
+ /**
+ * Bildschirmpixel pro Welteinheit bei der aktuellen Zoomstufe
+ */
+ worldScale() {
+ const worldWidth = CONFIG.WORLD_MAX_X - CONFIG.WORLD_MIN_X;
+ const visibleWidth = worldWidth / Math.pow(2, this.zoom - CONFIG.MIN_ZOOM);
+ return this.canvas.width / visibleWidth;
+ }
+
+ /**
+ * Ansicht in der Karte halten: Ist der sichtbare Bereich auf einer Achse groesser als die Karte
+ * (z.B. Handy hochkant ganz herausgezoomt), steht die Karte auf dieser Achse mittig; sonst
+ * bleiben die Raender der Ansicht innerhalb der Karte - kein Ziehen ins Leere.
+ */
+ clampView() {
+ const scale = this.worldScale();
+ // Noch ohne Groesse (z.B. Rahmen unsichtbar): nichts zu begrenzen
+ if (!scale || !this.canvas.height) return;
+
+ const clampAxis = (center, min, max, halfVisible) => {
+ if (!isFinite(center) || max - min <= halfVisible * 2) return (min + max) / 2;
+ return Math.min(max - halfVisible, Math.max(min + halfVisible, center));
+ };
+ this.centerWorldX = clampAxis(this.centerWorldX, CONFIG.WORLD_MIN_X, CONFIG.WORLD_MAX_X,
+ this.canvas.width / scale / 2);
+ this.centerWorldY = clampAxis(this.centerWorldY, CONFIG.WORLD_MIN_Y, CONFIG.WORLD_MAX_Y,
+ this.canvas.height / scale / 2);
}
/**
diff --git a/assets/map/scripts/download_marker_icons.py b/assets/map/scripts/download_marker_icons.py
index dd63bdf..7afe470 100644
--- a/assets/map/scripts/download_marker_icons.py
+++ b/assets/map/scripts/download_marker_icons.py
@@ -56,12 +56,39 @@ def collect_unique_icons(markers_dir):
return icons
-def download_icon(icon_path, out_dir):
- """Download a single icon. Returns status string."""
+def pick_one_path_per_filename(icon_paths):
+ """Ordnet jedem Dateinamen genau einen Quellpfad zu.
+
+ Die Icons werden nur unter ihrem Dateinamen gespeichert (der Viewer sucht sie genauso).
+ Teilen sich mehrere Quellpfade einen Namen, wird nur einer geladen - sonst schreiben zwei
+ Downloads gleichzeitig in dieselbe Datei und es ist Zufall, welches Bild uebrig bleibt.
+ Beispiel: /admin/assets/icons/kibelisk.png (blauer Kisk) und
+ /aion2/maps/admin/assets/icons/location/kibelisk.png (lila Kisk).
+
+ Rueckgabe: (Dateiname -> geladener Pfad, Dateiname -> alle Pfade bei Kollisionen)
+ """
+ by_name = {}
+ for path in icon_paths:
+ by_name.setdefault(os.path.basename(path), []).append(path)
+
+ chosen = {}
+ collisions = {}
+ for name in sorted(by_name):
+ # Feste Reihenfolge statt Zufall: Pfade unter /aion2/maps/... (dort liegen fast alle
+ # Icons) zuerst. Die uebrigen biegt der Viewer ueber CONFIG.ICON_ALIASES (js/config.js) um.
+ paths = sorted(by_name[name], key=lambda p: (not p.startswith("/aion2/"), p))
+ chosen[name] = paths[0]
+ if len(paths) > 1:
+ collisions[name] = paths
+ return chosen, collisions
+
+
+def download_icon(icon_path, out_dir, retries=3):
+ """Download a single icon. Returns (status, filename)."""
# Extract filename from path
filename = os.path.basename(icon_path)
if not filename:
- return "error:no-filename", ""
+ return "error:no-filename", icon_path
dest = os.path.join(out_dir, filename)
@@ -69,27 +96,36 @@ def download_icon(icon_path, out_dir):
return "exists", filename
url = BASE_URL + icon_path
+ tmp = dest + ".part"
+ status = "error:unknown"
+ # Bis zu 3 Versuche wie fetch_tile in download_all_maps.py; 404 gibt es an der Quelle nicht.
+ for attempt in range(1, retries + 1):
+ try:
+ req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT})
+ with urllib.request.urlopen(req, timeout=30) as resp:
+ data = resp.read()
+ if data:
+ with open(tmp, "wb") as fh:
+ fh.write(data)
+ os.replace(tmp, dest)
+ return "ok", filename
+ status = "empty"
+ except urllib.error.HTTPError as e:
+ if e.code == 404:
+ return "missing", filename
+ status = f"error:HTTP {e.code}"
+ except Exception as e:
+ status = f"error:{e!r}"
+ if attempt < retries:
+ time.sleep(0.5 * attempt)
+
+ # Halbe Datei eines abgebrochenen Versuchs nicht liegen lassen
try:
- req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT})
- with urllib.request.urlopen(req, timeout=30) as resp:
- data = resp.read()
-
- if not data:
- return "empty", filename
-
- tmp = dest + ".part"
- with open(tmp, "wb") as fh:
- fh.write(data)
- os.replace(tmp, dest)
- return "ok", filename
-
- except urllib.error.HTTPError as e:
- if e.code == 404:
- return "missing", filename
- return f"error:{e.code}", filename
- except Exception as e:
- return f"error:{repr(e)}", filename
+ os.unlink(tmp)
+ except OSError:
+ pass
+ return status, filename
def main():
@@ -101,7 +137,7 @@ def main():
parser.add_argument("-w", "--workers", type=int, default=16,
help="Number of concurrent downloads")
args = parser.parse_args()
-
+
# Resolve directories relative to script location
script_dir = os.path.dirname(os.path.abspath(__file__))
markers_dir = os.path.join(script_dir, args.markers_dir) if not os.path.isabs(args.markers_dir) else args.markers_dir
@@ -114,37 +150,62 @@ def main():
print("No icons found. Run extract_all_markers.py first.")
sys.exit(1)
+ # Pro Dateiname nur ein Download (siehe pick_one_path_per_filename)
+ chosen, collisions = pick_one_path_per_filename(icon_paths)
+ if collisions:
+ print(f"\nWARNING: {len(collisions)} file name(s) are used by different source paths.")
+ print(" Only one path per name is downloaded (an existing file is kept as it is).")
+ print(" The viewer maps the other paths via CONFIG.ICON_ALIASES in js/config.js - check it:")
+ for name, paths in collisions.items():
+ print(f" {name}")
+ print(f" saved as {name}: {paths[0]}")
+ for other in paths[1:]:
+ print(f" not downloaded: {other}")
+
# Create output directory
os.makedirs(out_dir, exist_ok=True)
# Download all icons
- print(f"\nDownloading {len(icon_paths)} icons to: {out_dir}")
+ total = len(chosen)
+ print(f"\nDownloading {total} icons to: {out_dir}")
- counts = {"ok": 0, "exists": 0, "missing": 0, "error": 0}
+ counts = {"ok": 0, "exists": 0, "missing": 0, "empty": 0, "error": 0}
+ problems = [] # (Dateiname, Status, Quellpfad) - am Ende mit Namen ausgeben
done = 0
t0 = time.time()
with ThreadPoolExecutor(max_workers=args.workers) as pool:
futures = {}
- for icon_path in icon_paths:
+ for icon_path in chosen.values():
futures[pool.submit(download_icon, icon_path, out_dir)] = icon_path
for fut in as_completed(futures):
+ icon_path = futures[fut]
status, filename = fut.result()
kind = status.split(":", 1)[0]
- counts[kind] += 1
+ counts[kind] = counts.get(kind, 0) + 1
+ if kind not in ("ok", "exists"):
+ problems.append((filename, status, icon_path))
done += 1
- if done % max(1, len(icon_paths) // 10) == 0 or done == len(icon_paths):
+ if done % max(1, total // 10) == 0 or done == total:
rate = done / max(time.time() - t0, 1e-6)
- print(f" {done}/{len(icon_paths)} ({rate:.1f}/s) "
- f"ok={counts['ok']} cached={counts['exists']} missing={counts['missing']} err={counts['error']}",
+ print(f" {done}/{total} ({rate:.1f}/s) "
+ f"ok={counts['ok']} cached={counts['exists']} missing={counts['missing']} "
+ f"empty={counts['empty']} err={counts['error']}",
flush=True)
elapsed = time.time() - t0
print(f"\nDone in {elapsed:.0f}s: downloaded={counts['ok']} cached={counts['exists']} "
- f"missing={counts['missing']} failed={counts['error']}")
+ f"missing={counts['missing']} empty={counts['empty']} failed={counts['error']}")
print(f"Icons saved to: {out_dir}")
+
+ if problems:
+ print(f"\n{len(problems)} icon(s) could not be downloaded:")
+ for filename, status, icon_path in sorted(problems):
+ print(f" {filename} [{status}] {BASE_URL}{icon_path}")
+ if collisions:
+ print(f"\nNote: {len(collisions)} file name collision(s), see the warning above.")
if __name__ == "__main__":
diff --git a/assets/map/styles.css b/assets/map/styles.css
index 7c4c26d..96202ea 100644
--- a/assets/map/styles.css
+++ b/assets/map/styles.css
@@ -394,6 +394,30 @@ button:hover {
margin-left: 4px;
}
+/* Emoji statt Icon-Grafik (Datei fehlt) - gleicher Platz wie .category-icon */
+.category-symbol {
+ width: 16px;
+ margin-right: 8px;
+ font-size: 12px;
+ line-height: 16px;
+ text-align: center;
+}
+
+/* Karte ohne Markerdaten */
+.category-empty {
+ font-size: 12px;
+ color: var(--text-secondary);
+}
+
+/* Hinweis unter der Liste: woher die Markerdaten stammen */
+.category-source {
+ padding-top: 8px;
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
+ font-size: 10px;
+ line-height: 1.4;
+ color: #888;
+}
+
/* Zoom indicator */
#zoom-indicator {
position: absolute;
@@ -537,6 +561,16 @@ button.tp-btn {
padding: 4px 8px;
}
+/* "Gelöschte" (Papierkorb) im Kopf des Panels: dezenter als "+ Neu" */
+button#tp-trash {
+ background: none;
+ color: var(--text-secondary);
+}
+
+button#tp-trash:hover {
+ color: var(--accent-gold);
+}
+
button.tp-icon {
background: none;
border: 1px solid transparent;
@@ -726,6 +760,14 @@ button.tp-item.tp-item-recommended {
overflow-wrap: anywhere;
}
+/* Knoepfe rechts neben dem Namen: Kopieren (fuer alle) und die Bearbeiten-Knoepfe in einer
+ Gruppe - sonst rutscht der Kopieren-Knopf durch space-between in die Mitte. */
+.tp-head-tools {
+ display: flex;
+ align-items: center;
+ flex-shrink: 0;
+}
+
.tp-desc {
margin-top: 6px;
font-size: 12px;
@@ -820,11 +862,13 @@ button.tp-item.tp-item-recommended {
accent-color: var(--accent-gold);
}
-/* Werkzeugleiste im Taktik-Panel - bleibt auch beim Einklappen sichtbar */
+/* Werkzeugleiste im Taktik-Panel - bleibt auch beim Einklappen sichtbar. Raster mit 7 gleich
+ grossen Feldern: oben die 7 Zeichenwerkzeuge, unten Text, Radierer, Rueckgaengig, Farbe und
+ Strichstaerke (3 Felder breit). Passt ohne Umbruch-Luecken aufs Panel und aufs Handy. */
#tactic-toolbar {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
+ display: grid;
+ grid-template-columns: repeat(7, minmax(0, 1fr));
+ grid-auto-rows: 32px;
gap: 4px;
margin-top: 8px;
padding-top: 8px;
@@ -836,10 +880,15 @@ button.tp-item.tp-item-recommended {
}
#tactic-toolbar .tool {
- min-width: 30px;
- height: 30px;
- padding: 0 5px;
- font-size: 14px;
+ width: 100%;
+ min-width: 0;
+ height: 100%;
+ padding: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 15px;
+ line-height: 1;
}
#tactic-toolbar .tool.active {
@@ -847,31 +896,44 @@ button.tp-item.tp-item-recommended {
background: rgba(255, 215, 0, 0.2);
}
-.tool-sep {
- width: 1px;
- height: 22px;
- margin: 0 2px;
- background: var(--border-color);
-}
-
#tool-color {
- width: 30px;
- height: 30px;
- padding: 2px;
+ width: 100%;
+ min-width: 0;
+ height: 100%;
+ padding: 3px;
border: 1px solid var(--border-color);
border-radius: 4px;
background: rgba(50, 50, 80, 0.8);
cursor: pointer;
}
+/* Das Farbfeld fuellt den Knopf ganz aus. Die Regeln bleiben getrennt: ein unbekanntes
+ Pseudo-Element macht sonst die ganze Regel ungueltig (Chrome kennt ::-moz-..., Firefox ::-webkit-... nicht). */
+#tool-color::-webkit-color-swatch-wrapper {
+ padding: 0;
+}
+
+#tool-color::-webkit-color-swatch {
+ border: none;
+ border-radius: 2px;
+}
+
+#tool-color::-moz-color-swatch {
+ border: none;
+ border-radius: 2px;
+}
+
#tool-width {
- height: 30px;
+ grid-column: span 3;
+ width: 100%;
+ min-width: 0;
+ height: 100%;
padding: 0 6px;
border: 1px solid var(--border-color);
border-radius: 4px;
background: rgba(50, 50, 80, 0.8);
color: var(--text-primary);
- font-size: 12px;
+ font-size: 13px;
}
/* Schritt-Leiste unten mittig zwischen Kategorien-Panel (links, 300px) und
@@ -980,6 +1042,27 @@ button.tp-item.tp-item-recommended {
background: rgba(255, 215, 0, 0.2);
}
+/* Rueckfrage (confirmDialog) bzw. Hinweis ueber den Feldern */
+.td-message {
+ margin-bottom: 12px;
+ font-size: 13px;
+ line-height: 1.45;
+ color: var(--text-primary);
+ white-space: pre-line;
+ overflow-wrap: anywhere;
+}
+
+/* Loeschen & Co.: roter Bestaetigungsknopf */
+#td-submit.td-danger {
+ border-color: #ff6b6b;
+ background: rgba(255, 107, 107, 0.2);
+ color: #ffd0d0;
+}
+
+#td-submit.td-danger:hover {
+ background: rgba(255, 107, 107, 0.35);
+}
+
/* Kurze Rueckmeldungen */
#toast {
position: absolute;
diff --git a/bot_api.php b/bot_api.php
index 1fc11e6..77f68a9 100644
--- a/bot_api.php
+++ b/bot_api.php
@@ -62,6 +62,8 @@ if (!empty($discordIds)) {
$recipients = array_map('strval', $stmt->fetchAll(PDO::FETCH_COLUMN));
}
+// Raidbeginn: Einstellungen (fester Punkt) auch fuer im Discord erstellte Raids anlegen.
+raid_settings_ensure_defaults([(int) $raidId]);
$settings = raid_settings_get((int) $raidId);
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = (string) ($_SERVER['HTTP_HOST'] ?? '');
diff --git a/bugs.php b/bugs.php
index b07c248..bee42de 100644
--- a/bugs.php
+++ b/bugs.php
@@ -135,7 +135,7 @@ include __DIR__ . '/includes/header.php';
Noch nicht bearbeitet
-
+
= csrf_field() ?>
diff --git a/calendar.php b/calendar.php
index 384adec..ada5543 100644
--- a/calendar.php
+++ b/calendar.php
@@ -12,6 +12,7 @@ require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raids_api.php';
require_once __DIR__ . '/includes/events_api.php';
require_once __DIR__ . '/includes/member_profile.php'; // gallery_comment_html() fuer Beschreibungen
+require_once __DIR__ . '/includes/calendar_audience.php';
$me = current_user();
$loggedIn = $me !== null && $me['status'] === 'active';
@@ -29,6 +30,8 @@ $canCreate = $loggedIn && user_has_permission('members.view');
$isModerator = $loggedIn && moderation_can();
$myId = $loggedIn ? (int) $me['id'] : 0;
$canTogglePublic = $loggedIn && user_has_permission('events.manage');
+// Leitung (calendar.leadership): traegt Termine nur fuer die Leitung ein und sieht interne Termine
+$canLead = $loggedIn && calendar_can_lead();
// Angezeigter Monat (?month=2026-09), Standard: aktueller Monat
$monthParam = (string) ($_GET['month'] ?? '');
@@ -108,15 +111,17 @@ if ($showEvents) {
// ---- Termine der Mitglieder ----
if ($showMember) {
try {
- // Noch nicht freigegebene sehen nur der Verfasser und die Moderation
+ // Noch nicht freigegebene sehen nur der Verfasser und die Moderation, interne Termine nur die
+ // Leitung (auch im oeffentlichen Kalender nicht).
$stmt = db()->prepare(
"SELECT e.*, COALESCE(NULLIF(u.display_name, ''), u.username) AS author, u.avatar_filename, u.username, u.display_name
FROM calendar_entries e JOIN users u ON u.id = e.user_id
WHERE e.starts_at >= ? AND e.starts_at < ? AND u.status = 'active'
AND (e.status = 'visible' OR e.user_id = ? OR ?)
+ AND (e.audience <> 'internal' OR ? OR e.user_id = ?)
ORDER BY e.starts_at"
);
- $stmt->execute([date('Y-m-d H:i:s', $monthStart), date('Y-m-d H:i:s', $monthEnd), $myId, $isModerator ? 1 : 0]);
+ $stmt->execute([date('Y-m-d H:i:s', $monthStart), date('Y-m-d H:i:s', $monthEnd), $myId, $isModerator ? 1 : 0, $canLead ? 1 : 0, $myId]);
$memberEntries = $stmt->fetchAll();
$participants = [];
@@ -151,6 +156,7 @@ if ($showMember) {
'people' => $people,
'joined' => in_array($myId, array_map('intval', array_column($people, 'id')), true),
'reported' => isset($reportedEntries[$id]),
+ 'audience' => (string) ($row['audience'] ?? 'all'),
];
}
} catch (PDOException $e) {
@@ -184,8 +190,18 @@ $locationField = static function (?array $row): string {
. ' ';
};
+/** Nur fuer die Leitung: fuer wen der Termin ist (includes/calendar_audience.php). */
+$audienceField = static function (?array $row): string {
+ $current = (string) ($row['audience'] ?? 'all');
+ $options = '';
+ foreach (CALENDAR_AUDIENCES as $value => $label) {
+ $options .= '
' . e($label) . ' ';
+ }
+ return '
Für wen?' . $options . ' ';
+};
+
/** Formularfelder fuer "Termin eintragen" und "Bearbeiten". */
-$entryFields = static function (?array $row) use ($locationField): string {
+$entryFields = static function (?array $row) use ($locationField, $audienceField, $canLead): string {
$start = $row ? date('Y-m-d\TH:i', strtotime((string) $row['starts_at'])) : date('Y-m-d\T20:00', strtotime('+1 day'));
$end = $row && $row['ends_at'] ? date('Y-m-d\TH:i', strtotime((string) $row['ends_at'])) : '';
return '
Titel '
@@ -195,7 +211,8 @@ $entryFields = static function (?array $row) use ($locationField): string {
. '
'
. '
Beschreibung (optional) '
. e((string) ($row['description'] ?? '')) . ' '
- . $locationField($row);
+ . $locationField($row)
+ . ($canLead ? $audienceField($row) : '');
};
$pageTitle = 'Kalender';
@@ -257,16 +274,21 @@ include __DIR__ . '/includes/header.php';
?>
= (int) date('j', $day) ?>
-
-
- <= $tag ?> class="calendar-entry calendar-= $entry['type'] ?>= $entry['past'] ? ' is-past' : '' ?>"
- = $entry['url'] ? 'href="' . e($entry['url']) . '"' : '' ?>
- title="= e(date('H:i', $entry['time']) . ' Uhr · ' . $entry['title'] . ($entry['detail'] !== '' ? ' · ' . $entry['detail'] : '')) ?>">
-
= date('H:i', $entry['time']) ?> = e($entry['title']) ?>
- = $tag ?>>
-
- 3): ?>
-
+= count($dayEntries) - 3 ?> weitere
+
+
+
+
+
+ <= $tag ?> class="calendar-entry calendar-= $entry['type'] ?>= $entry['past'] ? ' is-past' : '' ?>"
+ = $entry['url'] ? 'href="' . e($entry['url']) . '"' : '' ?>
+ title="= e(date('H:i', $entry['time']) . ' Uhr · ' . ($isInternal ? '🔒 ' : '') . $entry['title'] . ($entry['detail'] !== '' ? ' · ' . $entry['detail'] : '')) ?>">
+ = date('H:i', $entry['time']) ?> = $isInternal ? '🔒 ' : '' ?>= e($entry['title']) ?>
+ = $tag ?>>
+
+
diff --git a/calendar_action.php b/calendar_action.php
index 72224da..1c340ea 100644
--- a/calendar_action.php
+++ b/calendar_action.php
@@ -5,6 +5,7 @@
* Mitglieder erst nach Freigabe, Tempolimit).
*/
require_once __DIR__ . '/includes/bootstrap.php';
+require_once __DIR__ . '/includes/calendar_audience.php';
require_permission('members.view');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
@@ -18,6 +19,7 @@ const CALENDAR_DESCRIPTION_MAX = 1000;
$action = (string) ($_POST['action'] ?? '');
$me = current_user();
$myId = (int) $me['id'];
+$canLead = calendar_can_lead();
$pdo = db();
/** Zurueck in den Monat des Termins, direkt zum Eintrag. */
@@ -90,9 +92,10 @@ switch ($action) {
redirect($backTo($startsAt));
}
[$status, $note] = moderation_initial_status('calendar', $text);
+ $audience = calendar_audience_input(null, $canLead);
$pdo->prepare(
- 'INSERT INTO calendar_entries (user_id, title, description, starts_at, ends_at, location_path, status, moderation_note) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
- )->execute([$myId, $title, $description, $startsAt, $endsAt, $locationPath, $status, $note]);
+ 'INSERT INTO calendar_entries (user_id, title, description, starts_at, ends_at, location_path, audience, status, moderation_note) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'
+ )->execute([$myId, $title, $description, $startsAt, $endsAt, $locationPath, $audience, $status, $note]);
$entryId = (int) $pdo->lastInsertId();
// Wer einlaedt, ist natuerlich dabei
$pdo->prepare('INSERT INTO calendar_participants (entry_id, user_id) VALUES (?, ?)')->execute([$entryId, $myId]);
@@ -118,16 +121,17 @@ switch ($action) {
if ($entry['status'] === 'pending') {
[$status, $note] = ['pending', $entry['moderation_note']];
}
+ $audience = calendar_audience_input((string) ($entry['audience'] ?? 'all'), $canLead);
$pdo->prepare(
- 'UPDATE calendar_entries SET title = ?, description = ?, starts_at = ?, ends_at = ?, location_path = ?, status = ?, moderation_note = ?, updated_at = ? WHERE id = ?'
- )->execute([$title, $description, $startsAt, $endsAt, $locationPath, $status, $note, date('Y-m-d H:i:s'), (int) $entry['id']]);
+ 'UPDATE calendar_entries SET title = ?, description = ?, starts_at = ?, ends_at = ?, location_path = ?, audience = ?, status = ?, moderation_note = ?, updated_at = ? WHERE id = ?'
+ )->execute([$title, $description, $startsAt, $endsAt, $locationPath, $audience, $status, $note, date('Y-m-d H:i:s'), (int) $entry['id']]);
set_flash('success', $status === 'pending' ? 'Termin gespeichert - für alle sichtbar nach der Freigabe.' : 'Termin gespeichert.');
redirect($backTo($startsAt, (int) $entry['id']));
case 'delete':
$entry = $loadEntry((int) ($_POST['id'] ?? 0));
$isAuthor = (int) $entry['user_id'] === $myId;
- if (!$isAuthor && !moderation_can()) {
+ if (!$isAuthor && (!moderation_can() || !calendar_can_view($entry, $canLead, $myId))) {
set_flash('error', 'Diesen Termin darfst du nicht löschen.');
redirect($backTo($entry['starts_at'], (int) $entry['id']));
}
@@ -145,11 +149,16 @@ switch ($action) {
case 'join':
case 'leave':
$entry = $loadEntry((int) ($_POST['id'] ?? 0));
- $canSee = $entry['status'] === 'visible' || (int) $entry['user_id'] === $myId || moderation_can();
+ $canSee = ($entry['status'] === 'visible' || (int) $entry['user_id'] === $myId || moderation_can())
+ && calendar_can_view($entry, $canLead, $myId);
if (!$canSee) {
set_flash('error', 'Diesen Termin gibt es nicht (mehr).');
redirect($backTo(null));
}
+ if ($action === 'join' && !calendar_can_join($entry, $canLead)) {
+ set_flash('error', 'Bei diesem Termin tragen sich nur die Sedes Luminis ein.');
+ redirect($backTo($entry['starts_at'], (int) $entry['id']));
+ }
if ($action === 'join') {
try {
$pdo->prepare('INSERT INTO calendar_participants (entry_id, user_id) VALUES (?, ?)')->execute([(int) $entry['id'], $myId]);
diff --git a/contributions.php b/contributions.php
index e1bec72..31c67fb 100644
--- a/contributions.php
+++ b/contributions.php
@@ -242,7 +242,7 @@ include __DIR__ . '/includes/header.php';
+ data-confirm="= e('„' . $entry['name'] . '“ aus dieser Vergabe entfernen? Die Punkte werden abgezogen.') ?>" data-confirm-title="Aus der Vergabe entfernen" data-confirm-danger data-confirm-ok="Entfernen">
= csrf_field() ?>
@@ -256,7 +256,7 @@ include __DIR__ . '/includes/header.php';
+ data-confirm="= e('Vergabe „' . $award['title'] . '“ komplett löschen? Allen ' . count($entries) . ' Mitgliedern werden die Punkte wieder abgezogen.') ?>" data-confirm-title="Vergabe löschen" data-confirm-danger data-confirm-ok="Löschen">
= csrf_field() ?>
diff --git a/dashboard.php b/dashboard.php
index 2cbfe7b..aff4b6e 100644
--- a/dashboard.php
+++ b/dashboard.php
@@ -453,7 +453,7 @@ if (empty($user['tour_completed_at'])):
$tourSteps[] = ['target' => '[data-tour="wiki"]', 'title' => 'Einsteiger-Guide', 'text' => 'Im Wiki findest du den Einsteiger-Guide der Legion: Klassen, Dungeons, Gear und viele Tipps. Er wird von Mitgliedern geschrieben - wenn du mithelfen möchtest, sprich die Leitung an.'];
}
$tourSteps[] = ['target' => '[data-tour="bugs"]', 'title' => 'Fehler gefunden?', 'text' => 'Wenn auf der Website etwas nicht funktioniert, melde es uns hier. Unter „Meine Meldungen“ siehst du, was daraus geworden ist.'];
- $tourSteps[] = ['title' => 'Das war\'s! 🎉', 'text' => 'Jetzt kennst du dich aus. Viel Spaß in der Legion - und wenn du Fragen hast, melde dich einfach im Discord bei den Sedes Lumines.'];
+ $tourSteps[] = ['title' => 'Das war\'s! 🎉', 'text' => 'Jetzt kennst du dich aus. Viel Spaß in der Legion - und wenn du Fragen hast, melde dich einfach im Discord bei den Sedes Luminis.'];
?>
diff --git a/events.php b/events.php
index b68cc54..8fa85a2 100644
--- a/events.php
+++ b/events.php
@@ -231,7 +231,7 @@ include __DIR__ . '/includes/header.php';
= icon('edit') ?>
-
+
= csrf_field() ?>
diff --git a/gear.php b/gear.php
index 523eaf8..c290b9c 100644
--- a/gear.php
+++ b/gear.php
@@ -199,6 +199,10 @@ include __DIR__ . '/includes/header.php';
= e($set['note']) ?>
+
+
Skill- & Daevanion-Plan ↗
+
= icon('edit') ?> Bearbeiten
@@ -232,9 +236,12 @@ include __DIR__ . '/includes/header.php';
$slotLabel = GEAR_SLOTS[$slotKey][0];
$row = $slots[$slotKey] ?? null;
$item = $row['item'] ?? null;
- $tip = $slotLabel . ': ' . ($item ? $item['name'] . ($slotTags($row) ? ' (' . implode(' · ', $slotTags($row)) . ')' : '') : 'leer');
+ // Passt nicht (mehr), z.B. nach einem Klassenwechsel: rot markiert, geloescht wird nichts
+ $mismatch = $item ? gear_item_mismatch($item, $slotKey, $set['class_name']) : null;
+ $tip = $slotLabel . ': ' . ($item ? $item['name'] . ($slotTags($row) ? ' (' . implode(' · ', $slotTags($row)) . ')' : '') : 'leer')
+ . ($mismatch !== null ? ' – ' . $mismatch : '');
?>
-
@@ -261,13 +268,15 @@ include __DIR__ . '/includes/header.php';
= e(GEAR_SLOTS[$activeSlot][0]) ?>
+
= $itemIcon($activeItem, 48) ?>
= e($activeItem['name']) ?>
+
= e($activeMismatch) ?>
= e($activeItem['grade']) ?> · Stufe = (int) $activeItem['item_level'] ?>
- = $activeItem['item_type'] !== $activeItem['slot'] ? ' · ' . e($activeItem['item_type']) : '' ?>
+ = $activeItem['item_type'] !== $activeItem['slot'] ? ' · ' . e(gear_type_label($activeItem['item_type'])) : '' ?>
·
aion2hub
= e(gear_stats_text($activeItem['stats'])) ?>
@@ -276,7 +285,7 @@ include __DIR__ . '/includes/header.php';
-
+
= csrf_field() ?>
@@ -292,6 +301,13 @@ include __DIR__ . '/includes/header.php';
+
+
+ = isset(GEAR_CLASS_WEAPONS[$set['class_name'] ?? ''])
+ ? 'Nur Waffen für ' . e($set['class_name']) . ' – Klasse ändern unter „Bearbeiten“.'
+ : 'Tipp: Klasse im Set wählen, dann siehst du nur passende Waffen.' ?>
+
+
@@ -459,12 +475,16 @@ include __DIR__ . '/includes/header.php';
Notiz
+
Link zum Skill- & Daevanion-Plan (optional)
+
+
+
Plane Skills, Stigmen und Daevanion-Bretter auf einer Planer-Seite (= e(implode(', ', GEAR_BUILD_HOSTS)) ?>) und füge hier den Link zum Teilen ein - er erscheint beim Set und auf deiner Profilseite.
> Auf meiner Profilseite zeigen
Speichern
-
+
= csrf_field() ?>
@@ -484,6 +504,7 @@ include __DIR__ . '/includes/header.php';
+ >– keine Klasse –
>= e($class) ?>
diff --git a/gear_action.php b/gear_action.php
index d85474b..5001838 100644
--- a/gear_action.php
+++ b/gear_action.php
@@ -54,10 +54,12 @@ switch ($action) {
set_flash('error', 'Du hast schon ' . GEAR_MAX_SETS . ' Sets - lösche erst ein altes.');
redirect('/gear.php');
}
+ // "– keine Klasse –" (leer) bleibt ohne Klasse, nur wenn das Feld ganz fehlt, gilt die aus dem Profil
+ $class = isset($_POST['class_name']) ? $cleanClass((string) $_POST['class_name']) : ($me['class_name'] ?: null);
$pdo->prepare(
'INSERT INTO gear_sets (user_id, name, class_name, sort_order, updated_at)
SELECT ?, ?, ?, COALESCE(MAX(sort_order), 0) + 10, NOW() FROM gear_sets WHERE user_id = ?'
- )->execute([$userId, $name, $cleanClass((string) ($_POST['class_name'] ?? '')) ?? ($me['class_name'] ?: null), $userId]);
+ )->execute([$userId, $name, $class, $userId]);
redirect('/gear.php?set=' . (int) $pdo->lastInsertId());
case 'update':
@@ -68,9 +70,29 @@ switch ($action) {
redirect('/gear.php?set=' . (int) $set['id']);
}
$note = mb_substr(trim((string) ($_POST['note'] ?? '')), 0, 255);
- $pdo->prepare('UPDATE gear_sets SET name = ?, class_name = ?, note = ?, show_on_profile = ?, updated_at = NOW() WHERE id = ?')
- ->execute([$name, $cleanClass((string) ($_POST['class_name'] ?? '')), $note !== '' ? $note : null, isset($_POST['show_on_profile']) ? 1 : 0, $set['id']]);
+ $class = $cleanClass((string) ($_POST['class_name'] ?? ''));
+ [$buildUrl, $buildError] = gear_build_url_input((string) ($_POST['build_url'] ?? ''));
+ if ($buildError !== null) {
+ set_flash('error', $buildError);
+ redirect('/gear.php?set=' . (int) $set['id']);
+ }
+ $pdo->prepare('UPDATE gear_sets SET name = ?, class_name = ?, note = ?, build_url = ?, show_on_profile = ?, updated_at = NOW() WHERE id = ?')
+ ->execute([$name, $class, $note !== '' ? $note : null, $buildUrl, isset($_POST['show_on_profile']) ? 1 : 0, $set['id']]);
set_flash('success', 'Set gespeichert.');
+ // Neue Klasse: Waffen, die sie nicht tragen kann, bleiben drin (im Raster rot markiert) - nur Bescheid geben
+ if ($class !== null && $class !== $set['class_name']) {
+ $setSlots = gear_slots_for_sets([(int) $set['id']])[(int) $set['id']] ?? [];
+ $wrong = [];
+ foreach (GEAR_SLOTS as $slotKey => [$slotLabel]) {
+ $item = $setSlots[$slotKey]['item'] ?? null;
+ if ($item && !gear_item_fits_class($item, $class)) {
+ $wrong[] = $slotLabel . ' (' . $item['name'] . ')';
+ }
+ }
+ if ($wrong) {
+ set_flash('info', 'Passt nicht zu ' . $class . ': ' . implode(', ', $wrong) . ' – neu wählen oder Slot leeren.');
+ }
+ }
redirect('/gear.php?set=' . (int) $set['id']);
case 'duplicate':
@@ -83,8 +105,8 @@ switch ($action) {
}
$pdo->beginTransaction();
$pdo->prepare(
- 'INSERT INTO gear_sets (user_id, name, class_name, note, show_on_profile, sort_order, updated_at)
- SELECT user_id, ?, class_name, note, 0, sort_order + 1, NOW() FROM gear_sets WHERE id = ?'
+ 'INSERT INTO gear_sets (user_id, name, class_name, note, build_url, show_on_profile, sort_order, updated_at)
+ SELECT user_id, ?, class_name, note, build_url, 0, sort_order + 1, NOW() FROM gear_sets WHERE id = ?'
)->execute([mb_substr($set['name'] . ' (Kopie)', 0, 80), $set['id']]);
$newId = (int) $pdo->lastInsertId();
$pdo->prepare(
@@ -126,14 +148,19 @@ switch ($action) {
if (!$item) {
$fail('Bitte einen Gegenstand aus der Liste wählen.', $back);
}
- if (!gear_item_fits_slot($item, $slot)) {
- $fail('„' . $item['name'] . '“ passt nicht in den Slot ' . GEAR_SLOTS[$slot][0] . '.', $back);
- }
- // Bei einem anderen Gegenstand passen Seelenpraegung und Manasteine nicht mehr - neu anfangen
+ // Bei einem anderen Gegenstand passen Seelenpraegung und Manasteine nicht mehr - neu anfangen.
+ // Der schon eingesetzte darf weiter bearbeitet werden, auch wenn er nicht mehr passt (z.B. nach
+ // einem Klassenwechsel); neu einsetzen laesst sich nur, was in den Slot und zur Klasse passt.
$current = $pdo->prepare('SELECT item_id FROM gear_set_slots WHERE set_id = ? AND slot = ?');
$current->execute([$set['id'], $slot]);
$sameItem = (int) $current->fetchColumn() === (int) $item['id'];
+ if (!$sameItem && !gear_item_fits_slot($item, $slot)) {
+ $fail('„' . $item['name'] . '“ passt nicht in den Slot ' . GEAR_SLOTS[$slot][0] . '.', $back);
+ }
+ if (!$sameItem && !gear_item_fits_class($item, $set['class_name'])) {
+ $fail('„' . $item['name'] . '“ ist keine Waffe für ' . $set['class_name'] . '.', $back);
+ }
$enchant = max(0, min((int) $item['enchant_max'], (int) ($_POST['enchant'] ?? 0)));
$exceed = max(0, min((int) $item['exceed_max'], (int) ($_POST['exceed'] ?? 0)));
diff --git a/includes/calendar_audience.php b/includes/calendar_audience.php
new file mode 100644
index 0000000..6d6229c
--- /dev/null
+++ b/includes/calendar_audience.php
@@ -0,0 +1,42 @@
+ 'Alle Mitglieder',
+ 'leadership' => 'Nur Leitung nimmt teil (für alle sichtbar)',
+ 'internal' => 'Intern – nur für die Leitung sichtbar',
+];
+
+function calendar_can_lead(): bool
+{
+ return user_has_permission('calendar.leadership');
+}
+
+/** Darf der Betrachter den Termin sehen? (Freigabe/Moderation prueft der Aufrufer wie bisher.) */
+function calendar_can_view(array $row, bool $canLead, int $myId): bool
+{
+ return ($row['audience'] ?? 'all') !== 'internal' || $canLead || (int) $row['user_id'] === $myId;
+}
+
+/** Darf der Betrachter sich mit "Bin dabei" eintragen? */
+function calendar_can_join(array $row, bool $canLead): bool
+{
+ return ($row['audience'] ?? 'all') === 'all' || $canLead;
+}
+
+/** Zielgruppe aus dem Formular - ohne calendar.leadership bleibt es beim bisherigen Wert. */
+function calendar_audience_input(?string $current, bool $canLead): string
+{
+ $value = (string) ($_POST['audience'] ?? '');
+ if ($canLead && isset(CALENDAR_AUDIENCES[$value])) {
+ return $value;
+ }
+ return $current !== null && isset(CALENDAR_AUDIENCES[$current]) ? $current : 'all';
+}
diff --git a/includes/calendar_entry.php b/includes/calendar_entry.php
index 268816c..a47533f 100644
--- a/includes/calendar_entry.php
+++ b/includes/calendar_entry.php
@@ -6,13 +6,14 @@
* @var bool $isModerator
* @var int $myId
* @var callable $entryFields
+ * @var bool $canLead calendar.leadership (Termine nur fuer die Leitung)
*/
$row = $entry['row'];
$entryId = (int) $row['id'];
$isAuthor = (int) $row['user_id'] === $myId;
$ends = $row['ends_at'] ? strtotime((string) $row['ends_at']) : null;
-$actionForm = static function (string $action, string $label, string $class, string $confirm = '') use ($entryId): string {
- return ''
+$actionForm = static function (string $action, string $label, string $class) use ($entryId): string {
+ return ' '
. csrf_field() . ' '
. '' . $label . ' ';
};
@@ -24,6 +25,11 @@ $actionForm = static function (string $action, string $label, string $class, str
Wartet auf Freigabe
+
+ 🔒 Intern
+
+ Nur Leitung
+
= avatar_html(['id' => $row['user_id'], 'username' => $row['username'], 'display_name' => $row['display_name'], 'avatar_filename' => $row['avatar_filename']], 22) ?>
= e((string) $row['author']) ?>
@@ -70,9 +76,11 @@ $actionForm = static function (string $action, string $label, string $class, str
- = $entry['joined']
- ? $actionForm('leave', 'Absagen', 'button-secondary')
- : $actionForm('join', '✋ Bin dabei', 'button-success') ?>
+
+ = $actionForm('leave', 'Absagen', 'button-secondary') ?>
+
+ = $actionForm('join', '✋ Bin dabei', 'button-success') ?>
+
@@ -95,7 +103,7 @@ $actionForm = static function (string $action, string $label, string $class, str
-
+
= csrf_field() ?>
= icon('trash') ?>
@@ -106,7 +114,8 @@ $actionForm = static function (string $action, string $label, string $class, str
= icon('flag') ?> Gemeldet
+ data-confirm="Die Moderation schaut sich den Termin an." data-confirm-title="Termin melden" data-confirm-ok="Melden"
+ data-confirm-input="reason" data-confirm-placeholder="Was ist daran nicht in Ordnung? (optional)">
= csrf_field() ?>
diff --git a/includes/data_reset.php b/includes/data_reset.php
index 1139d2a..7d890fa 100644
--- a/includes/data_reset.php
+++ b/includes/data_reset.php
@@ -58,11 +58,12 @@ const DATA_RESET_AREAS = [
],
'tactics' => [
'label' => 'Taktiken (Karte)',
- 'description' => 'Alle Taktiken mit ihren Schritten und Zeichnungen.',
+ 'description' => 'Alle Taktiken mit ihren Schritten und Zeichnungen, dazu Verlauf und Papierkorb (gesicherte Stände, gelöschte Taktiken).',
'count' => 'SELECT COUNT(*) FROM tactics',
'unit' => ['Taktik', 'Taktiken'],
- 'delete' => ['DELETE FROM tactics'],
- 'reset_ids' => ['tactic_shapes', 'tactic_steps', 'tactics'],
+ // tactic_revisions hat keinen Fremdschluessel auf tactics - muss eigens geleert werden
+ 'delete' => ['DELETE FROM tactic_revisions', 'DELETE FROM tactics'],
+ 'reset_ids' => ['tactic_shapes', 'tactic_steps', 'tactics', 'tactic_revisions'],
],
'calendar' => [
'label' => 'Kalender-Termine',
diff --git a/includes/discord_auth.php b/includes/discord_auth.php
index 221afb2..4e51bb4 100644
--- a/includes/discord_auth.php
+++ b/includes/discord_auth.php
@@ -9,7 +9,7 @@ require_once __DIR__ . '/discord.php';
* Berechtigungsgruppen mit hinterlegter Discord-Rolle (roles.discord_role_id) werden
* vollstaendig von Discord gesteuert: wer die Rolle hat, ist drin, wer sie nicht (mehr)
* hat, fliegt raus. Gruppen ohne Discord-Rolle bleiben unangetastet und werden weiter von
- * Hand vergeben. Hat jemand mehrere verknuepfte Rollen (z.B. Sedes Lumines und Lumina
+ * Hand vergeben. Hat jemand mehrere verknuepfte Rollen (z.B. Sedes Luminis und Lumina
* Ascendens), bekommt er alle zugehoerigen Gruppen - die Rechte addieren sich.
*/
diff --git a/includes/footer.php b/includes/footer.php
index 61bf7fb..a243eff 100644
--- a/includes/footer.php
+++ b/includes/footer.php
@@ -8,6 +8,8 @@
+
+
diff --git a/includes/gear.php b/includes/gear.php
index ee3149a..6779bba 100644
--- a/includes/gear.php
+++ b/includes/gear.php
@@ -117,9 +117,29 @@ function gear_doll_mini_html(array $slots, bool $column = false): string
return $html . '';
}
-// In der Nebenhand: Schilde & Co. (SubHand) und Einhandwaffen fuer zwei Waffen
+// In der Nebenhand: Schilde & Co. (SubHand) und Einhandwaffen fuer zwei Waffen - ob es in Aion 2
+// zwei Waffen gibt, ist noch offen. Hat das Set eine Klasse, bleibt nur deren Waffenart (s.u.).
const GEAR_OFFHAND_WEAPON_TYPES = ['Sword', 'Dagger', 'Mace'];
+// Hauptwaffe je Klasse (Aion 2: genau eine Waffenart pro Klasse, laut aion2hub). An die Klasse
+// gebunden sind nur Waffen mit dem Spiel-Slot MainHand - Schutz, Ruestung und Schmuck nicht.
+const GEAR_CLASS_WEAPONS = [
+ 'Templer' => 'Sword',
+ 'Gladiator' => 'Greatsword',
+ 'Assassine' => 'Dagger',
+ 'Jäger' => 'Bow',
+ 'Magier' => 'Magicbook',
+ 'Beschwörer' => 'Orb',
+ 'Kleriker' => 'Mace',
+ 'Kantor' => 'Staff',
+];
+
+// Waffenarten auf Deutsch (aion2hub liefert sie englisch)
+const GEAR_TYPE_LABELS = [
+ 'Sword' => 'Schwert', 'Greatsword' => 'Zweihänder', 'Dagger' => 'Dolch', 'Bow' => 'Bogen', 'Magicbook' => 'Zauberbuch',
+ 'Orb' => 'Orb', 'Staff' => 'Stab', 'Mace' => 'Streitkolben', 'Guarder' => 'Schutz',
+];
+
// Seltenheit: Reihenfolge und CSS-Klasse (Farbe)
const GEAR_GRADES = ['Common' => 'common', 'Rare' => 'rare', 'Epic' => 'epic', 'Unique' => 'unique', 'Heroic' => 'heroic', 'Special' => 'special'];
@@ -190,6 +210,12 @@ function gear_grade_class(?string $grade): string
return 'grade-' . (GEAR_GRADES[$grade ?? ''] ?? 'common');
}
+/** Art eines Gegenstands zum Anzeigen: Waffenarten auf Deutsch, alles andere wie bei aion2hub. */
+function gear_type_label(string $type): string
+{
+ return GEAR_TYPE_LABELS[$type] ?? $type;
+}
+
/** Passt ein Katalog-Gegenstand in diesen Slot eines Sets? */
function gear_item_fits_slot(array $item, string $slotKey): bool
{
@@ -202,8 +228,35 @@ function gear_item_fits_slot(array $item, string $slotKey): bool
return true;
}
-/** Eintraege fuer die Suchliste (assets/js/item-picker.js) eines Slots. */
-function gear_picker_items(string $slotKey): array
+/**
+ * Kann die Klasse des Sets diesen Gegenstand tragen? Gebunden sind nur Waffen mit dem Spiel-Slot
+ * MainHand (GEAR_CLASS_WEAPONS), auch in der Nebenhand. Sets ohne Klasse duerfen alles.
+ */
+function gear_item_fits_class(array $item, ?string $className): bool
+{
+ $weapon = GEAR_CLASS_WEAPONS[$className ?? ''] ?? null;
+ return $weapon === null || $item['slot'] !== 'MainHand' || $item['item_type'] === $weapon;
+}
+
+/**
+ * Warum passt ein Gegenstand nicht (mehr) in diesen Slot des Sets, z.B. nach einem Klassenwechsel?
+ * null = passt. Geloescht wird so ein Gegenstand nie - er wird nur markiert und laesst sich weiter
+ * bearbeiten (gear_action.php, save_slot), neu einsetzen laesst sich nur, was passt.
+ */
+function gear_item_mismatch(array $item, string $slotKey, ?string $className): ?string
+{
+ if (!gear_item_fits_slot($item, $slotKey)) {
+ return 'passt nicht in diesen Slot';
+ }
+ return gear_item_fits_class($item, $className) ? null : 'passt nicht zu ' . $className;
+}
+
+/**
+ * Eintraege fuer die Suchliste (assets/js/item-picker.js) eines Slots, mit Klasse nur deren Waffen.
+ * Der eingesetzte Gegenstand ($keepId) bleibt immer drin, auch wenn er nicht mehr passt - fehlt er,
+ * leert die Suchliste beim Laden das Feld und der Slot laesst sich nicht mehr speichern.
+ */
+function gear_picker_items(string $slotKey, ?string $className = null, int $keepId = 0): array
{
$slots = GEAR_SLOTS[$slotKey][2] ?? [];
if (!$slots) {
@@ -211,10 +264,16 @@ function gear_picker_items(string $slotKey): array
}
$stmt = db()->prepare(
'SELECT id, name, slot, item_type, grade, item_level, icon FROM gear_items
- WHERE slot IN (' . implode(',', array_fill(0, count($slots), '?')) . ') ORDER BY item_level DESC, name'
+ WHERE slot IN (' . implode(',', array_fill(0, count($slots), '?')) . ') OR id = ? ORDER BY item_level DESC, name'
);
- $stmt->execute($slots);
- $rows = array_values(array_filter($stmt->fetchAll(), static fn (array $row): bool => gear_item_fits_slot($row, $slotKey)));
+ $stmt->execute([...$slots, $keepId]);
+ $rows = [];
+ foreach ($stmt->fetchAll() as $row) {
+ $row['mismatch'] = gear_item_mismatch($row, $slotKey, $className);
+ if ($row['mismatch'] === null || (int) $row['id'] === $keepId) {
+ $rows[] = $row;
+ }
+ }
// Gleiche Namen (z.B. zwei Varianten) auseinanderhalten - die Suchliste waehlt ueber den Namen
$names = array_count_values(array_column($rows, 'name'));
@@ -222,7 +281,9 @@ function gear_picker_items(string $slotKey): array
'id' => (int) $row['id'],
'name' => $names[$row['name']] > 1 ? $row['name'] . ' (Stufe ' . (int) $row['item_level'] . ', #' . (int) $row['id'] . ')' : $row['name'],
'icon' => gear_icon_url($row),
- 'category' => $row['grade'] . ' · Stufe ' . (int) $row['item_level'] . ($row['item_type'] !== $row['slot'] ? ' · ' . $row['item_type'] : ''),
+ 'category' => $row['grade'] . ' · Stufe ' . (int) $row['item_level']
+ . ($row['item_type'] !== $row['slot'] ? ' · ' . gear_type_label($row['item_type']) : '')
+ . ($row['mismatch'] !== null ? ' · ' . $row['mismatch'] : ''),
], $rows);
}
@@ -459,6 +520,44 @@ function gear_set_item_level(array $slots): ?float
// ---- Sets ----
+// Planer-Seiten, auf die ein Set als Skill-/Daevanion-Plan verlinken darf (auch deren Subdomains).
+// Eigene Skill- und Daevanion-Daten hat die Website (noch) nicht - bis dahin der Link zum Build.
+const GEAR_BUILD_HOSTS = ['aion2hub.com', 'talentbuilds.com', 'aion2t.com', 'aion2.online', 'gamers4.life', 'aion2.app'];
+const GEAR_BUILD_URL_MAX = 300;
+
+/** Die Planer-Seite eines Build-Links ("aion2hub.com") oder null, wenn sie nicht erlaubt ist. */
+function gear_build_host(string $url): ?string
+{
+ $parts = parse_url($url);
+ $host = strtolower((string) ($parts['host'] ?? ''));
+ if (($parts['scheme'] ?? '') !== 'https' || $host === '' || isset($parts['user']) || isset($parts['pass'])) {
+ return null;
+ }
+ foreach (GEAR_BUILD_HOSTS as $allowed) {
+ if ($host === $allowed || str_ends_with($host, '.' . $allowed)) {
+ return $allowed;
+ }
+ }
+ return null;
+}
+
+/**
+ * Build-Link aus dem Formular pruefen: leer oder ein https-Link auf eine der Planer-Seiten.
+ *
+ * @return array{0: ?string, 1: ?string} [Link oder null, Fehlermeldung oder null]
+ */
+function gear_build_url_input(string $raw): array
+{
+ $url = trim($raw);
+ if ($url === '') {
+ return [null, null];
+ }
+ if (mb_strlen($url) > GEAR_BUILD_URL_MAX || preg_match('/\s/u', $url) || gear_build_host($url) === null) {
+ return [null, 'Der Build-Link muss eine https-Adresse von ' . implode(', ', GEAR_BUILD_HOSTS) . ' sein (höchstens ' . GEAR_BUILD_URL_MAX . ' Zeichen).'];
+ }
+ return [$url, null];
+}
+
function gear_set(int $id): ?array
{
$stmt = db()->prepare(
diff --git a/includes/header.php b/includes/header.php
index 13b6976..b1836e6 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -173,12 +173,14 @@ if ($siteAnnouncement !== null && $currentScript !== 'site.php' && ($shellUser |
// Wer trotz Wartung hier ist, soll daran erinnert werden, dass sie noch laeuft.
$maintenanceNotice = $shellUser && maintenance_active();
-// 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.
+// Erfolgsmeldungen ("Bestätigungen") bekommen ein zentriertes Popup mit Haken-Animation, das
+// sich von selbst schliesst. Fehlermeldungen erscheinen als Meldung, die man mit OK bestaetigen
+// muss (assets/js/confirm-dialog.js) - als Balken oben gingen sie leicht unter. Hinweise ("info")
+// bleiben als Balken.
$allFlashes = get_flashes();
$successFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($f['type'] ?? '') === 'success'));
-$otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($f['type'] ?? '') !== 'success'));
+$errorFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($f['type'] ?? '') === 'error'));
+$otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => !in_array($f['type'] ?? '', ['success', 'error'], true)));
?>
@@ -221,6 +223,9 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
+
+
+
@@ -410,6 +415,9 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
= e($flash['message']) ?>
+
+
= e($flash['message']) ?>
+
diff --git a/member_edit.php b/member_edit.php
index 0d82468..6092971 100644
--- a/member_edit.php
+++ b/member_edit.php
@@ -120,7 +120,7 @@ include __DIR__ . '/includes/header.php';
Speichern
Löschen
+ data-confirm="= e($character['name'] . ' wirklich löschen?') ?>" data-confirm-title="Charakter löschen" data-confirm-danger data-confirm-ok="Löschen">Löschen
@@ -185,7 +185,7 @@ include __DIR__ . '/includes/header.php';
Speichern
= icon('trash') ?>
+ data-confirm="Dieses Bild löschen?" data-confirm-title="Bild löschen" data-confirm-danger data-confirm-ok="Löschen">= icon('trash') ?>
@@ -258,7 +258,7 @@ $ownBackground = profile_background_image($id);
= $ownBackground ? 'Ersetzt dein bisheriges eigenes Hintergrundbild.' : '' ?>
-
+
= csrf_field() ?>
diff --git a/member_picture.php b/member_picture.php
index b5ec978..b2212ee 100644
--- a/member_picture.php
+++ b/member_picture.php
@@ -59,7 +59,7 @@ $reportButton = static function (string $type, int $id, bool $already): string {
return '' . icon('flag') . ' Gemeldet ';
}
return ' '
+ . 'data-confirm="Die Moderation schaut sich das an." data-confirm-title="Melden" data-confirm-ok="Melden" data-confirm-input="reason" data-confirm-placeholder="Was ist daran nicht in Ordnung? (optional)">'
. csrf_field()
. ' '
. ' '
@@ -147,7 +147,7 @@ include __DIR__ . '/includes/header.php';
-
@@ -355,6 +369,28 @@ include __DIR__ . '/includes/header.php';
+
+
+
+
+
= icon('x') ?>
+
Premade auflösen
+
Du löst als Legionsleitung auf. Der Lead bekommt die Begründung per Discord-PN, die übrigen Mitglieder erfahren nur, dass die Legionsleitung die Gruppe aufgelöst hat.
+
+ = csrf_field() ?>
+
+
+ Begründung
+
+
+ Abbrechen
+ Gruppe auflösen
+
+
+
+
+
+
diff --git a/profile.php b/profile.php
index e52be94..3a665ca 100644
--- a/profile.php
+++ b/profile.php
@@ -137,7 +137,7 @@ include __DIR__ . '/includes/header.php';
-
+
= csrf_field() ?>
Profilbild entfernen
@@ -244,7 +244,7 @@ document.getElementById('avatar-upload-input').addEventListener('change', functi
Das Lösen der Verknüpfung ist von der Legionsleitung deaktiviert.
-
+
= csrf_field() ?>
Verknüpfung entfernen
diff --git a/raid_archive.php b/raid_archive.php
index f3ba5bd..7cc3daa 100644
--- a/raid_archive.php
+++ b/raid_archive.php
@@ -26,6 +26,7 @@ try {
} catch (Throwable $e) {
$raidBefore = null;
}
+ raid_settings_ensure_defaults([$raidId]); // fester Punkt auch fuer im Discord erstellte Raids
archive_raid($raidId);
set_flash('success', 'Raid wurde archiviert.');
$autoMessages = [];
diff --git a/raid_attendance.php b/raid_attendance.php
index 74d9f5d..b6419ad 100644
--- a/raid_attendance.php
+++ b/raid_attendance.php
@@ -17,6 +17,7 @@ if (!$raid && !$apiError) {
redirect('/raids.php');
}
+raid_settings_ensure_defaults([$raidId]);
$settings = raid_settings_get($raidId);
$attendance = raid_attendance_get($raidId);
$userIds = raid_user_ids_by_discord();
diff --git a/raid_attendance_action.php b/raid_attendance_action.php
index 78a5c2a..c8e934c 100644
--- a/raid_attendance_action.php
+++ b/raid_attendance_action.php
@@ -13,6 +13,8 @@ if ($raidId <= 0) {
redirect('/raids.php');
}
$userId = (int) current_user()['id'];
+// Eigene Einstellungen (fester Punkt) vor dem "kontrolliert"-Haken anlegen.
+raid_settings_ensure_defaults([$raidId]);
$statuses = (array) ($_POST['status'] ?? []);
$names = (array) ($_POST['names'] ?? []);
diff --git a/raid_create_action.php b/raid_create_action.php
index a3ee96c..3cd877f 100644
--- a/raid_create_action.php
+++ b/raid_create_action.php
@@ -11,14 +11,79 @@ $title = trim((string) ($input['title'] ?? ''));
$dateRaw = trim((string) ($input['date_raw'] ?? ''));
$requirements = trim((string) ($input['requirements'] ?? ''));
$groupNames = trim((string) ($input['group_names'] ?? ''));
-$gearscore = trim((string) ($input['gearscore'] ?? ''));
-$maxSlots = isset($input['max_slots']) && is_numeric($input['max_slots']) ? (int) $input['max_slots'] : 12;
-$pointsPresent = max(0, min(CONTRIBUTION_MAX_POINTS, (int) ($input['points_present'] ?? 0)));
-$pointsAbsent = max(0, min(CONTRIBUTION_MAX_POINTS, (int) ($input['points_absent'] ?? 0)));
+[$gearscore, $gearscoreError] = raid_normalize_gearscore((string) ($input['gearscore'] ?? ''));
if ($title === '' || $dateRaw === '' || $requirements === '' || $groupNames === '') {
json_response(false, 'Bitte Titel, Datum, Anforderungen und mindestens eine Gruppe angeben.');
}
+$groupList = array_values(array_filter(array_map('trim', explode(',', $groupNames)), static fn (string $name): bool => $name !== ''));
+$groupCount = count($groupList);
+$slotsError = raid_slots_error($input['max_slots'] ?? '', $groupCount);
+if ($slotsError !== null) {
+ json_response(false, $slotsError);
+}
+$maxSlots = (int) trim((string) $input['max_slots']);
+if ($gearscoreError !== null) {
+ json_response(false, $gearscoreError);
+}
+
+// Lumipunkte: ohne raids.points gilt fest +1 pro Teilnahme, kein Abzug.
+$pointsPresent = RAID_POINTS_DEFAULT_PRESENT;
+$pointsAbsent = RAID_POINTS_DEFAULT_ABSENT;
+if (user_has_permission('raids.points')) {
+ $pointsPresent = raid_points_input($input['points_present'] ?? RAID_POINTS_DEFAULT_PRESENT);
+ $pointsAbsent = raid_points_input($input['points_absent'] ?? RAID_POINTS_DEFAULT_ABSENT);
+ $pointsError = $pointsPresent === null || $pointsAbsent === null
+ ? 'Lumipunkte: bitte ganze Zahlen von 0 bis ' . RAID_POINTS_MAX . ' angeben.'
+ : raid_points_error($pointsPresent, $pointsAbsent);
+ if ($pointsError !== null) {
+ json_response(false, $pointsError);
+ }
+}
+
+// Feste Premades, die direkt einer Gruppe zugeordnet werden (Gruppe => Premade-ID).
+$premadeChoices = [];
+foreach ((array) ($input['premades'] ?? []) as $choice) {
+ $group = (int) ($choice['group'] ?? 0);
+ $premadeId = (int) ($choice['premade_id'] ?? 0);
+ if ($premadeId <= 0) {
+ continue;
+ }
+ if ($group < 1 || $group > $groupCount || isset($premadeChoices[$group])) {
+ json_response(false, 'Die Zuordnung der Premades zu den Gruppen ist ungültig.');
+ }
+ if (in_array($premadeId, $premadeChoices, true)) {
+ json_response(false, 'Eine Premade kann nur einer Gruppe zugeordnet werden.');
+ }
+ $premadeChoices[$group] = $premadeId;
+}
+$premadesById = [];
+if (!empty($premadeChoices)) {
+ try {
+ foreach (fetch_premades() as $premade) {
+ $premadesById[(int) ($premade['id'] ?? 0)] = $premade;
+ }
+ } catch (Throwable $e) {
+ json_response(false, 'Die Premades konnten nicht geladen werden: ' . $e->getMessage());
+ }
+ foreach ($premadeChoices as $group => $premadeId) {
+ if (!isset($premadesById[$premadeId])) {
+ json_response(false, 'Diese Premade gibt es nicht (mehr) - bitte die Seite neu laden.');
+ }
+ // Die Gruppe heisst wie die Premade (beim Einladen benennt der Bot sie ohnehin so um).
+ $groupList[$group - 1] = trim((string) preg_replace('/\s+/u', ' ', str_replace(',', ' ', (string) ($premadesById[$premadeId]['name'] ?? ''))))
+ ?: 'Gruppe ' . $group;
+ }
+ $groupNames = implode(', ', $groupList);
+ if (mb_strlen($groupNames, 'UTF-8') > RAID_FIELD_LIMITS['group_names'][1]) {
+ // Zu lang fuer die API - Platzhalter schicken, die Einladung setzt den richtigen Namen.
+ foreach ($premadeChoices as $group => $premadeId) {
+ $groupList[$group - 1] = 'Gruppe ' . $group;
+ }
+ $groupNames = implode(', ', $groupList);
+ }
+}
+
$fieldError = raid_fields_error(['title' => $title, 'requirements' => $requirements, 'gearscore' => $gearscore, 'group_names' => $groupNames]);
if ($fieldError !== null) {
json_response(false, $fieldError);
@@ -33,19 +98,50 @@ try {
'gearscore' => $gearscore,
'max_slots' => $maxSlots,
]);
- $newRaidId = (int) ($result['raid_id'] ?? 0);
- // Lumipunkte beim Archivieren kennt die Raid-API nicht - die merkt sich die Website.
- if ($newRaidId > 0 && ($pointsPresent > 0 || $pointsAbsent > 0)) {
- raid_settings_save_points($newRaidId, $pointsPresent, $pointsAbsent);
- }
- admin_log('⚔️ Raid erstellt', [
- 'Raid' => $title,
- 'Termin' => $dateRaw,
- 'Plätze' => $maxSlots,
- 'Gruppen' => $groupNames,
- 'Lumipunkte' => $pointsPresent > 0 || $pointsAbsent > 0 ? '+' . $pointsPresent . ' anwesend / -' . $pointsAbsent . ' abwesend' : '',
- ], 'success');
- json_response(true, 'Raid wurde erstellt.', ['raid_id' => $result['raid_id'] ?? null]);
} catch (Throwable $e) {
json_response(false, 'Erstellen fehlgeschlagen: ' . $e->getMessage());
}
+
+$newRaidId = (int) ($result['raid_id'] ?? 0);
+// Lumipunkte beim Archivieren kennt die Raid-API nicht - die merkt sich die Website. Auch 0/0
+// wird gespeichert, damit ein bewusst punktloser Raid nicht den festen Punkt bekommt.
+if ($newRaidId > 0) {
+ try {
+ raid_settings_save_points($newRaidId, $pointsPresent, $pointsAbsent);
+ } catch (PDOException $e) {
+ // Raid steht - ohne Eintrag gilt beim Anzeigen der feste Punkt.
+ }
+}
+admin_log('⚔️ Raid erstellt', [
+ 'Raid' => $title,
+ 'Termin' => $dateRaw,
+ 'Plätze' => $maxSlots,
+ 'Gruppen' => $groupNames,
+ 'Gearscore' => $gearscore,
+ 'Lumipunkte' => '+' . $pointsPresent . ' anwesend / -' . $pointsAbsent . ' abwesend',
+], 'success');
+
+// Premades direkt einladen - Fehler dabei machen den Raid nicht ungueltig.
+$premadeMessages = [];
+foreach ($newRaidId > 0 ? $premadeChoices : [] as $group => $premadeId) {
+ $premade = $premadesById[$premadeId];
+ $premadeName = (string) ($premade['name'] ?? ('#' . $premadeId));
+ try {
+ $count = invite_premade($newRaidId, $premadeId, $group);
+ admin_log('🤝 Premade zum Raid eingeladen', [
+ 'Raid' => $title,
+ 'Premade' => $premadeName,
+ 'Zielgruppe' => 'Gruppe ' . $group . ' – umbenannt und gesperrt',
+ 'Eingeladen' => $count . ' Mitglied(er) per DM',
+ 'Mitglieder' => implode(', ', array_map(
+ static fn (array $m): string => (string) ($m['name'] ?? admin_log_discord_name((string) ($m['user_id'] ?? ''))),
+ array_filter((array) ($premade['members'] ?? []), static fn ($m): bool => ($m['status'] ?? '') === 'accepted')
+ )),
+ ]);
+ $premadeMessages[] = '„' . $premadeName . '“: ' . $count . ' Mitglied(er) per DM eingeladen.';
+ } catch (Throwable $e) {
+ $premadeMessages[] = '„' . $premadeName . '“ konnte nicht eingeladen werden (' . $e->getMessage() . ') - bitte im Bearbeiten-Modus erneut versuchen.';
+ }
+}
+
+json_response(true, trim('Raid wurde erstellt. ' . implode(' ', $premadeMessages)), ['raid_id' => $result['raid_id'] ?? null]);
diff --git a/raid_edit_action.php b/raid_edit_action.php
index d8a2591..28eaa82 100644
--- a/raid_edit_action.php
+++ b/raid_edit_action.php
@@ -12,32 +12,7 @@ if ($raidId <= 0) {
json_response(false, 'Ungültige Anfrage.');
}
-$fields = [];
-foreach (['title', 'date_raw', 'requirements', 'gearscore', 'group_names'] as $key) {
- if (isset($input[$key]) && trim((string) $input[$key]) !== '') {
- $fields[$key] = trim((string) $input[$key]);
- }
-}
-// Der Gearscore ist optional - ein geleertes Feld entfernt ihn.
-if (isset($input['gearscore']) && trim((string) $input['gearscore']) === '') {
- $fields['gearscore'] = '';
-}
-if (isset($input['max_slots']) && is_numeric($input['max_slots'])) {
- $fields['max_slots'] = (int) $input['max_slots'];
-}
-if (isset($input['locked_groups']) && is_array($input['locked_groups'])) {
- $fields['locked_groups'] = array_values(array_map('intval', $input['locked_groups']));
-}
-
-if (empty($fields)) {
- json_response(false, 'Keine Änderungen übermittelt.');
-}
-$fieldError = raid_fields_error($fields);
-if ($fieldError !== null) {
- json_response(false, $fieldError);
-}
-
-// Stand vor der Aenderung fuers Audit-Log (alt -> neu)
+// Stand vor der Aenderung: fuer unveraenderte Altwerte (siehe unten) und fuers Audit-Log (alt -> neu)
try {
$before = fetch_raid_by_id($raidId);
$beforePoints = raid_settings_get($raidId);
@@ -46,18 +21,85 @@ try {
$beforePoints = null;
}
+$fields = [];
+foreach (['title', 'date_raw', 'requirements', 'group_names'] as $key) {
+ if (isset($input[$key]) && trim((string) $input[$key]) !== '') {
+ $fields[$key] = trim((string) $input[$key]);
+ }
+}
+// Unveraenderte Gruppen nicht erneut schicken: Premades benennen Gruppen um, dabei kann die Liste
+// laenger werden, als die API beim Speichern erlaubt - das soll andere Aenderungen nicht blockieren.
+$groupNamesOf = static fn (string $names): array => array_values(array_filter(array_map('trim', explode(',', $names)), static fn (string $n): bool => $n !== ''));
+if (isset($fields['group_names']) && $before !== null && $groupNamesOf($fields['group_names']) === $groupNamesOf((string) ($before['groups'] ?? ''))) {
+ unset($fields['group_names']);
+}
+// Der Gearscore ist optional - ein geleertes Feld entfernt ihn. Ein unveraenderter alter Wert
+// (frueher war Freitext erlaubt) blockiert das Speichern anderer Aenderungen nicht.
+if (isset($input['gearscore'])) {
+ $rawGearscore = trim((string) $input['gearscore']);
+ if ($before === null || $rawGearscore !== trim((string) ($before['gearscore'] ?? ''))) {
+ [$gearscore, $gearscoreError] = raid_normalize_gearscore($rawGearscore);
+ if ($gearscoreError !== null) {
+ json_response(false, $gearscoreError);
+ }
+ $fields['gearscore'] = $gearscore;
+ }
+}
+// Max. Spieler haengt an der Zahl der Gruppen (je 5 Plaetze) - geprueft wird, sobald sich eins
+// von beiden aendert.
+$beforeGroupCount = $before !== null ? raid_group_count((string) ($before['groups'] ?? '')) : 0;
+$groupCount = isset($fields['group_names']) ? raid_group_count($fields['group_names']) : $beforeGroupCount;
+if (isset($fields['group_names']) && $groupCount > RAID_MAX_GROUPS) {
+ json_response(false, 'Höchstens ' . RAID_MAX_GROUPS . ' Gruppen pro Raid.');
+}
+if (isset($input['max_slots'])) {
+ $rawSlots = trim((string) $input['max_slots']);
+ $unchanged = $before !== null && $groupCount === $beforeGroupCount
+ && $rawSlots === (string) (int) ($before['max_slots'] ?? 0);
+ if (!$unchanged) {
+ $slotsError = raid_slots_error($rawSlots, $groupCount);
+ if ($slotsError !== null) {
+ json_response(false, $slotsError);
+ }
+ $fields['max_slots'] = (int) $rawSlots;
+ }
+}
+if (isset($input['locked_groups']) && is_array($input['locked_groups'])) {
+ $fields['locked_groups'] = array_values(array_map('intval', $input['locked_groups']));
+}
+
+// Lumipunkte aendert nur, wer raids.points hat - alle anderen lassen die Einstellung unangetastet.
+$pointsPresent = null;
+$pointsAbsent = null;
+if (user_has_permission('raids.points') && (isset($input['points_present']) || isset($input['points_absent']))) {
+ $pointsPresent = raid_points_input($input['points_present'] ?? 0);
+ $pointsAbsent = raid_points_input($input['points_absent'] ?? 0);
+ $pointsError = $pointsPresent === null || $pointsAbsent === null
+ ? 'Lumipunkte: bitte ganze Zahlen von 0 bis ' . RAID_POINTS_MAX . ' angeben.'
+ : raid_points_error($pointsPresent, $pointsAbsent);
+ if ($pointsError !== null) {
+ json_response(false, $pointsError);
+ }
+}
+$pointsChanged = $pointsPresent !== null
+ && ($beforePoints === null || $pointsPresent !== $beforePoints['points_present'] || $pointsAbsent !== $beforePoints['points_absent']);
+
+if (empty($fields) && !$pointsChanged) {
+ json_response(false, 'Keine Änderungen übermittelt.');
+}
+$fieldError = raid_fields_error($fields);
+if ($fieldError !== null) {
+ json_response(false, $fieldError);
+}
+
try {
- $result = update_raid($raidId, $fields);
+ $result = !empty($fields) ? update_raid($raidId, $fields) : ['raid_id' => $raidId];
$newRaidId = (int) ($result['raid_id'] ?? $raidId);
// Einstellungen, Anwesenheit und Vergaben haengen an der raid_id - ggf. mit umziehen.
raid_rename_id($raidId, $newRaidId);
- if (isset($input['points_present']) || isset($input['points_absent'])) {
- raid_settings_save_points(
- $newRaidId,
- max(0, min(CONTRIBUTION_MAX_POINTS, (int) ($input['points_present'] ?? 0))),
- max(0, min(CONTRIBUTION_MAX_POINTS, (int) ($input['points_absent'] ?? 0)))
- );
+ if ($pointsChanged) {
+ raid_settings_save_points($newRaidId, $pointsPresent, $pointsAbsent);
}
$groupList = static fn ($groups): string => $groups ? implode(', ', array_map('intval', (array) $groups)) : 'keine';
@@ -76,11 +118,10 @@ try {
} else {
$logFields['Geändert'] = implode(', ', array_keys($fields));
}
- if ($beforePoints !== null && (isset($input['points_present']) || isset($input['points_absent']))) {
+ if ($pointsChanged) {
$logFields['Lumipunkte'] = admin_log_change(
- '+' . $beforePoints['points_present'] . ' anwesend / −' . $beforePoints['points_absent'] . ' abwesend',
- '+' . max(0, min(CONTRIBUTION_MAX_POINTS, (int) ($input['points_present'] ?? 0))) . ' anwesend / −'
- . max(0, min(CONTRIBUTION_MAX_POINTS, (int) ($input['points_absent'] ?? 0))) . ' abwesend'
+ $beforePoints !== null ? '+' . $beforePoints['points_present'] . ' anwesend / −' . $beforePoints['points_absent'] . ' abwesend' : '',
+ '+' . $pointsPresent . ' anwesend / −' . $pointsAbsent . ' abwesend'
);
}
if ($newRaidId !== $raidId) {
diff --git a/raid_restore.php b/raid_restore.php
index 188d5f6..5c99b84 100644
--- a/raid_restore.php
+++ b/raid_restore.php
@@ -1,6 +1,7 @@
admin_log_raid($raidId)], 'success');
- set_flash('success', 'Raid wurde wiederhergestellt.');
+ $newRaidId = restore_raid($raidId);
+ // Neu gepostet (neue raid_id): Einstellungen, Anwesenheit und Vergaben ziehen mit um.
+ raid_rename_id($raidId, $newRaidId);
+ admin_log('♻️ Raid wiederhergestellt', [
+ 'Raid' => admin_log_raid($newRaidId),
+ 'Hinweis' => $newRaidId !== $raidId ? 'Discord-Nachricht wurde neu gepostet' : '',
+ ], 'success');
+ set_flash('success', $newRaidId !== $raidId
+ ? 'Raid wurde wiederhergestellt und im Discord neu gepostet.'
+ : 'Raid wurde wiederhergestellt.');
} catch (Throwable $e) {
set_flash('error', 'Wiederherstellen fehlgeschlagen: ' . $e->getMessage());
}
diff --git a/raid_signup.php b/raid_signup.php
deleted file mode 100644
index b45adaa..0000000
--- a/raid_signup.php
+++ /dev/null
@@ -1,41 +0,0 @@
-getMessage());
-}
-
-redirect($redirectTo);
diff --git a/raid_signup_action.php b/raid_signup_action.php
index 7a0e9d6..d633b81 100644
--- a/raid_signup_action.php
+++ b/raid_signup_action.php
@@ -66,7 +66,10 @@ try {
$requestGroup = 0;
}
- $assigned = raid_signup($raidId, $discordId, (string) $user['discord_username'], $class, $requestGroup);
+ // Derselbe Name wie bei einer Anmeldung im Discord: der Anzeigename auf dem Server (Nickname),
+ // nicht der Discord-Kontoname.
+ $signupName = trim((string) ($user['display_name'] ?? '')) !== '' ? (string) $user['display_name'] : (string) $user['discord_username'];
+ $assigned = raid_signup($raidId, $discordId, $signupName, $class, $requestGroup);
$assignedGroup = (int) ($assigned['group'] ?? 0);
$groupNames = array_values(array_filter(array_map('trim', explode(',', (string) ($raid['groups'] ?? '')))));
diff --git a/raids.php b/raids.php
index c19fabe..078dcfa 100644
--- a/raids.php
+++ b/raids.php
@@ -2,38 +2,13 @@
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/raids_api.php';
require_once __DIR__ . '/includes/raid_attendance.php';
+require_once __DIR__ . '/includes/raid_card.php';
require_permission('raids.view');
-function render_signup_list(array $members, bool $draggable): void
-{
- ?>
-
-
-
-
- data-user-id="= e($memberUserId) ?>" data-name="= e($memberName) ?>" data-class="= e($memberClass) ?>">
-
- ⏳
-
-
-
- = e($memberName) ?> (= e($memberClass) ?>)
-
-
-
-
Max. Spieler
-
+
Gearscore
-
+
Anforderungen
-
-
-
= contribution_coin(16) ?> Punkte für Anwesende beim Archivieren
-
+
+
+
+ = contribution_coin(16) ?> Punkte für Anwesende beim Archivieren
+
+
+
+ Abzug für Abwesende
+
+
+
Wird beim Archivieren automatisch vergeben - außer es wurden vorher schon Punkte für den Raid verteilt. Ohne Anwesenheitsliste bekommen alle in den Gruppen die Punkte, einen Abzug gibt es dann nicht. Standard: += RAID_POINTS_DEFAULT_PRESENT ?> pro Teilnahme, höchstens = RAID_POINTS_MAX ?>; 0 = keine Automatik.
-
- Abzug für Abwesende
-
-
-
Wird beim Archivieren automatisch vergeben - außer es wurden vorher schon Punkte für den Raid verteilt. Ohne Anwesenheitsliste bekommen alle in den Gruppen die Punkte, einen Abzug gibt es dann nicht. 0 = keine Automatik.
-
-
+
+
= contribution_coin(15) ?> = e(raid_points_summary(RAID_POINTS_DEFAULT_PRESENT, RAID_POINTS_DEFAULT_ABSENT)) ?> – die Werte legt die Legionsleitung fest.
+
+ ['id' => (int) ($p['id'] ?? 0), 'name' => (string) ($p['name'] ?? '')], $premades);
+ ?>
+
data-premades='= e(json_encode($premadeOptions, JSON_UNESCAPED_UNICODE)) ?>'>
Gruppen
+
Jede Gruppe hat = RAID_GROUP_SIZE ?> Plätze (1 Tank, 1 Heiler, 3 DPS) und füllt sich über die Anmeldungen. Eine feste Premade kannst du direkt einer Gruppe zuordnen – die Gruppe heißt dann wie die Premade, wird gesperrt und die Mitglieder bekommen eine Einladung per Discord-PN.
@@ -172,280 +156,27 @@ include __DIR__ . '/includes/header.php';
Raid-Daten konnten nicht geladen werden: = e($apiError) ?>
-
-
= e($emptyLabels[$status]) ?>
+
+
+
= e($emptyLabels[$status]) ?>
+
+ $status,
+ 'current_discord_id' => $currentDiscordId,
+ 'can_manage' => $canManageRaids,
+ 'can_set_points' => $canSetRaidPoints,
+ 'settings' => $raidSettings,
+ 'premades' => $premades,
+ ];
+ ?>
+
- =1 echte Gruppe, 0 Ersatzbank, -1 abgemeldet.
- $signupsByGroup = [];
- $benchSignups = [];
- $declinedSignups = [];
- $mySignup = null;
- foreach ($signups as $signup) {
- $groupNumber = (int) ($signup['group'] ?? 0);
- if ($groupNumber >= 1) {
- $signupsByGroup[$groupNumber][] = $signup;
- } elseif ($groupNumber === 0) {
- $benchSignups[] = $signup;
- } else {
- $declinedSignups[] = $signup;
- }
- if ($currentDiscordId && (string) ($signup['user_id'] ?? '') === (string) $currentDiscordId && $groupNumber >= 0) {
- $mySignup = $signup;
- }
- }
-
- // Wie im Bot-Embed zaehlen nur echte, bestaetigte Anmeldungen als "aktiv".
- $activeCount = 0;
- foreach ($signupsByGroup as $groupMembers) {
- foreach ($groupMembers as $groupMember) {
- if (($groupMember['class'] ?? '') !== 'Ausstehend') {
- $activeCount++;
- }
- }
- }
-
- $raidSetting = $raidSettings[(string) $raidId] ?? null;
- $autoPresent = (int) ($raidSetting['points_present'] ?? 0);
- $autoAbsent = (int) ($raidSetting['points_absent'] ?? 0);
- $raidStarted = !empty($raid['timestamp']) && (int) $raid['timestamp'] <= time();
-
- // Suchtext fuer die Raid-Suche: Titel, Termin, Anforderungen, Gruppen, Spieler und Klassen
- $searchText = mb_strtolower(implode(' ', array_merge(
- [$title, $dateLabel, $requirements, $gearscore],
- $groupNames,
- array_map(static fn ($s) => ($s['name'] ?? '') . ' ' . ($s['class'] ?? ''), $signups)
- )));
-
- $mySignupGroupNumber = $mySignup ? (int) ($mySignup['group'] ?? 0) : null;
- $mySignupGroupLabel = $mySignupGroupNumber === 0 ? 'Ersatzbank' : ($mySignupGroupNumber ? ($groupNames[$mySignupGroupNumber - 1] ?? ('#' . $mySignupGroupNumber)) : null);
- ?>
-
-
-
= e($dateLabel) ?>
-
-
-
Anwesenheit
-
-
kontrolliert
-
-
noch nicht kontrolliert
-
- 0 || $autoAbsent > 0): ?>
-
- = contribution_coin(15) ?> += $autoPresent ?>= $autoAbsent > 0 ? ' / −' . $autoAbsent : '' ?>
- = !empty($raidSetting['auto_processed_at']) ? '· ' . e((string) $raidSetting['auto_result']) : 'beim Archivieren' ?>
-
-
-
-
-
-
= icon('list') ?> Anforderungen: = e($requirements) ?>
-
-
-
Gearscore: = e($gearscore) ?>
-
-
-
-
-
-
-
- Anforderungen
- = e($requirements) ?>
-
-
-
-
Gruppen
-
-
+ Gruppe hinzufügen
-
-
- Speichern
-
-
-
-
-
-
- Premade einladen
-
-
-
- = e((string) ($premade['name'] ?? '')) ?>
-
-
-
- $groupName): ?>
- = e($groupName) ?>
-
-
- Einladen
-
-
-
-
-
-
-
-
-
- $groupName): ?>
-
-
-
= e($groupName) ?> (= count($members) ?>) = $isLockedGroup ? ' ' . icon('lock') : '' ?>
-
-
Keine Anmeldungen
-
-
-
-
-
-
-
Ersatzbank (= count($benchSignups) ?>)
-
-
Keine Anmeldungen
-
-
-
-
-
-
-
-
- Abgemeldet: = e(implode(', ', array_map(static fn ($s) => (string) ($s['name'] ?? '?'), $declinedSignups))) ?>
-
-
-
-
-
Dieser Raid ist archiviert – Anmeldungen sind geschlossen.
-
-
Verknüpfe deinen Discord-Account , um dich anzumelden.
-
-
-
-
- Du bist angemeldet als = e((string) ($mySignup['class'] ?? '')) ?>
- in = e($mySignupGroupLabel) ?> .
-
-
- Ändern
-
- = csrf_field() ?>
-
-
- Abmelden
-
-
-
-
Anmelden
-
-
-
-
+
+
diff --git a/raids_live.php b/raids_live.php
new file mode 100644
index 0000000..b0e4403
--- /dev/null
+++ b/raids_live.php
@@ -0,0 +1,95 @@
+:
,:,...
+ *
+ * Antwort: Reihenfolge der Raids, ihr aktueller Fingerabdruck (rev) und fertig gerenderte Karten
+ * fuer alle Raids, deren Fingerabdruck sich gegenueber "known" geaendert hat. Aenderungen aus dem
+ * Discord kommen so ebenfalls an, weil die Daten wie auf der Seite live von der Raid-API stammen.
+ */
+require_once __DIR__ . '/includes/bootstrap.php';
+require_once __DIR__ . '/includes/raid_card.php';
+
+// Wird per fetch() aufgerufen - Fehler deshalb als JSON statt Weiterleitung auf die Login-Seite.
+if (!current_user()) {
+ http_response_code(401);
+ json_response(false, 'Bitte neu anmelden.');
+}
+if (!user_has_permission('raids.view')) {
+ http_response_code(403);
+ json_response(false, 'Dir fehlt die Berechtigung, Raids zu sehen.');
+}
+
+$status = (string) ($_GET['status'] ?? 'active');
+if (!in_array($status, RAID_STATUSES, true)) {
+ $status = 'active';
+}
+$known = [];
+foreach (explode(',', (string) ($_GET['known'] ?? '')) as $pair) {
+ $parts = explode(':', trim($pair), 2);
+ if (count($parts) === 2 && ctype_digit($parts[0])) {
+ $known[$parts[0]] = $parts[1];
+ }
+}
+
+$currentUser = current_user();
+$canManageRaids = user_has_permission('raids.manage');
+$canSetRaidPoints = $canManageRaids && user_has_permission('raids.points');
+// Die Formulare in den Karten brauchen das CSRF-Token der Sitzung - danach die Sitzung freigeben,
+// damit eine langsame Raid-API andere Tabs derselben Person nicht blockiert.
+csrf_token();
+session_write_close();
+
+try {
+ $raids = fetch_raids($status);
+} catch (Throwable $e) {
+ http_response_code(502);
+ json_response(false, 'Raid-Daten konnten nicht geladen werden.');
+}
+try {
+ $raidSettings = raid_settings_all();
+} catch (PDOException $e) {
+ $raidSettings = [];
+}
+
+$order = [];
+$revs = [];
+$changed = [];
+foreach ($raids as $raid) {
+ $raidId = (string) (int) ($raid['raid_id'] ?? 0);
+ $rev = raid_card_rev($raid, $raidSettings[$raidId] ?? null);
+ $order[] = $raidId;
+ $revs[$raidId] = $rev;
+ if (isset($known[$raidId]) && $known[$raidId] !== $rev) {
+ $changed[$raidId] = $raid;
+ }
+}
+
+$cards = [];
+if (!empty($changed)) {
+ $premades = [];
+ if ($canManageRaids) {
+ try {
+ $premades = fetch_premades();
+ } catch (Throwable $e) {
+ $premades = [];
+ }
+ }
+ $context = [
+ 'status' => $status,
+ 'current_discord_id' => $currentUser['discord_id'] ?? null,
+ 'can_manage' => $canManageRaids,
+ 'can_set_points' => $canSetRaidPoints,
+ 'settings' => $raidSettings,
+ 'premades' => $premades,
+ ];
+ foreach ($changed as $raidId => $raid) {
+ ob_start();
+ render_raid_card($raid, $context);
+ $cards[$raidId] = trim((string) ob_get_clean());
+ }
+}
+
+header('Cache-Control: no-store');
+json_response(true, '', ['order' => $order, 'revs' => $revs, 'cards' => (object) $cards]);
diff --git a/reports.php b/reports.php
index 9640cc8..2ff5edf 100644
--- a/reports.php
+++ b/reports.php
@@ -208,7 +208,7 @@ include __DIR__ . '/includes/header.php';
= icon($isArchived ? 'restore' : 'archive') ?>
-
+
= csrf_field() ?>
diff --git a/shop_manage.php b/shop_manage.php
index b279657..eb0be5e 100644
--- a/shop_manage.php
+++ b/shop_manage.php
@@ -120,7 +120,7 @@ include __DIR__ . '/includes/header.php';
+ data-confirm="= e('„' . $item['name'] . '“ mit dem Lagerhaus verknüpfen?' . ((int) $item['stock'] > 0 ? ' Der Shop-Bestand von ' . (int) $item['stock'] . ' Stück wird dort eingelagert.' : '') . ' Danach kommt der Bestand automatisch aus dem Lagerhaus.') ?>" data-confirm-title="Mit dem Lagerhaus verknüpfen" data-confirm-ok="Verknüpfen">
= csrf_field() ?>
@@ -128,7 +128,7 @@ include __DIR__ . '/includes/header.php';
+ data-confirm="= e('„' . $item['name'] . '“ aus dem Shop löschen? Bisherige Anträge bleiben erhalten.') ?>" data-confirm-title="Gegenstand löschen" data-confirm-danger data-confirm-ok="Löschen">
= csrf_field() ?>
@@ -159,7 +159,7 @@ include __DIR__ . '/includes/header.php';
Speichern
+ data-confirm="= e('Kategorie „' . $category['name'] . '“ löschen? Ihre Gegenstände bleiben ohne Kategorie im Shop.') ?>" data-confirm-title="Kategorie löschen" data-confirm-danger data-confirm-ok="Löschen">
= csrf_field() ?>
diff --git a/sql/schema.sql b/sql/schema.sql
index 8102b5b..ab0ff80 100644
--- a/sql/schema.sql
+++ b/sql/schema.sql
@@ -385,6 +385,34 @@ CREATE TABLE IF NOT EXISTS tactic_shapes (
INDEX idx_tactic_shapes_step (step_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+-- Verlauf und Papierkorb: gesicherte Staende einer Taktik - vor Aenderungen hoechstens alle
+-- 30 Minuten je Person, vor dem Loeschen und Wiederherstellen immer (includes/tactics.php).
+-- tactic_id bewusst OHNE Fremdschluessel, damit die Sicherung das Loeschen der Taktik ueberlebt.
+-- Alte Staende verschwinden nach 90 Tagen (die neuesten fuenf je Taktik bleiben), geloeschte
+-- Taktiken 90 Tage nach dem Loeschen.
+CREATE TABLE IF NOT EXISTS tactic_revisions (
+ id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
+ tactic_id INT UNSIGNED NOT NULL,
+ map_slug VARCHAR(60) NOT NULL,
+ name VARCHAR(120) NOT NULL,
+ -- So war die Taktik beim Sichern - danach richten sich die Rechte, auch nach dem Loeschen
+ visibility ENUM('private', 'public') NOT NULL,
+ highlight ENUM('none', 'recommended', 'official') NOT NULL DEFAULT 'none',
+ owner_id INT UNSIGNED NULL,
+ -- edit = vor einer Aenderung, delete = vor dem Loeschen, restore = vor dem Wiederherstellen
+ reason ENUM('edit', 'delete', 'restore') NOT NULL DEFAULT 'edit',
+ step_count INT UNSIGNED NOT NULL DEFAULT 0,
+ shape_count INT UNSIGNED NOT NULL DEFAULT 0,
+ -- JSON: Felder der Taktik und die Schritte in Reihenfolge samt Zeichnungen (tactic_export)
+ snapshot MEDIUMTEXT NOT NULL,
+ created_by INT UNSIGNED NULL,
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE SET NULL,
+ FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
+ INDEX idx_tactic_revisions_tactic (tactic_id, created_at),
+ INDEX idx_tactic_revisions_map (map_slug, reason)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
-- Wiki (Einsteiger-Guide): Kapitel und Unterseiten, Versionen, Mitwirkende
CREATE TABLE IF NOT EXISTS wiki_pages (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
@@ -557,6 +585,8 @@ CREATE TABLE IF NOT EXISTS calendar_entries (
ends_at DATETIME NULL,
-- Treffpunkt auf der Karte (Link /map.php?karte=...&x=...&y=...)
location_path VARCHAR(300) NULL,
+ -- Fuer wen: all (alle), leadership (alle sehen ihn, teilnehmen nur die Leitung), internal (nur die Leitung sieht ihn)
+ audience ENUM('all', 'leadership', 'internal') NOT NULL DEFAULT 'all',
-- visible / pending (Moderation wie bei Kommentaren)
status VARCHAR(10) NOT NULL DEFAULT 'visible',
moderation_note VARCHAR(255) NULL,
@@ -610,6 +640,8 @@ CREATE TABLE IF NOT EXISTS gear_sets (
name VARCHAR(80) NOT NULL,
class_name VARCHAR(30) NULL,
note VARCHAR(255) NULL,
+ -- Link zum eigenen Skill-/Daevanion-Plan auf einer Planer-Seite (GEAR_BUILD_HOSTS)
+ build_url VARCHAR(300) NULL,
-- 1 = auf der eigenen Profilseite zeigen (dann koennen alle Mitglieder es ansehen und vergleichen)
show_on_profile TINYINT(1) NOT NULL DEFAULT 0,
sort_order INT NOT NULL DEFAULT 0,
diff --git a/tactics_api.php b/tactics_api.php
index be2c302..3fc5bff 100644
--- a/tactics_api.php
+++ b/tactics_api.php
@@ -37,6 +37,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
'can_create' => true,
'can_highlight' => user_has_permission('map.tactics.highlight'),
'tactics' => tactics_for_map($slug, $userId),
+ // Papierkorb: nur, was dieses Konto wiederherstellen darf
+ 'deleted' => tactics_deleted_for_map($slug, $userId),
]);
}
@@ -74,21 +76,26 @@ function tactic_load(int $tacticId, int $userId, bool $forEdit = true): array
json_response(false, 'Diese Taktik gibt es nicht mehr - bitte die Seite neu laden.');
}
if ($forEdit && !tactic_can_edit($tactic, $userId)) {
- json_response(false, 'Diese Taktik darfst du nicht bearbeiten - nur der Ersteller (und bei öffentlichen Taktiken die Leitung).');
+ json_response(false, ($tactic['highlight'] ?? '') === 'official'
+ ? 'Offizielle Taktiken darf außer dem Ersteller nur bearbeiten, wer Taktiken hervorheben darf.'
+ : 'Diese Taktik darfst du nicht bearbeiten - nur der Ersteller und bei öffentlichen Taktiken die Strategen.');
}
return $tactic;
}
-/** Sucht einen Schritt, prueft das Bearbeitungsrecht an seiner Taktik und liefert ihn. */
+/**
+ * Sucht einen Schritt, prueft das Bearbeitungsrecht an seiner Taktik und liefert ihn - unter
+ * 'tactic' die Taktik (wie von tactic_load).
+ */
function tactic_step_owner(int $stepId, int $userId): array
{
- $stmt = db()->prepare('SELECT id, tactic_id, sort_order FROM tactic_steps WHERE id = ?');
+ $stmt = db()->prepare('SELECT id, tactic_id, title, sort_order FROM tactic_steps WHERE id = ?');
$stmt->execute([$stepId]);
$step = $stmt->fetch();
if (!$step) {
json_response(false, 'Diesen Schritt gibt es nicht mehr - bitte die Seite neu laden.');
}
- tactic_load((int) $step['tactic_id'], $userId);
+ $step['tactic'] = tactic_load((int) $step['tactic_id'], $userId);
return $step;
}
@@ -106,19 +113,6 @@ function tactic_visibility_label(string $visibility): string
return $visibility === 'public' ? 'öffentlich' : 'privat (nur für den Ersteller)';
}
-/** Legt einen Schritt am Ende der Taktik an und gibt seine ID zurueck. */
-function tactic_append_step(int $tacticId, string $title, string $description = ''): int
-{
- $stmt = db()->prepare('SELECT COALESCE(MAX(sort_order), 0) + 1 FROM tactic_steps WHERE tactic_id = ?');
- $stmt->execute([$tacticId]);
- $order = (int) $stmt->fetchColumn();
-
- db()->prepare('INSERT INTO tactic_steps (tactic_id, title, description, sort_order) VALUES (?, ?, ?, ?)')
- ->execute([$tacticId, $title, $description, $order]);
-
- return (int) db()->lastInsertId();
-}
-
try {
switch ($action) {
// ---- Taktiken ----
@@ -151,6 +145,54 @@ try {
}
json_response(true, 'Taktik angelegt.', ['tactic_id' => $tacticId, 'step_id' => $stepId]);
+ case 'tactic_copy':
+ // Kopieren darf jeder, der die Taktik sehen kann - so lassen sich auch offizielle als
+ // eigene Vorlage weiterfuehren. Die Kopie gehoert dem Kopierenden, ist standardmaessig
+ // privat und nicht hervorgehoben; die Vorlage bleibt unveraendert.
+ $source = tactic_load((int) ($input['tactic_id'] ?? 0), $userId, false);
+ $name = tactic_text($input, 'name', 120, 'einen Namen', false);
+ if ($name === '') {
+ $name = mb_substr('Kopie von ' . $source['name'], 0, 120);
+ }
+ $visibility = in_array($input['visibility'] ?? '', TACTIC_VISIBILITIES, true) ? (string) $input['visibility'] : 'private';
+
+ $pdo = db();
+ $pdo->beginTransaction();
+ $pdo->prepare('INSERT INTO tactics (map_slug, name, description, visibility, created_by) VALUES (?, ?, ?, ?, ?)')
+ ->execute([(string) $source['map_slug'], $name, (string) ($source['description'] ?? ''), $visibility, $userId]);
+ $copyId = (int) $pdo->lastInsertId();
+
+ // Schritt fuer Schritt in derselben Reihenfolge, die Zeichnungen wie bei "+ Kopie dieses Schritts"
+ $sourceSteps = $pdo->prepare('SELECT id, title, description FROM tactic_steps WHERE tactic_id = ? ORDER BY sort_order, id');
+ $sourceSteps->execute([(int) $source['id']]);
+ $copyShapes = $pdo->prepare(
+ 'INSERT INTO tactic_shapes (step_id, shape_type, label, color, width, points, created_by)
+ SELECT ?, shape_type, label, color, width, points, ? FROM tactic_shapes WHERE step_id = ? ORDER BY id'
+ );
+ $stepCount = 0;
+ foreach ($sourceSteps->fetchAll() as $sourceStep) {
+ $stepId = tactic_append_step($copyId, (string) $sourceStep['title'], (string) ($sourceStep['description'] ?? ''));
+ $copyShapes->execute([$stepId, $userId, (int) $sourceStep['id']]);
+ $stepCount++;
+ }
+ if ($stepCount === 0) {
+ tactic_append_step($copyId, '');
+ $stepCount = 1;
+ }
+ $pdo->commit();
+
+ // Private Kopien sind Entwuerfe einzelner Mitglieder - nur oeffentliche ins Log.
+ if ($visibility === 'public') {
+ admin_log('📋 Taktik kopiert', [
+ 'Taktik' => $name,
+ 'Vorlage' => (string) $source['name'],
+ 'Karte' => (string) $source['map_slug'],
+ 'Ersteller der Vorlage' => $source['created_by'] !== null ? admin_log_user((int) $source['created_by']) : '',
+ 'Schritte' => (string) $stepCount,
+ ], 'success');
+ }
+ json_response(true, 'Taktik kopiert.', ['tactic_id' => $copyId]);
+
case 'tactic_update':
$tacticId = (int) ($input['tactic_id'] ?? 0);
$old = tactic_load($tacticId, $userId);
@@ -162,9 +204,14 @@ try {
if ((int) $old['created_by'] === $userId && in_array($input['visibility'] ?? '', TACTIC_VISIBILITIES, true)) {
$visibility = (string) $input['visibility'];
}
+ // Eine hervorgehobene Taktik darf auch der Ersteller nicht einfach verschwinden lassen.
+ if ($visibility !== $old['visibility'] && !tactic_can_change_visibility($old, $userId)) {
+ json_response(false, 'Hervorgehobene Taktiken kann nur privat stellen, wer Taktiken hervorheben darf - bitte zuerst die Hervorhebung entfernen lassen.');
+ }
// Private Taktiken koennen nicht hervorgehoben sein.
$highlight = $visibility === 'public' ? (string) $old['highlight'] : 'none';
+ tactic_snapshot_if_due($tacticId, $userId);
if ($highlight === 'none') {
db()->prepare(
"UPDATE tactics SET name = ?, description = ?, visibility = ?, highlight = 'none',
@@ -221,10 +268,20 @@ try {
case 'tactic_delete':
$tactic = tactic_load((int) ($input['tactic_id'] ?? 0), $userId);
+ if (!tactic_can_delete($tactic, $userId)) {
+ json_response(false, 'Hervorgehobene Taktiken kann nur löschen, wer Taktiken hervorheben darf - bitte zuerst die Hervorhebung entfernen lassen.');
+ }
$stepCount = db()->prepare('SELECT COUNT(*) FROM tactic_steps WHERE tactic_id = ?');
$stepCount->execute([(int) $tactic['id']]);
$steps = (string) $stepCount->fetchColumn();
- db()->prepare('DELETE FROM tactics WHERE id = ?')->execute([(int) $tactic['id']]);
+
+ $pdo = db();
+ $pdo->beginTransaction();
+ // Vorher immer sichern: die Taktik landet im Papierkorb ("Gelöschte" im Taktik-Panel).
+ tactic_snapshot((int) $tactic['id'], 'delete', $userId);
+ $pdo->prepare('DELETE FROM tactics WHERE id = ?')->execute([(int) $tactic['id']]);
+ $pdo->commit();
+
if (tactic_should_log($tactic, $userId)) {
admin_log((int) $tactic['created_by'] !== $userId ? '🗑️ Fremde Taktik gelöscht' : '🗑️ Taktik gelöscht', [
'Taktik' => $tactic['name'],
@@ -233,6 +290,7 @@ try {
'Sichtbarkeit' => tactic_visibility_label((string) $tactic['visibility']),
'Hervorhebung' => TACTIC_HIGHLIGHTS[$tactic['highlight']] ?? '',
'Schritte' => $steps,
+ 'Wiederherstellen' => TACTIC_REVISION_DAYS . ' Tage lang im Taktik-Panel unter „Gelöschte“',
], 'danger');
}
json_response(true, 'Taktik gelöscht.');
@@ -245,6 +303,7 @@ try {
$description = tactic_text($input, 'description', 5000, 'die Beschreibung', false);
$copyFrom = (int) ($input['copy_from'] ?? 0);
+ tactic_snapshot_if_due($tacticId, $userId);
$pdo = db();
$pdo->beginTransaction();
$stepId = tactic_append_step($tacticId, $title, $description);
@@ -272,6 +331,7 @@ try {
$title = tactic_text($input, 'title', 120, 'einen Titel', false);
$description = tactic_text($input, 'description', 5000, 'die Beschreibung', false);
+ tactic_snapshot_if_due((int) $step['tactic_id'], $userId);
db()->prepare('UPDATE tactic_steps SET title = ?, description = ? WHERE id = ?')
->execute([$title, $description, (int) $step['id']]);
tactic_touch((int) $step['tactic_id']);
@@ -279,15 +339,36 @@ try {
case 'step_delete':
$step = tactic_step_owner((int) ($input['step_id'] ?? 0), $userId);
+ $tactic = $step['tactic'];
- $count = db()->prepare('SELECT COUNT(*) FROM tactic_steps WHERE tactic_id = ?');
- $count->execute([(int) $step['tactic_id']]);
- if ((int) $count->fetchColumn() <= 1) {
+ $order = db()->prepare('SELECT id FROM tactic_steps WHERE tactic_id = ? ORDER BY sort_order, id');
+ $order->execute([(int) $step['tactic_id']]);
+ $stepIds = array_map('intval', $order->fetchAll(PDO::FETCH_COLUMN));
+ if (count($stepIds) <= 1) {
json_response(false, 'Eine Taktik braucht mindestens einen Schritt.');
}
+ $shapeCount = db()->prepare('SELECT COUNT(*) FROM tactic_shapes WHERE step_id = ?');
+ $shapeCount->execute([(int) $step['id']]);
+ $shapes = (string) $shapeCount->fetchColumn();
+ tactic_snapshot_if_due((int) $step['tactic_id'], $userId);
db()->prepare('DELETE FROM tactic_steps WHERE id = ?')->execute([(int) $step['id']]);
tactic_touch((int) $step['tactic_id']);
+
+ // In fremden Taktiken zaehlt das wie eine Loeschung (Notbremse, siehe includes/security.php) -
+ // sonst liesse sich eine Taktik Schritt fuer Schritt unbemerkt leeren. Eigene bleiben still.
+ if ((int) ($tactic['created_by'] ?? 0) !== $userId) {
+ $position = array_search((int) $step['id'], $stepIds, true);
+ admin_log('🗑️ Schritt einer fremden Taktik gelöscht', [
+ 'Taktik' => (string) $tactic['name'],
+ 'Karte' => (string) $tactic['map_slug'],
+ 'Ersteller' => $tactic['created_by'] !== null ? admin_log_user((int) $tactic['created_by']) : '',
+ 'Schritt' => ($position !== false ? 'Schritt ' . ($position + 1) : '')
+ . ((string) $step['title'] !== '' ? ' – ' . $step['title'] : ''),
+ 'Zeichnungen' => $shapes,
+ 'Wiederherstellen' => 'im Taktik-Panel über „🕘 Verlauf“',
+ ], 'danger');
+ }
json_response(true, 'Schritt gelöscht.');
case 'step_move':
@@ -307,6 +388,7 @@ try {
}
[$ids[$index], $ids[$target]] = [$ids[$target], $ids[$index]];
+ tactic_snapshot_if_due((int) $step['tactic_id'], $userId);
$pdo = db();
$pdo->beginTransaction();
$update = $pdo->prepare('UPDATE tactic_steps SET sort_order = ? WHERE id = ?');
@@ -335,6 +417,7 @@ try {
$width = max(1, min(30, (int) ($input['width'] ?? 4)));
$label = tactic_text($input, 'label', 200, 'die Beschriftung', $type === 'text');
+ tactic_snapshot_if_due((int) $step['tactic_id'], $userId);
db()->prepare(
'INSERT INTO tactic_shapes (step_id, shape_type, label, color, width, points, created_by)
VALUES (?, ?, ?, ?, ?, ?, ?)'
@@ -363,10 +446,119 @@ try {
}
tactic_load($tacticId, $userId);
+ // Kein eigener Log-Eintrag pro Zeichnung - der Verlauf zeigt, wer wann etwas geaendert hat.
+ tactic_snapshot_if_due($tacticId, $userId);
db()->prepare('DELETE FROM tactic_shapes WHERE id = ?')->execute([$shapeId]);
tactic_touch($tacticId);
json_response(true, '');
+ // ---- Verlauf und Papierkorb ----
+ case 'revision_list':
+ // Nur fuer bestehende Taktiken, die das Konto bearbeiten darf (Staende aus privater
+ // Zeit filtert tactic_revision_list zusaetzlich) - geloeschte stehen im GET unter "deleted".
+ $tactic = tactic_load((int) ($input['tactic_id'] ?? 0), $userId);
+ json_response(true, '', ['revisions' => tactic_revision_list($tactic, $userId)]);
+
+ case 'revision_restore':
+ $stmt = db()->prepare(
+ 'SELECT id, tactic_id, map_slug, name, visibility, highlight, owner_id, reason, snapshot, created_by, created_at
+ FROM tactic_revisions WHERE id = ?'
+ );
+ $stmt->execute([(int) ($input['revision_id'] ?? 0)]);
+ $revision = $stmt->fetch();
+ $gone = 'Diesen Stand gibt es nicht mehr - bitte die Seite neu laden.';
+ // Die Rechte haengen am gesicherten Stand: ein privater Stand bleibt fuer alle ausser
+ // dem Ersteller unsichtbar, auch wenn die Taktik inzwischen oeffentlich ist.
+ $subject = $revision ? tactic_revision_subject($revision) : [];
+ if (!$revision || !tactic_can_view($subject, $userId)) {
+ json_response(false, $gone);
+ }
+ $tacticId = (int) $revision['tactic_id'];
+ $exists = db()->prepare('SELECT COUNT(*) FROM tactics WHERE id = ?');
+ $exists->execute([$tacticId]);
+ // Gibt es die Taktik noch, gilt ausserdem, was die Taktik jetzt ist (tactic_load prueft
+ // Sehen und Bearbeiten - inzwischen private Taktiken anderer gelten als nicht vorhanden).
+ $current = (int) $exists->fetchColumn() > 0 ? tactic_load($tacticId, $userId) : null;
+
+ if ($current === null) {
+ // Geloeschte Taktik: nur aus der Sicherung vor dem Loeschen (ihrem neuesten Stand)
+ // und nur mit denselben Rechten, die das Loeschen gebraucht hat.
+ $newest = db()->prepare('SELECT id FROM tactic_revisions WHERE tactic_id = ? ORDER BY created_at DESC, id DESC LIMIT 1');
+ $newest->execute([$tacticId]);
+ if ((int) $newest->fetchColumn() !== (int) $revision['id']) {
+ json_response(false, $gone);
+ }
+ if (!tactic_can_delete($subject, $userId)) {
+ json_response(false, 'Diese Taktik darfst du nicht wiederherstellen - nur wer sie auch löschen dürfte.');
+ }
+ }
+
+ $data = json_decode((string) $revision['snapshot'], true);
+ if (!is_array($data) || !is_array($data['tactic'] ?? null) || !is_array($data['steps'] ?? null)) {
+ json_response(false, 'Dieser Stand ist beschädigt und lässt sich nicht wiederherstellen.');
+ }
+ $when = date('d.m.Y H:i', (int) strtotime((string) $revision['created_at']));
+
+ $pdo = db();
+ $pdo->beginTransaction();
+ if ($current !== null) {
+ // Der jetzige Stand kommt selbst in den Verlauf - so laesst sich auch das
+ // Wiederherstellen rueckgaengig machen. Sichtbarkeit und Hervorhebung bleiben, wie sie sind.
+ tactic_snapshot($tacticId, 'restore', $userId);
+ $pdo->prepare('DELETE FROM tactic_steps WHERE tactic_id = ?')->execute([$tacticId]); // Zeichnungen per ON DELETE CASCADE
+ $pdo->prepare('UPDATE tactics SET name = ?, description = ?, updated_at = NOW() WHERE id = ?')
+ ->execute([(string) $revision['name'], (string) ($data['tactic']['description'] ?? ''), $tacticId]);
+ } else {
+ // Mit der alten ID (AUTO_INCREMENT vergibt sie nie neu), damit der Verlauf dranbleibt -
+ // und mit Ersteller, Sichtbarkeit und Hervorhebung wie vor dem Loeschen.
+ $highlight = $revision['visibility'] === 'public' ? (string) $revision['highlight'] : 'none';
+ $highlightedBy = (int) ($data['tactic']['highlighted_by'] ?? 0);
+ if ($highlight === 'none' || empty(tactic_existing_users([$highlightedBy]))) {
+ $highlightedBy = null;
+ }
+ try {
+ $pdo->prepare(
+ 'INSERT INTO tactics (id, map_slug, name, description, visibility, highlight, highlighted_by,
+ highlighted_at, created_by, created_at, updated_at)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())'
+ )->execute([
+ $tacticId,
+ (string) $revision['map_slug'],
+ (string) $revision['name'],
+ (string) ($data['tactic']['description'] ?? ''),
+ (string) $revision['visibility'],
+ $highlight,
+ $highlightedBy,
+ $highlight !== 'none' ? tactic_datetime($data['tactic']['highlighted_at'] ?? null) : null,
+ $revision['owner_id'] !== null ? (int) $revision['owner_id'] : null,
+ tactic_datetime($data['tactic']['created_at'] ?? null),
+ ]);
+ } catch (PDOException $e) {
+ if ((int) ($e->errorInfo[1] ?? 0) !== 1062) {
+ throw $e;
+ }
+ $pdo->rollBack();
+ json_response(false, 'Diese Taktik wurde gerade schon wiederhergestellt - bitte die Seite neu laden.');
+ }
+ }
+ $steps = tactic_import_steps($tacticId, $data['steps']);
+ $pdo->commit();
+
+ $logged = $current ?? ['visibility' => $revision['visibility'], 'created_by' => $revision['owner_id']];
+ if (tactic_should_log($logged, $userId)) {
+ admin_log('♻️ Taktik wiederhergestellt', [
+ 'Taktik' => (string) $revision['name'],
+ 'Karte' => (string) $revision['map_slug'],
+ 'Ersteller' => $logged['created_by'] !== null ? admin_log_user((int) $logged['created_by']) : '',
+ 'Stand' => $current !== null ? 'vom ' . $when : 'vor dem Löschen am ' . $when . ' (aus dem Papierkorb)',
+ 'Vorheriger Stand' => $current !== null ? 'im Verlauf gesichert' : '',
+ 'Schritte' => (string) $steps,
+ ], 'success');
+ }
+ json_response(true, $current !== null
+ ? 'Der Stand vom ' . $when . ' ist wieder aktuell - der bisherige steht im Verlauf.'
+ : 'Taktik „' . $revision['name'] . '“ wiederhergestellt.', ['tactic_id' => $tacticId]);
+
default:
json_response(false, 'Unbekannte Aktion.');
}
diff --git a/warehouse.php b/warehouse.php
index 760a92e..4d1c6dc 100644
--- a/warehouse.php
+++ b/warehouse.php
@@ -291,7 +291,7 @@ include __DIR__ . '/includes/header.php';
+ data-confirm="Diesen Eintrag löschen? Der Bestand wird entsprechend angepasst." data-confirm-title="Eintrag löschen" data-confirm-danger data-confirm-ok="Löschen">
= csrf_field() ?>
diff --git a/wiki.php b/wiki.php
index c04dfe3..9f9fcb2 100644
--- a/wiki.php
+++ b/wiki.php
@@ -182,7 +182,7 @@ $nameOf = static fn (array $u): string => $u['display_name'] !== '' ? $u['displa
▼
+ data-confirm="Diese Seite= $page['parent_id'] === null ? ' samt allen Unterseiten' : '' ?> wirklich löschen?" data-confirm-title="Wiki-Seite löschen" data-confirm-danger data-confirm-ok="Löschen">
= csrf_field() ?>
@@ -279,7 +279,7 @@ $nameOf = static fn (array $u): string => $u['display_name'] !== '' ? $u['displa
= e($nameOf($contributor)) ?>
= class_badge_html($contributor['class_name'] ?? null, 18) ?>
-
+
= csrf_field() ?>
diff --git a/wiki_history.php b/wiki_history.php
index e26e59c..f516f37 100644
--- a/wiki_history.php
+++ b/wiki_history.php
@@ -58,7 +58,7 @@ include __DIR__ . '/includes/header.php';