Menu counts for open reports and moderation, item tooltips in warehouse and Lumishop
- Reports: the menu item shows how many reports are still open (not archived), for everyone with reports.view. The reports live in the bot, so the count sits in settings.reports_nav_cache and is fetched at most every 2 minutes with a short timeout (reports_nav_open()); the reports page refreshes it right away, also after archiving. reports_api_request() takes a timeout. - Moderation: the menu count now matches the "Freigabe" tab - waiting items plus reported items that are still visible (moderation_open_counts(), internal calendar entries only for calendar.leadership), with a title like "2 warten auf Freigabe, 1 gemeldet". - Warehouse and Lumishop cards get an info bubble on mouse hover or keyboard focus (not on touch): large image, category, stock, Lumishop price and the last movement in the warehouse; price, availability, amount in open requests and whether the own Lumipunkte suffice in the shop. Weapons and armour with the same name in the gear catalogue also show grade, level and base stats. Content is rendered as a <template> per card (includes/item_tooltip.php), shown and placed by assets/js/item-tooltip.js; the old native title on warehouse cards is gone. - Patch notes and README updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d984918b8c
commit
6f8040c397
11 changed files with 455 additions and 19 deletions
17
README.md
17
README.md
|
|
@ -350,6 +350,11 @@ Report-Karte in Discord einen "Archivieren"-Button neben "Löschen" (vorher lie
|
|||
löschen) - der Button-Text wechselt je nach aktuellem Status zwischen "Archivieren" und
|
||||
"Wiederherstellen".
|
||||
|
||||
Am Menüpunkt steht, wie viele Reports offen (nicht archiviert) sind - für alle mit `reports.view`.
|
||||
Die Reports liegen beim Bot: Die Zahl steht in `settings.reports_nav_cache` und wird höchstens alle
|
||||
2 Minuten mit kurzer Wartezeit neu geholt (`reports_nav_open()` in `includes/raids_api.php`); die
|
||||
Reports-Seite frischt sie beim Aufruf sofort auf, also auch direkt nach dem Archivieren.
|
||||
|
||||
Der Auto-Mute richtet sich nicht mehr nach der reinen Anzahl an Reports, sondern nach
|
||||
Report-**Punkten**: jeder Report zählt so viele Punkte, wie die höchste Discord-Rolle des Melders
|
||||
im Einstellungs-Panel dieser Seite hinterlegt hat (unkonfigurierte Rollen zählen 1 Punkt). Dort
|
||||
|
|
@ -658,6 +663,8 @@ Im **Lumishop** (`shop.php`) tauschen Mitglieder Lumipunkte gegen Gegenstände.
|
|||
- **Angebot** als Kacheln mit Bild, Kategorie, Beschreibung, Preis und verfügbarer Menge, dazu
|
||||
Suche und Kategoriefilter. Oben steht, wie viele Punkte man ausgeben kann: der Punktestand
|
||||
abzüglich der Punkte in eigenen offenen Anträgen.
|
||||
- **Info-Blase** beim Draufzeigen (Maus/Tastatur, siehe Lagerhaus): Preis, Verfügbarkeit, wie viel schon
|
||||
in offenen Anträgen steckt und ob die eigenen Lumipunkte reichen (bzw. wie viele fehlen).
|
||||
- **Beantragen:** Anzahl und optional eine Bemerkung (z.B. der Charaktername). Man darf mehr
|
||||
beantragen, als gerade verfügbar ist. Die Punkte müssen aber für die ganze Anzahl reichen,
|
||||
wobei offene Anträge schon abgezogen sind. Abgezogen wird noch nichts, und offene Anträge
|
||||
|
|
@ -716,6 +723,11 @@ Die Seite **Lagerhaus** (`warehouse.php`) führt Buch über die Gegenstände der
|
|||
für Spieler ohne Konto. Optional eine Bemerkung.
|
||||
- **Entnehmen:** Gegenstand aus dem Bestand, Anzahl, Zeitpunkt (jetzt oder von Hand) und
|
||||
optional an wen, wieder als Konto oder Name. Mehr als vorhanden lässt sich nicht entnehmen.
|
||||
- **Info-Blase** beim Draufzeigen mit der Maus bzw. beim Ansteuern mit der Tastatur (nicht beim Tippen am
|
||||
Handy): großes Bild, Name, Kategorie, Bestand, Lumishop-Preis und die letzte Bewegung (wann, wie viel,
|
||||
von/an wen). Gibt es den Gegenstand unter gleichem Namen im Gear-Katalog (`gear_items`), zeigt sie
|
||||
auch Seltenheit (farbig), Stufe und Grundwerte wie im Spiel (`includes/item_tooltip.php`,
|
||||
`assets/js/item-tooltip.js`; der Inhalt steht als `<template>` in jeder Kachel).
|
||||
- **Bestand** als Kacheln: Bild des Gegenstands mit der Menge, darunter Name und Kategorie.
|
||||
Dazu Suche und Kategoriefilter. Ein Klick auf eine Kachel zeigt den Verlauf dieses
|
||||
Gegenstands, die Knöpfe − und + öffnen Entnehmen bzw. Einlagern mit ihm.
|
||||
|
|
@ -1162,7 +1174,8 @@ unterhalb seiner eigenen Rolle ändern.
|
|||
## Moderation (Galeriebilder und Kommentare)
|
||||
|
||||
`includes/moderation.php`, Seite **Admin → Moderation** (`moderation.php`, Berechtigung
|
||||
`comments.moderate`, wartende Inhalte als Zahl am Menüpunkt). Grundsätzlich ist alles sofort
|
||||
`comments.moderate`). Am Menüpunkt steht, was offen ist - wie im Reiter „Freigabe“: wartende und
|
||||
gemeldete, noch sichtbare Inhalte (`moderation_open_counts()`). Grundsätzlich ist alles sofort
|
||||
sichtbar - erst nach Freigabe sichtbar (für alle außer Verfasser und Moderation) wird:
|
||||
|
||||
- alles von **neuen Mitgliedern** (erste 14 Tage seit Discord-Beitritt bzw. Kontoerstellung),
|
||||
|
|
@ -1207,7 +1220,7 @@ für neue Mitglieder automatisch. Die Schritte stehen am Ende von `dashboard.php
|
|||
Im Mitgliederbereich fragt jede offene Seite alle 20 Sekunden bei `live.php` nach, solange sie zu sehen
|
||||
ist (`assets/js/live.js`, Werte aus `includes/live_updates.php`):
|
||||
- **Menü:** Die Zahlen und Hinweise an den Menüpunkten (Raids, neue Galeriebilder, offene Shop-Anträge,
|
||||
Freischaltungen, Fehlermeldungen, Moderation, Wartung, Impressum, Patchnotes) und der eigene Punktestand
|
||||
Freischaltungen, Fehlermeldungen, Moderation, Reports, Wartung, Impressum, Patchnotes) und der eigene Punktestand
|
||||
werden direkt ersetzt. Der Seitenaufbau (`includes/header.php`) nutzt dieselben Funktionen
|
||||
(`nav_badges()`, `nav_points()`), die Menüpunkte tragen dafür `data-badge`.
|
||||
- **Seiteninhalt:** Für Dashboard, Galerie, Bildseite, Profilseite, Mitgliederliste, Kalender, Lumishop,
|
||||
|
|
|
|||
|
|
@ -2968,6 +2968,53 @@ a.button-small:hover { text-decoration: none; }
|
|||
}
|
||||
.button-secondary .shop-count { background: var(--gold); color: #1a1a1a; }
|
||||
|
||||
/* Info-Blase zu Gegenstaenden im Lagerhaus und Lumishop (assets/js/item-tooltip.js) */
|
||||
.item-tip {
|
||||
position: fixed;
|
||||
z-index: 3000;
|
||||
min-width: 220px;
|
||||
max-width: 300px;
|
||||
padding: 0.7rem 0.8rem;
|
||||
border: 1px solid rgba(201, 162, 39, 0.55);
|
||||
border-radius: 10px;
|
||||
background: rgba(18, 18, 18, 0.97);
|
||||
box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
|
||||
color: var(--text);
|
||||
font-size: 0.82rem;
|
||||
line-height: 1.4;
|
||||
pointer-events: none;
|
||||
}
|
||||
.item-tip[hidden] { display: none; }
|
||||
.item-tip-head { display: flex; align-items: center; gap: 0.65rem; }
|
||||
.item-tip-head .warehouse-icon { flex-shrink: 0; border-radius: 8px; }
|
||||
.item-tip-title { display: flex; flex-direction: column; min-width: 0; }
|
||||
.item-tip-title strong { font-size: 0.95rem; line-height: 1.25; overflow-wrap: anywhere; }
|
||||
.item-tip-title strong:not([class]) { color: var(--gold); }
|
||||
.item-tip-sub { color: var(--text-muted); font-size: 0.75rem; }
|
||||
.item-tip-stats {
|
||||
list-style: none;
|
||||
margin: 0.55rem 0 0;
|
||||
padding: 0.45rem 0 0;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
.item-tip-stats li,
|
||||
.item-tip-lines div { display: flex; justify-content: space-between; gap: 1rem; }
|
||||
.item-tip-value { color: #7ddc8a; font-weight: 600; white-space: nowrap; }
|
||||
.item-tip-text { margin: 0.55rem 0 0; color: var(--text-muted); overflow-wrap: anywhere; }
|
||||
.item-tip-lines {
|
||||
display: grid;
|
||||
gap: 0.2rem;
|
||||
margin: 0.55rem 0 0;
|
||||
padding-top: 0.45rem;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
.item-tip-lines dt { color: var(--text-muted); white-space: nowrap; }
|
||||
.item-tip-lines dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
|
||||
.item-tip-lines dd .contribution-coin { vertical-align: -2px; }
|
||||
.item-tip-lines .is-short { color: #f08a86; }
|
||||
.item-tip-lines .is-ok { color: #7ddc8a; }
|
||||
.item-tip-hint { margin-top: 0.5rem; color: var(--text-muted); font-size: 0.72rem; font-style: italic; }
|
||||
|
||||
.shop-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
||||
|
|
|
|||
93
assets/js/item-tooltip.js
Normal file
93
assets/js/item-tooltip.js
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* Info-Blase zu Gegenstaenden (Lagerhaus, Lumishop): Karten mit [data-item-tip] tragen ihren Inhalt als
|
||||
* <template class="item-tip-template"> (includes/item_tooltip.php). Beim Draufzeigen mit der Maus bzw.
|
||||
* beim Ansteuern mit der Tastatur erscheint er neben der Karte - rechts, sonst links, sonst darunter -
|
||||
* und immer ganz im Fenster. Auf Touch-Geraeten nicht: dort ist Tippen schon "oeffnen" bzw. "beantragen".
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var tip = null;
|
||||
var current = null;
|
||||
|
||||
function hide() {
|
||||
if (tip) tip.hidden = true;
|
||||
current = null;
|
||||
}
|
||||
|
||||
function place(card) {
|
||||
var box = card.getBoundingClientRect();
|
||||
var gap = 10;
|
||||
var margin = 8;
|
||||
var viewWidth = document.documentElement.clientWidth;
|
||||
var viewHeight = window.innerHeight;
|
||||
if (box.bottom < 0 || box.top > viewHeight) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
tip.style.left = '0px';
|
||||
tip.style.top = '0px';
|
||||
var width = tip.offsetWidth;
|
||||
var height = tip.offsetHeight;
|
||||
var left;
|
||||
var top = box.top;
|
||||
if (box.right + gap + width <= viewWidth - margin) {
|
||||
left = box.right + gap;
|
||||
} else if (box.left - gap - width >= margin) {
|
||||
left = box.left - gap - width;
|
||||
} else {
|
||||
left = box.left + box.width / 2 - width / 2;
|
||||
top = box.bottom + gap;
|
||||
if (top + height > viewHeight - margin) top = box.top - gap - height;
|
||||
}
|
||||
tip.style.left = Math.round(Math.min(Math.max(margin, left), viewWidth - width - margin)) + 'px';
|
||||
tip.style.top = Math.round(Math.min(Math.max(margin, top), viewHeight - height - margin)) + 'px';
|
||||
}
|
||||
|
||||
function show(card) {
|
||||
var template = card.querySelector('template.item-tip-template');
|
||||
if (!template) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
if (!tip) {
|
||||
tip = document.createElement('div');
|
||||
tip.className = 'item-tip';
|
||||
tip.setAttribute('role', 'tooltip');
|
||||
document.body.appendChild(tip);
|
||||
}
|
||||
if (current !== card) {
|
||||
tip.textContent = '';
|
||||
tip.appendChild(template.content.cloneNode(true));
|
||||
current = card;
|
||||
}
|
||||
tip.hidden = false;
|
||||
place(card);
|
||||
}
|
||||
|
||||
document.addEventListener('pointerover', function (event) {
|
||||
if (event.pointerType !== 'mouse') return;
|
||||
var card = event.target.closest('[data-item-tip]');
|
||||
if (card === current) return;
|
||||
if (card && !card.hidden) show(card);
|
||||
else hide();
|
||||
});
|
||||
document.documentElement.addEventListener('mouseleave', hide);
|
||||
document.addEventListener('focusin', function (event) {
|
||||
var card = event.target.closest('[data-item-tip]');
|
||||
if (card) show(card);
|
||||
else hide();
|
||||
});
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Escape') hide();
|
||||
});
|
||||
// Beim Scrollen mitwandern; verschwindet die Karte aus dem Bild, verschwindet auch die Blase
|
||||
window.addEventListener('scroll', function () {
|
||||
if (current) place(current);
|
||||
}, true);
|
||||
window.addEventListener('resize', hide);
|
||||
// Dialoge (Einlagern, Beantragen ...) gehen vor
|
||||
document.addEventListener('click', function (event) {
|
||||
if (event.target.closest('[data-open-modal], .shop-buy')) hide();
|
||||
});
|
||||
})();
|
||||
|
|
@ -314,8 +314,8 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => !i
|
|||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewReports): ?>
|
||||
<a href="/reports.php" data-nav="/reports.php"<?= $navOrder('/reports.php') ?> class="sidebar-link<?= $isReportsActive ? ' active' : '' ?>" title="Reports">
|
||||
<?= icon('flag') ?><span class="label">Reports</span>
|
||||
<a href="/reports.php" data-nav="/reports.php" data-badge="/reports.php"<?= $navOrder('/reports.php') ?> class="sidebar-link<?= $isReportsActive ? ' active' : '' ?>" title="Reports">
|
||||
<?= icon('flag') ?><span class="label">Reports</span><?= nav_badge_html($navBadges, '/reports.php') ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canManageBugs): ?>
|
||||
|
|
|
|||
95
includes/item_tooltip.php
Normal file
95
includes/item_tooltip.php
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Info-Blase zu Gegenstaenden im Lagerhaus und im Lumishop: gross das Bild, Name und Art - und fuer
|
||||
* Waffen und Ruestungen, die es auch im Gear-Katalog gibt (gear_items, gleicher Name), Seltenheit,
|
||||
* Stufe und Grundwerte wie im Spiel. Die Seiten geben den Inhalt als <template> in der Karte aus,
|
||||
* assets/js/item-tooltip.js zeigt ihn beim Draufzeigen (Maus) bzw. Ansteuern (Tastatur) an.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/gear.php';
|
||||
|
||||
/**
|
||||
* Gegenstaende aus dem Gear-Katalog mit diesen Namen (Gross-/Kleinschreibung egal). Gibt es einen
|
||||
* Namen mehrfach, gilt der mit der hoechsten Gegenstandsstufe.
|
||||
*
|
||||
* @param array<int, string> $names
|
||||
* @return array<string, array<string, mixed>> klein geschriebener Name => Gegenstand (gear_item_decode)
|
||||
*/
|
||||
function item_tip_gear(array $names): array
|
||||
{
|
||||
$names = array_values(array_unique(array_filter(array_map('trim', $names), static fn (string $name): bool => $name !== '')));
|
||||
if (empty($names)) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
$stmt = db()->prepare(
|
||||
'SELECT * FROM gear_items WHERE name IN (' . implode(',', array_fill(0, count($names), '?')) . ') ORDER BY item_level, id'
|
||||
);
|
||||
$stmt->execute($names);
|
||||
} catch (PDOException $e) {
|
||||
return []; // Gear-Planer noch nicht eingerichtet
|
||||
}
|
||||
$items = [];
|
||||
foreach ($stmt->fetchAll() as $row) {
|
||||
$items[mb_strtolower((string) $row['name'])] = gear_item_decode($row);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inhalt der Info-Blase als <template> (fuer assets/js/item-tooltip.js).
|
||||
*
|
||||
* @param array{name: string, icon_html: string, subtitle?: string, gear?: ?array<string, mixed>, text?: string,
|
||||
* lines?: array<int, array{0: string, 1: string}>, hint?: string} $tip
|
||||
* lines: [Beschriftung, Wert als fertiges HTML]; text: Beschreibung (Klartext, Zeilenumbrueche bleiben)
|
||||
*/
|
||||
function item_tip_template(array $tip): string
|
||||
{
|
||||
$gear = $tip['gear'] ?? null;
|
||||
$sub = [];
|
||||
$type = '';
|
||||
if ($gear) {
|
||||
$type = $gear['item_type'] !== '' && $gear['item_type'] !== $gear['slot'] ? gear_type_label((string) $gear['item_type']) : '';
|
||||
$sub[] = ($type !== '' ? $type . ' · ' : '') . $gear['grade'] . ' · Stufe ' . (int) $gear['item_level'];
|
||||
}
|
||||
// Die Kategorie nur, wenn sie nicht schon als Art dasteht ("Bogen · Epic · Stufe 45" statt noch mal "Bogen")
|
||||
if (($tip['subtitle'] ?? '') !== '' && $tip['subtitle'] !== $type) {
|
||||
$sub[] = (string) $tip['subtitle'];
|
||||
}
|
||||
|
||||
// Das Bild steht in der Karte schon geladen - in der Blase nicht erst "lazy" nachladen
|
||||
$html = '<template class="item-tip-template"><div class="item-tip-head">' . str_replace(' loading="lazy"', '', $tip['icon_html'])
|
||||
. '<div class="item-tip-title"><strong' . ($gear ? ' class="' . e(gear_grade_class((string) $gear['grade'])) . '"' : '') . '>'
|
||||
. e($tip['name']) . '</strong>';
|
||||
foreach ($sub as $line) {
|
||||
$html .= '<span class="item-tip-sub">' . e($line) . '</span>';
|
||||
}
|
||||
$html .= '</div></div>';
|
||||
|
||||
// Grundwerte aus dem Gear-Katalog - wie auf der Gegenstands-Karte im Gear-Planer
|
||||
$stats = $gear ? array_slice((array) $gear['stats'], 0, 10) : [];
|
||||
if ($stats) {
|
||||
$html .= '<ul class="item-tip-stats">';
|
||||
foreach ($stats as $stat) {
|
||||
$html .= '<li><span>' . e((string) $stat[0]) . '</span><span class="item-tip-value">'
|
||||
. e(gear_format_value((float) $stat[1], (string) ($stat[2] ?? ''))) . '</span></li>';
|
||||
}
|
||||
$html .= '</ul>';
|
||||
}
|
||||
if (($tip['text'] ?? '') !== '') {
|
||||
$html .= '<p class="item-tip-text">' . nl2br(e((string) $tip['text'])) . '</p>';
|
||||
}
|
||||
if (!empty($tip['lines'])) {
|
||||
$html .= '<dl class="item-tip-lines">';
|
||||
foreach ($tip['lines'] as [$label, $value]) {
|
||||
$html .= '<div><dt>' . e($label) . '</dt><dd>' . $value . '</dd></div>';
|
||||
}
|
||||
$html .= '</dl>';
|
||||
}
|
||||
if (($tip['hint'] ?? '') !== '') {
|
||||
$html .= '<div class="item-tip-hint">' . e((string) $tip['hint']) . '</div>';
|
||||
}
|
||||
return $html . '</template>';
|
||||
}
|
||||
|
|
@ -85,9 +85,21 @@ function nav_badges(array $user, string $currentScript, ?array $seen = null): ar
|
|||
}
|
||||
}
|
||||
if (user_has_permission('comments.moderate')) {
|
||||
$count = moderation_pending_count();
|
||||
// Wartet auf Freigabe und gemeldet, aber noch sichtbar - wie der Reiter "Freigabe"
|
||||
[$pending, $reported] = moderation_open_counts();
|
||||
if ($pending + $reported > 0) {
|
||||
$badges['/moderation.php'] = $plain($pending + $reported, implode(', ', array_filter([
|
||||
$pending > 0 ? $pending . ' ' . ($pending === 1 ? 'wartet' : 'warten') . ' auf Freigabe' : '',
|
||||
$reported > 0 ? $reported . ' gemeldet' : '',
|
||||
])));
|
||||
}
|
||||
}
|
||||
// Offene (nicht archivierte) Reports aus dem Discord-Bot - zwischengespeichert, includes/raids_api.php
|
||||
if (user_has_permission('reports.view')) {
|
||||
require_once __DIR__ . '/raids_api.php';
|
||||
$count = reports_nav_open();
|
||||
if ($count > 0) {
|
||||
$badges['/moderation.php'] = $plain($count, 'Warten auf Freigabe');
|
||||
$badges['/reports.php'] = $plain($count, $count === 1 ? '1 offener Report' : $count . ' offene Reports');
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
|
|
|
|||
|
|
@ -83,18 +83,30 @@ function moderation_initial_status(string $type, string $text = ''): array
|
|||
return ['visible', null];
|
||||
}
|
||||
|
||||
/** Wartende Inhalte (fuer die Zahl in der Seitenleiste). */
|
||||
function moderation_pending_count(): int
|
||||
/**
|
||||
* Offenes in der Moderation (fuer die Zahl in der Seitenleiste), gezaehlt wie auf moderation.php:
|
||||
* [wartet auf Freigabe, gemeldet und noch sichtbar]. Interne Termine der Leitung zaehlen nur fuer
|
||||
* Moderatoren, die sie auch sehen (calendar.leadership).
|
||||
*
|
||||
* @return array{0: int, 1: int}
|
||||
*/
|
||||
function moderation_open_counts(): array
|
||||
{
|
||||
$count = 0;
|
||||
foreach (MODERATION_TYPES as [$table]) {
|
||||
$pending = 0;
|
||||
$reported = 0;
|
||||
foreach (MODERATION_TYPES as $type => [$table]) {
|
||||
$where = $type === 'calendar' && !user_has_permission('calendar.leadership') ? "audience <> 'internal' AND " : '';
|
||||
try {
|
||||
$count += (int) db()->query("SELECT COUNT(*) FROM $table WHERE status = 'pending'")->fetchColumn();
|
||||
$pending += (int) db()->query("SELECT COUNT(*) FROM $table WHERE {$where}status = 'pending'")->fetchColumn();
|
||||
$reported += (int) db()->query(
|
||||
"SELECT COUNT(*) FROM $table t WHERE {$where}t.status = 'visible'
|
||||
AND EXISTS (SELECT 1 FROM content_reports r WHERE r.content_type = " . db()->quote($type) . " AND r.content_id = t.id)"
|
||||
)->fetchColumn();
|
||||
} catch (PDOException $e) {
|
||||
// Spalten/Tabellen noch nicht angelegt
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
return [$pending, $reported];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,6 +19,17 @@ const PATCHNOTE_TYPES = [
|
|||
];
|
||||
|
||||
const PATCHNOTES = [
|
||||
[
|
||||
'id' => '2026-09-25-d',
|
||||
'date' => '2026-09-25',
|
||||
'title' => 'Info-Blasen im Lagerhaus und Lumishop',
|
||||
'summary' => 'Zeig auf einen Gegenstand, und du siehst alles Wichtige dazu auf einen Blick.',
|
||||
'changes' => [
|
||||
['type' => 'neu', 'area' => 'Lagerhaus', 'text' => 'Zeigst du mit der Maus auf einen Gegenstand, erscheint eine Info-Blase: großes Bild, Bestand, Preis im Lumishop und wann zuletzt etwas eingelagert oder entnommen wurde - von bzw. an wen. Waffen und Rüstungen, die es im Gear-Planer gibt, zeigen dazu Seltenheit, Stufe und Grundwerte wie im Spiel.'],
|
||||
['type' => 'neu', 'area' => 'Lumishop', 'text' => 'Auch im Lumishop hat jeder Gegenstand eine Info-Blase: Preis, Verfügbarkeit, wie viel schon beantragt ist und ob deine Lumipunkte reichen - oder wie viele dir noch fehlen.'],
|
||||
['type' => 'neu', 'area' => 'Verwaltung', 'text' => 'Am Menüpunkt „Reports“ steht jetzt, wie viele Reports noch offen (nicht archiviert) sind. „Moderation“ zählt neben wartenden Inhalten auch gemeldete, die noch sichtbar sind.', 'audience' => 'leitung'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => '2026-09-25-c',
|
||||
'date' => '2026-09-25',
|
||||
|
|
|
|||
|
|
@ -995,7 +995,7 @@ function reports_guild_id(): int
|
|||
* @return array<string, mixed>
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
function reports_api_request(string $method, string $path = '', array $queryParams = [], ?array $jsonBody = null): array
|
||||
function reports_api_request(string $method, string $path = '', array $queryParams = [], ?array $jsonBody = null, int $timeout = 10): array
|
||||
{
|
||||
if (!function_exists('curl_init')) {
|
||||
throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.');
|
||||
|
|
@ -1015,7 +1015,7 @@ function reports_api_request(string $method, string $path = '', array $queryPara
|
|||
$options = [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => $method,
|
||||
CURLOPT_TIMEOUT => 10,
|
||||
CURLOPT_TIMEOUT => $timeout,
|
||||
CURLOPT_SSL_VERIFYPEER => true,
|
||||
];
|
||||
|
||||
|
|
@ -1061,9 +1061,79 @@ function fetch_reports(bool $includeArchived = true): array
|
|||
throw new RuntimeException('Unerwartetes Antwortformat der Reports-API.');
|
||||
}
|
||||
|
||||
reports_nav_store($data['reports']);
|
||||
return $data['reports'];
|
||||
}
|
||||
|
||||
// Offene (nicht archivierte) Reports als Zahl in der Seitenleiste. Wie bei den Raids liegen sie beim Bot -
|
||||
// die Zahl steht in settings.reports_nav_cache und wird hoechstens alle REPORTS_NAV_CACHE_TTL Sekunden neu
|
||||
// geholt; fetch_reports() (die Reports-Seite, auch nach dem Archivieren) frischt sie sofort auf.
|
||||
const REPORTS_NAV_CACHE_TTL = 120;
|
||||
|
||||
/**
|
||||
* Liest (ohne Argument) oder schreibt den Zwischenspeicher - innerhalb eines Aufrufs gilt der zuletzt
|
||||
* geschriebene Stand.
|
||||
*
|
||||
* @param array{fetched_at: int, open: int}|null $value
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
function reports_nav_cache(?array $value = null): ?array
|
||||
{
|
||||
static $current = false;
|
||||
if ($value !== null) {
|
||||
$current = $value;
|
||||
try {
|
||||
setting_set('reports_nav_cache', (string) json_encode($value));
|
||||
} catch (PDOException $e) {
|
||||
// Ohne settings-Tabelle eben ohne Zwischenspeicher.
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
if ($current === false) {
|
||||
$decoded = json_decode(setting_get('reports_nav_cache'), true);
|
||||
$current = is_array($decoded) ? $decoded : null;
|
||||
}
|
||||
return $current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merkt sich, wie viele der Reports offen (nicht archiviert) sind.
|
||||
*
|
||||
* @param array<int, array<string, mixed>> $reports
|
||||
*/
|
||||
function reports_nav_store(array $reports): int
|
||||
{
|
||||
$open = count(array_filter($reports, static fn (array $report): bool => empty($report['archived'])));
|
||||
$cached = reports_nav_cache();
|
||||
if (!is_array($cached) || (int) ($cached['open'] ?? -1) !== $open || time() - (int) ($cached['fetched_at'] ?? 0) >= 60) {
|
||||
reports_nav_cache(['fetched_at' => time(), 'open' => $open]);
|
||||
}
|
||||
return $open;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zahl der offenen Reports fuer die Seitenleiste. Ist der Zwischenspeicher aelter als REPORTS_NAV_CACHE_TTL,
|
||||
* fragt die Funktion den Bot mit kurzer Wartezeit; antwortet er nicht, gilt der letzte Stand.
|
||||
*/
|
||||
function reports_nav_open(): int
|
||||
{
|
||||
$cached = reports_nav_cache();
|
||||
$open = (int) ($cached['open'] ?? 0);
|
||||
if (time() - (int) ($cached['fetched_at'] ?? 0) >= REPORTS_NAV_CACHE_TTL) {
|
||||
// Zeitpunkt vorher merken - sonst fragt bei einem Ausfall des Bots jeder Seitenaufruf erneut
|
||||
reports_nav_cache(['fetched_at' => time(), 'open' => $open]);
|
||||
try {
|
||||
$data = reports_api_request('GET', '', ['guild_id' => reports_guild_id(), 'include_archived' => 'false'], null, 3);
|
||||
if (($data['status'] ?? '') === 'success' && is_array($data['reports'] ?? null)) {
|
||||
$open = reports_nav_store($data['reports']);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
// Bot nicht erreichbar oder nicht eingerichtet - dann eben der letzte Stand
|
||||
}
|
||||
}
|
||||
return $open;
|
||||
}
|
||||
|
||||
/** @throws RuntimeException */
|
||||
function delete_report(int $reportId): void
|
||||
{
|
||||
|
|
|
|||
39
shop.php
39
shop.php
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/shop.php';
|
||||
require_once __DIR__ . '/includes/item_tooltip.php';
|
||||
require_permission('shop.view');
|
||||
|
||||
$canManage = user_has_permission('shop.manage');
|
||||
|
|
@ -22,6 +23,39 @@ foreach ($items as $item) {
|
|||
$categoryCounts[$categoryId] = ($categoryCounts[$categoryId] ?? 0) + 1;
|
||||
}
|
||||
$hasUncategorized = !empty($categoryCounts[0]);
|
||||
// Waffen und Ruestungen aus dem Gear-Katalog (gleicher Name) bekommen in der Info-Blase ihre Werte
|
||||
$gearByName = item_tip_gear(array_merge(array_column($items, 'name'), array_filter(array_column($items, 'warehouse_name'))));
|
||||
|
||||
/**
|
||||
* Info-Blase eines Angebots (includes/item_tooltip.php): Preis, Verfuegbarkeit, schon beantragt und ob die
|
||||
* eigenen Lumipunkte reichen.
|
||||
*/
|
||||
function shop_item_tip(array $item, int $spendable, ?array $gear): string
|
||||
{
|
||||
$price = (int) $item['price'];
|
||||
$available = $item['available'];
|
||||
$lines = [
|
||||
['Preis', $price > 0 ? contribution_coin(14) . ' ' . e(contribution_format($price)) . ' pro Stück' : 'kostenlos'],
|
||||
['Verfügbar', e($available === null ? 'unbegrenzt' : ($available > 0 ? number_format($available, 0, ',', '.') : 'ausverkauft'))],
|
||||
];
|
||||
if ((int) ($item['reserved'] ?? 0) > 0) {
|
||||
$lines[] = ['In offenen Anträgen', e(number_format((int) $item['reserved'], 0, ',', '.'))];
|
||||
}
|
||||
if ($price > 0) {
|
||||
$affordable = intdiv($spendable, $price);
|
||||
$lines[] = $affordable > 0
|
||||
? ['Deine Lumipunkte reichen für', '<span class="is-ok">' . e(number_format($affordable, 0, ',', '.')) . ' Stück</span>']
|
||||
: ['Dir fehlen noch', '<span class="is-short">' . contribution_coin(14) . ' ' . e(contribution_format($price - $spendable)) . '</span>'];
|
||||
}
|
||||
return item_tip_template([
|
||||
'name' => (string) $item['name'],
|
||||
'icon_html' => shop_icon_html($item, 56),
|
||||
'subtitle' => $item['category_name'] !== null ? (string) $item['category_name'] : 'Lumishop',
|
||||
'gear' => $gear,
|
||||
'text' => (string) ($item['description'] ?? ''),
|
||||
'lines' => $lines,
|
||||
]);
|
||||
}
|
||||
$showCategoryList = count($categories) + ($hasUncategorized ? 1 : 0) > 1;
|
||||
|
||||
// Eigene Antraege
|
||||
|
|
@ -107,7 +141,9 @@ include __DIR__ . '/includes/header.php';
|
|||
$max = min(SHOP_MAX_ORDER_QUANTITY, $affordable);
|
||||
$reason = $max < 1 ? 'Nicht genug Lumipunkte' : '';
|
||||
?>
|
||||
<div class="shop-card" data-name="<?= e(mb_strtolower((string) $item['name'])) ?>" data-category="<?= (int) ($item['category_id'] ?? 0) ?>">
|
||||
<div class="shop-card" data-item-tip data-name="<?= e(mb_strtolower((string) $item['name'])) ?>" data-category="<?= (int) ($item['category_id'] ?? 0) ?>">
|
||||
<?= shop_item_tip($item, $spendable, $gearByName[mb_strtolower((string) $item['name'])]
|
||||
?? $gearByName[mb_strtolower((string) ($item['warehouse_name'] ?? ''))] ?? null) ?>
|
||||
<span class="shop-card-image"><?= shop_icon_html($item, 72) ?></span>
|
||||
<span class="shop-card-name"><?= e((string) $item['name']) ?></span>
|
||||
<?php if ($item['category_name'] !== null): ?>
|
||||
|
|
@ -184,4 +220,5 @@ include __DIR__ . '/includes/header.php';
|
|||
</div>
|
||||
|
||||
<script src="<?= e(asset_url('/assets/js/shop.js')) ?>"></script>
|
||||
<script src="<?= e(asset_url('/assets/js/item-tooltip.js')) ?>"></script>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/warehouse.php';
|
||||
require_once __DIR__ . '/includes/item_tooltip.php';
|
||||
require_permission('warehouse.view');
|
||||
|
||||
$canManage = user_has_permission('warehouse.manage');
|
||||
|
|
@ -26,6 +27,22 @@ try {
|
|||
}
|
||||
$stockTotal = array_sum(array_map(static fn (array $row): int => (int) $row['quantity'], $itemStock));
|
||||
|
||||
// Fuer die Info-Blase an jedem Gegenstand: die letzte Bewegung (gleiche Zeit: die zuletzt eingetragene)
|
||||
// und passende Eintraege im Gear-Katalog (Seltenheit, Stufe, Grundwerte).
|
||||
$lastMovements = [];
|
||||
foreach (db()->query(
|
||||
"SELECT m.item_id, m.direction, m.quantity, m.occurred_at, m.counterpart_name,
|
||||
COALESCE(NULLIF(u.display_name, ''), u.username) AS counterpart_user
|
||||
FROM warehouse_movements m
|
||||
JOIN (SELECT item_id, MAX(occurred_at) AS last_at FROM warehouse_movements GROUP BY item_id) l
|
||||
ON l.item_id = m.item_id AND l.last_at = m.occurred_at
|
||||
LEFT JOIN users u ON u.id = m.counterpart_user_id
|
||||
ORDER BY m.id"
|
||||
)->fetchAll() as $movement) {
|
||||
$lastMovements[(int) $movement['item_id']] = $movement;
|
||||
}
|
||||
$gearByName = item_tip_gear(array_column($itemStock, 'name'));
|
||||
|
||||
// Verlauf, optional nur fuer einen Gegenstand (Klick auf den Namen im Bestand).
|
||||
$filterItemId = isset($_GET['item']) ? (int) $_GET['item'] : null;
|
||||
$filterItem = null;
|
||||
|
|
@ -95,6 +112,33 @@ function warehouse_counterpart(array $movement): string
|
|||
return (string) ($movement['counterpart_name'] ?? '');
|
||||
}
|
||||
|
||||
/** Info-Blase eines Gegenstands im Bestand (includes/item_tooltip.php): Bestand, Lumishop-Preis, letzte Bewegung. */
|
||||
function warehouse_item_tip(array $row, ?int $shopPrice, ?array $last, ?array $gear): string
|
||||
{
|
||||
$lines = [['Im Lager', e(number_format((int) $row['quantity'], 0, ',', '.'))]];
|
||||
if ($shopPrice !== null) {
|
||||
$lines[] = ['Im Lumishop', '<img class="contribution-coin" src="/assets/images/lumipunkt.svg" alt="Lumipunkte" width="14" height="14"> '
|
||||
. e(number_format($shopPrice, 0, ',', '.'))];
|
||||
}
|
||||
if ($last) {
|
||||
$in = $last['direction'] === 'in';
|
||||
$lines[] = [$in ? 'Zuletzt eingelagert' : 'Zuletzt entnommen',
|
||||
e(($in ? '+' : '−') . number_format((int) $last['quantity'], 0, ',', '.') . ' · ' . warehouse_format_time($last['occurred_at']))];
|
||||
$who = warehouse_counterpart($last);
|
||||
if ($who !== '') {
|
||||
$lines[] = [$in ? 'von' : 'an', e($who)];
|
||||
}
|
||||
}
|
||||
return item_tip_template([
|
||||
'name' => (string) $row['name'],
|
||||
'icon_html' => warehouse_icon_html($row['icon'] ?? null, (string) $row['name'], 56),
|
||||
'subtitle' => warehouse_category_label((string) $row['category']),
|
||||
'gear' => $gear,
|
||||
'lines' => $lines,
|
||||
'hint' => 'Klicken für den Verlauf',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Auswahl "Konto oder Name" fuer beide Formulare. Die Mitgliederliste ($items) wird nur beim
|
||||
* ersten Aufruf ausgegeben, der zweite nutzt sie mit (null).
|
||||
|
|
@ -176,9 +220,10 @@ include __DIR__ . '/includes/header.php';
|
|||
<?php else: ?>
|
||||
<div class="warehouse-grid" id="warehouse-stock">
|
||||
<?php foreach ($itemStock as $row): ?>
|
||||
<div class="warehouse-card" data-name="<?= e(mb_strtolower((string) $row['name'])) ?>" data-category="<?= e((string) $row['category']) ?>">
|
||||
<a class="warehouse-card-link" href="/warehouse.php?item=<?= (int) $row['id'] ?>#verlauf"
|
||||
title="<?= e((string) $row['name']) ?> - zuletzt bewegt <?= e(warehouse_format_time($row['last_movement'])) ?>. Klicken für den Verlauf.">
|
||||
<div class="warehouse-card" data-item-tip data-name="<?= e(mb_strtolower((string) $row['name'])) ?>" data-category="<?= e((string) $row['category']) ?>">
|
||||
<?= warehouse_item_tip($row, isset($shopPrices[(int) $row['id']]) ? (int) $shopPrices[(int) $row['id']] : null,
|
||||
$lastMovements[(int) $row['id']] ?? null, $gearByName[mb_strtolower((string) $row['name'])] ?? null) ?>
|
||||
<a class="warehouse-card-link" href="/warehouse.php?item=<?= (int) $row['id'] ?>#verlauf">
|
||||
<span class="warehouse-card-image">
|
||||
<?= warehouse_icon_html($row['icon'] ?? null, (string) $row['name'], 72) ?>
|
||||
<span class="warehouse-card-qty"><?= number_format((int) $row['quantity'], 0, ',', '.') ?></span>
|
||||
|
|
@ -186,7 +231,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<span class="warehouse-card-name"><?= e((string) $row['name']) ?></span>
|
||||
<span class="warehouse-card-category"><?= e(warehouse_category_label((string) $row['category'])) ?></span>
|
||||
<?php if (isset($shopPrices[(int) $row['id']])): ?>
|
||||
<span class="warehouse-card-shop" title="Im Lumishop erhältlich">
|
||||
<span class="warehouse-card-shop">
|
||||
Lumishop · <img src="/assets/images/lumipunkt.svg" alt="" width="12" height="12"> <?= e(number_format((int) $shopPrices[(int) $row['id']], 0, ',', '.')) ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
|
@ -421,4 +466,5 @@ include __DIR__ . '/includes/header.php';
|
|||
|
||||
<script src="<?= e(asset_url('/assets/js/item-picker.js')) ?>"></script>
|
||||
<script src="<?= e(asset_url('/assets/js/warehouse.js')) ?>"></script>
|
||||
<script src="<?= e(asset_url('/assets/js/item-tooltip.js')) ?>"></script>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue