Bug reports: members report website bugs on the dashboard, leadership handles them under /bugs.php
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
2d60de3b2b
commit
db4c614dca
11 changed files with 576 additions and 2 deletions
|
|
@ -621,6 +621,15 @@ ALTER TABLE roles ADD COLUMN roster_order INT NULL DEFAULT NULL AFTER is_system;
|
|||
Neue Berechtigung `members.view` muss ebenfalls nachträglich unter Berechtigungsgruppen
|
||||
angelegt/zugewiesen werden.
|
||||
|
||||
## Fehlermeldungen
|
||||
|
||||
Im Dashboard können Mitglieder unter **Fehler gefunden?** Bugs der Website melden (Titel,
|
||||
Bereich, Beschreibung, optional ein Screenshot-Link; Browser/Gerät wird automatisch
|
||||
mitgeschickt). Unter „Meine Meldungen“ sehen sie den Status und die Antwort der Leitung.
|
||||
Bearbeitet werden die Meldungen im Admin-Bereich unter **Fehlermeldungen** (`/bugs.php`,
|
||||
Berechtigung `bugs.manage`), offene Meldungen stehen als Zahl am Menüpunkt. Die Tabelle
|
||||
`bug_reports` legt die Website selbst an.
|
||||
|
||||
## Berechtigungskonzept
|
||||
|
||||
- **Berechtigungen** sind einzelne Schlüssel wie `users.view`, `roles.manage`, `dashboard.view`.
|
||||
|
|
|
|||
|
|
@ -2892,6 +2892,127 @@ input.shop-approve-quantity { width: 72px; padding: 0.3rem 0.45rem; font-size: 0
|
|||
@media (max-width: 700px) {
|
||||
.shop-order-actions { flex-wrap: wrap; justify-content: flex-end; width: 100%; }
|
||||
}
|
||||
/* --- Fehlermeldungen (Dashboard + /bugs.php) --- */
|
||||
|
||||
.bug-report-details > summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.9rem;
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.bug-report-details > summary::-webkit-details-marker { display: none; }
|
||||
|
||||
.bug-report-details > summary > span:nth-child(2) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.bug-report-details > summary .text-muted { font-size: 0.88rem; }
|
||||
|
||||
.bug-panel .icon-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 8px;
|
||||
background: rgba(201, 162, 39, 0.15);
|
||||
color: var(--gold);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.bug-report-details[open] .bug-report-toggle { visibility: hidden; }
|
||||
|
||||
.bug-form {
|
||||
margin-top: 1.25rem;
|
||||
padding-top: 1.25rem;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.bug-form-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.bug-form textarea { resize: vertical; font-family: inherit; }
|
||||
|
||||
.bug-my-list {
|
||||
margin-top: 1.25rem;
|
||||
padding-top: 1.1rem;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.bug-my-list h3 { margin: 0 0 0.75rem; font-size: 1rem; }
|
||||
|
||||
.bug-my-item {
|
||||
padding: 0.75rem 0;
|
||||
border-bottom: 1px dashed var(--border);
|
||||
}
|
||||
|
||||
.bug-my-item:last-child { border-bottom: none; padding-bottom: 0; }
|
||||
|
||||
.bug-my-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.bug-my-meta { font-size: 0.82rem; margin-top: 0.15rem; }
|
||||
|
||||
.bug-admin-note {
|
||||
margin-top: 0.5rem;
|
||||
padding: 0.55rem 0.75rem;
|
||||
border-left: 3px solid var(--gold);
|
||||
border-radius: 4px;
|
||||
background: rgba(201, 162, 39, 0.08);
|
||||
font-size: 0.9rem;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.bug-badge-progress { border-color: #5b9bd5; color: #5b9bd5; }
|
||||
|
||||
.filter-tab-count {
|
||||
margin-left: 0.3rem;
|
||||
padding: 0 0.4rem;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
/* Statusfarbe links an der Karte */
|
||||
.bug-card-open { border-left-color: var(--gold); }
|
||||
.bug-card-open:hover { border-color: var(--gold); }
|
||||
.bug-card-in_progress { border-left-color: #5b9bd5; }
|
||||
.bug-card-in_progress:hover { border-color: #5b9bd5; }
|
||||
.bug-card-done { border-left-color: var(--success); opacity: 0.8; }
|
||||
.bug-card-rejected { border-left-color: var(--danger); opacity: 0.7; }
|
||||
.bug-card-rejected:hover { border-color: var(--danger); }
|
||||
|
||||
.bug-manage-form { margin-top: 0.9rem; }
|
||||
|
||||
.bug-manage-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.bug-manage-row select { width: auto; flex-shrink: 0; }
|
||||
.bug-manage-row input { flex: 1; min-width: 0; }
|
||||
.bug-manage-row button { flex-shrink: 0; }
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.bug-form-row { grid-template-columns: 1fr; }
|
||||
.bug-report-details > summary { flex-wrap: wrap; }
|
||||
.bug-manage-row { flex-wrap: wrap; }
|
||||
.bug-manage-row input { flex-basis: 100%; }
|
||||
}
|
||||
|
||||
/* --- Oeffentliche Startseite --- */
|
||||
|
||||
body.home-page {
|
||||
|
|
|
|||
87
bug_action.php
Normal file
87
bug_action.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/bugs.php';
|
||||
require_permission('dashboard.view');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
redirect('/dashboard.php');
|
||||
}
|
||||
verify_csrf();
|
||||
|
||||
$action = (string) ($_POST['action'] ?? '');
|
||||
$user = current_user();
|
||||
$pdo = db();
|
||||
|
||||
if ($action === 'create') {
|
||||
// Jedes Mitglied mit Dashboard-Zugang darf Fehler melden.
|
||||
$title = trim((string) ($_POST['title'] ?? ''));
|
||||
$area = (string) ($_POST['area'] ?? '');
|
||||
$description = trim((string) ($_POST['description'] ?? ''));
|
||||
$screenshot = trim((string) ($_POST['screenshot_url'] ?? ''));
|
||||
|
||||
$error = null;
|
||||
if ($title === '' || mb_strlen($title) > 150) {
|
||||
$error = 'Bitte einen kurzen Titel angeben (höchstens 150 Zeichen).';
|
||||
} elseif (!array_key_exists($area, BUG_AREAS)) {
|
||||
$error = 'Bitte auswählen, wo der Fehler aufgetreten ist.';
|
||||
} elseif (mb_strlen($description) < 10) {
|
||||
$error = 'Bitte beschreibe kurz, was passiert ist (mindestens 10 Zeichen).';
|
||||
} elseif (mb_strlen($description) > 5000) {
|
||||
$error = 'Die Beschreibung ist zu lang (höchstens 5000 Zeichen).';
|
||||
} elseif ($screenshot !== '' && (!preg_match('#^https?://#i', $screenshot) || mb_strlen($screenshot) > 500)) {
|
||||
$error = 'Der Screenshot-Link muss mit http:// oder https:// beginnen.';
|
||||
} else {
|
||||
$recent = $pdo->prepare('SELECT COUNT(*) FROM bug_reports WHERE user_id = ? AND created_at > NOW() - INTERVAL 1 HOUR');
|
||||
$recent->execute([(int) $user['id']]);
|
||||
if ((int) $recent->fetchColumn() >= BUG_MAX_PER_HOUR) {
|
||||
$error = 'Du hast in der letzten Stunde schon viele Fehler gemeldet - bitte versuche es später noch einmal.';
|
||||
}
|
||||
}
|
||||
|
||||
if ($error !== null) {
|
||||
set_flash('error', $error);
|
||||
// Eingaben fuer das erneute Anzeigen merken, damit nichts verloren geht.
|
||||
$_SESSION['bug_form'] = compact('title', 'area', 'description', 'screenshot');
|
||||
redirect('/dashboard.php#fehler-melden');
|
||||
}
|
||||
|
||||
$pdo->prepare(
|
||||
'INSERT INTO bug_reports (user_id, title, area, description, screenshot_url, user_agent) VALUES (?, ?, ?, ?, ?, ?)'
|
||||
)->execute([
|
||||
(int) $user['id'],
|
||||
$title,
|
||||
$area,
|
||||
$description,
|
||||
$screenshot !== '' ? $screenshot : null,
|
||||
mb_substr((string) ($_SERVER['HTTP_USER_AGENT'] ?? ''), 0, 255) ?: null,
|
||||
]);
|
||||
unset($_SESSION['bug_form']);
|
||||
set_flash('success', 'Danke! Deine Fehlermeldung ist bei der Leitung angekommen.');
|
||||
redirect('/dashboard.php#meine-meldungen');
|
||||
}
|
||||
|
||||
// Alles weitere ist Bearbeitung durch die Leitung.
|
||||
if (!user_has_permission('bugs.manage')) {
|
||||
set_flash('error', 'Du darfst Fehlermeldungen nicht bearbeiten.');
|
||||
redirect('/dashboard.php');
|
||||
}
|
||||
|
||||
$id = (int) ($_POST['id'] ?? 0);
|
||||
$back = '/bugs.php' . (isset($_POST['filter']) ? '?status=' . rawurlencode((string) $_POST['filter']) : '');
|
||||
|
||||
if ($action === 'update') {
|
||||
$status = (string) ($_POST['status'] ?? '');
|
||||
$note = trim((string) ($_POST['admin_note'] ?? ''));
|
||||
if (!array_key_exists($status, BUG_STATUSES)) {
|
||||
set_flash('error', 'Ungültiger Status.');
|
||||
redirect($back);
|
||||
}
|
||||
$stmt = $pdo->prepare('UPDATE bug_reports SET status = ?, admin_note = ?, handled_by = ?, updated_at = NOW() WHERE id = ?');
|
||||
$stmt->execute([$status, $note !== '' ? mb_substr($note, 0, 5000) : null, (int) $user['id'], $id]);
|
||||
set_flash('success', 'Fehlermeldung wurde aktualisiert.');
|
||||
} elseif ($action === 'delete') {
|
||||
$pdo->prepare('DELETE FROM bug_reports WHERE id = ?')->execute([$id]);
|
||||
set_flash('success', 'Fehlermeldung wurde gelöscht.');
|
||||
}
|
||||
|
||||
redirect($back . '#bug-' . $id);
|
||||
148
bugs.php
Normal file
148
bugs.php
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/bugs.php';
|
||||
require_permission('bugs.manage');
|
||||
|
||||
// Standard: alles, was noch zu tun ist (offen + in Arbeit).
|
||||
$filters = [
|
||||
'todo' => ['Zu erledigen', "b.status IN ('open', 'in_progress')"],
|
||||
'open' => ['Offen', "b.status = 'open'"],
|
||||
'in_progress' => ['In Arbeit', "b.status = 'in_progress'"],
|
||||
'done' => ['Behoben', "b.status = 'done'"],
|
||||
'rejected' => ['Abgelehnt', "b.status = 'rejected'"],
|
||||
'all' => ['Alle', '1 = 1'],
|
||||
];
|
||||
$filter = (string) ($_GET['status'] ?? 'todo');
|
||||
if (!array_key_exists($filter, $filters)) {
|
||||
$filter = 'todo';
|
||||
}
|
||||
|
||||
$counts = db()->query('SELECT status, COUNT(*) FROM bug_reports GROUP BY status')->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||
$counts = array_map('intval', $counts);
|
||||
$countFor = static function (string $key) use ($counts): int {
|
||||
return match ($key) {
|
||||
'todo' => ($counts['open'] ?? 0) + ($counts['in_progress'] ?? 0),
|
||||
'all' => array_sum($counts),
|
||||
default => $counts[$key] ?? 0,
|
||||
};
|
||||
};
|
||||
|
||||
$bugs = db()->query(
|
||||
"SELECT b.*, u.username, u.display_name, u.discord_id, u.avatar_filename,
|
||||
h.username AS handler_username, h.display_name AS handler_display_name
|
||||
FROM bug_reports b
|
||||
LEFT JOIN users u ON u.id = b.user_id
|
||||
LEFT JOIN users h ON h.id = b.handled_by
|
||||
WHERE {$filters[$filter][1]}
|
||||
ORDER BY FIELD(b.status, 'open', 'in_progress', 'done', 'rejected'), b.created_at DESC"
|
||||
)->fetchAll();
|
||||
|
||||
$pageTitle = 'Fehlermeldungen';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<div class="panel panel-filter-bar">
|
||||
<div class="raid-header">
|
||||
<h1>Fehlermeldungen</h1>
|
||||
</div>
|
||||
<p class="text-muted">Bugs, die Mitglieder im Dashboard gemeldet haben. Status und Antwort sieht der Melder in seinem Dashboard unter „Meine Meldungen“.</p>
|
||||
<div class="filter-tabs">
|
||||
<?php foreach ($filters as $key => [$label]): ?>
|
||||
<a href="/bugs.php?status=<?= e($key) ?>" class="filter-tab<?= $filter === $key ? ' active' : '' ?>">
|
||||
<?= e($label) ?> <span class="filter-tab-count"><?= $countFor($key) ?></span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (empty($bugs)): ?>
|
||||
<div class="panel">
|
||||
<p class="text-muted">Hier gibt es gerade nichts - keine Fehlermeldungen in dieser Ansicht.</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="report-list">
|
||||
<?php foreach ($bugs as $bug): ?>
|
||||
<?php
|
||||
$reporterName = $bug['user_id'] === null
|
||||
? 'Gelöschtes Konto'
|
||||
: ($bug['display_name'] !== '' ? $bug['display_name'] : $bug['username']);
|
||||
$reporter = $bug['user_id'] === null ? null : [
|
||||
'id' => $bug['user_id'], 'username' => $bug['username'], 'display_name' => $bug['display_name'],
|
||||
'discord_id' => $bug['discord_id'], 'avatar_filename' => $bug['avatar_filename'],
|
||||
];
|
||||
$handlerName = $bug['handler_username'] !== null
|
||||
? ($bug['handler_display_name'] !== '' ? $bug['handler_display_name'] : $bug['handler_username'])
|
||||
: null;
|
||||
?>
|
||||
<div class="report-card bug-card bug-card-<?= e($bug['status']) ?>" id="bug-<?= (int) $bug['id'] ?>">
|
||||
<div class="report-card-main">
|
||||
<div class="report-card-user">
|
||||
<?php if ($reporter): ?>
|
||||
<?= avatar_html($reporter, 40) ?>
|
||||
<?php endif; ?>
|
||||
<div class="report-card-user-info">
|
||||
<strong><?= e($bug['title']) ?></strong>
|
||||
<span class="text-muted">
|
||||
<?= e(bug_area_label($bug['area'])) ?> · von <?= e($reporterName) ?> · <?= e(date('d.m.Y H:i', strtotime($bug['created_at']))) ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="report-card-badges">
|
||||
<?= bug_status_badge($bug['status']) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="report-card-body">
|
||||
<div class="report-reason-text"><?= e($bug['description']) ?></div>
|
||||
<?php if (!empty($bug['screenshot_url'])): ?>
|
||||
<div class="report-evidence">
|
||||
<?= icon('link') ?>
|
||||
<a href="<?= e($bug['screenshot_url']) ?>" target="_blank" rel="noopener noreferrer">Screenshot ansehen</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($bug['user_agent'])): ?>
|
||||
<div class="report-evidence" title="Browser / Gerät des Melders">
|
||||
<?= icon('hash') ?>
|
||||
<span class="report-evidence-text"><?= e($bug['user_agent']) ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<form method="post" action="/bug_action.php" class="bug-manage-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="update">
|
||||
<input type="hidden" name="id" value="<?= (int) $bug['id'] ?>">
|
||||
<input type="hidden" name="filter" value="<?= e($filter) ?>">
|
||||
<div class="bug-manage-row">
|
||||
<select name="status" aria-label="Status">
|
||||
<?php foreach (BUG_STATUSES as $key => [$label]): ?>
|
||||
<option value="<?= e($key) ?>"<?= $bug['status'] === $key ? ' selected' : '' ?>><?= e($label) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<input type="text" name="admin_note" maxlength="5000"
|
||||
placeholder="Antwort an den Melder (optional)"
|
||||
value="<?= e((string) ($bug['admin_note'] ?? '')) ?>">
|
||||
<button type="submit" class="button-small">Speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="report-card-footer">
|
||||
<span class="text-muted">
|
||||
<?php if ($handlerName !== null && $bug['updated_at'] !== null): ?>
|
||||
Zuletzt bearbeitet von <?= e($handlerName) ?> am <?= e(date('d.m.Y H:i', strtotime($bug['updated_at']))) ?>
|
||||
<?php else: ?>
|
||||
Noch nicht bearbeitet
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<form method="post" action="/bug_action.php" class="inline-form" onsubmit="return confirm('Diese Fehlermeldung wirklich endgültig löschen?');">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="id" value="<?= (int) $bug['id'] ?>">
|
||||
<input type="hidden" name="filter" value="<?= e($filter) ?>">
|
||||
<button type="submit" class="icon-button icon-button-danger" title="Löschen"><?= icon('trash') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/raids_api.php';
|
||||
require_once __DIR__ . '/includes/contributions.php';
|
||||
require_once __DIR__ . '/includes/bugs.php';
|
||||
require_permission('dashboard.view');
|
||||
|
||||
$user = current_user();
|
||||
|
|
@ -110,6 +111,21 @@ if ($canViewPremades && $discordId) {
|
|||
}
|
||||
}
|
||||
|
||||
// Eigene Fehlermeldungen (die neuesten zuerst) und ggf. Eingaben nach einem Fehler.
|
||||
$myBugs = [];
|
||||
try {
|
||||
$bugStmt = db()->prepare(
|
||||
'SELECT id, title, area, status, admin_note, created_at, updated_at FROM bug_reports
|
||||
WHERE user_id = ? ORDER BY created_at DESC LIMIT 10'
|
||||
);
|
||||
$bugStmt->execute([(int) $user['id']]);
|
||||
$myBugs = $bugStmt->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
$myBugs = [];
|
||||
}
|
||||
$bugForm = $_SESSION['bug_form'] ?? null;
|
||||
unset($_SESSION['bug_form']);
|
||||
|
||||
$pageTitle = 'Dashboard';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
|
|
@ -296,4 +312,73 @@ include __DIR__ . '/includes/header.php';
|
|||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="panel bug-panel" id="fehler-melden">
|
||||
<details class="bug-report-details"<?= $bugForm !== null ? ' open' : '' ?>>
|
||||
<summary>
|
||||
<span class="icon-badge"><?= icon('bug') ?></span>
|
||||
<span>
|
||||
<strong>Fehler gefunden?</strong>
|
||||
<span class="text-muted">Wenn auf der Website etwas nicht funktioniert, sag uns Bescheid.</span>
|
||||
</span>
|
||||
<span class="button button-secondary button-small bug-report-toggle">Fehler melden</span>
|
||||
</summary>
|
||||
<form method="post" action="/bug_action.php" class="bug-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="create">
|
||||
<div class="bug-form-row">
|
||||
<div>
|
||||
<label for="bug-title">Kurzer Titel</label>
|
||||
<input type="text" id="bug-title" name="title" maxlength="150" required
|
||||
placeholder="z.B. Raid-Anmeldung speichert die Klasse nicht"
|
||||
value="<?= e((string) ($bugForm['title'] ?? '')) ?>">
|
||||
</div>
|
||||
<div>
|
||||
<label for="bug-area">Wo ist es passiert?</label>
|
||||
<select id="bug-area" name="area" required>
|
||||
<option value="">Bitte auswählen …</option>
|
||||
<?php foreach (BUG_AREAS as $key => $label): ?>
|
||||
<option value="<?= e($key) ?>"<?= ($bugForm['area'] ?? '') === $key ? ' selected' : '' ?>><?= e($label) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="bug-description">Was ist passiert?</label>
|
||||
<textarea id="bug-description" name="description" rows="5" maxlength="5000" required
|
||||
placeholder="Was hast du gemacht, was ist passiert und was hättest du stattdessen erwartet?"><?= e((string) ($bugForm['description'] ?? '')) ?></textarea>
|
||||
<div class="field-hint">Je genauer, desto schneller finden wir den Fehler. Browser und Gerät werden automatisch mitgeschickt.</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="bug-screenshot">Link zu einem Screenshot (optional)</label>
|
||||
<input type="text" id="bug-screenshot" name="screenshot_url" maxlength="500"
|
||||
placeholder="https://… (z.B. Bild aus Discord kopieren)"
|
||||
value="<?= e((string) ($bugForm['screenshot'] ?? '')) ?>">
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button type="submit">Fehler absenden</button>
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
|
||||
<?php if (!empty($myBugs)): ?>
|
||||
<div class="bug-my-list" id="meine-meldungen">
|
||||
<h3>Meine Meldungen</h3>
|
||||
<?php foreach ($myBugs as $bug): ?>
|
||||
<div class="bug-my-item">
|
||||
<div class="bug-my-head">
|
||||
<strong><?= e($bug['title']) ?></strong>
|
||||
<?= bug_status_badge($bug['status']) ?>
|
||||
</div>
|
||||
<div class="text-muted bug-my-meta">
|
||||
<?= e(bug_area_label($bug['area'])) ?> · gemeldet am <?= e(date('d.m.Y H:i', strtotime($bug['created_at']))) ?>
|
||||
</div>
|
||||
<?php if (!empty($bug['admin_note'])): ?>
|
||||
<div class="bug-admin-note"><strong>Antwort der Leitung:</strong> <?= e($bug['admin_note']) ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
|
|||
61
includes/bugs.php
Normal file
61
includes/bugs.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Fehlermeldungen: Mitglieder melden im Dashboard Bugs der Website, die Leitung bearbeitet
|
||||
* sie unter /bugs.php (Berechtigung bugs.manage).
|
||||
*/
|
||||
|
||||
// Status => [Anzeigename, Badge-Klasse]
|
||||
const BUG_STATUSES = [
|
||||
'open' => ['Offen', 'badge-pending'],
|
||||
'in_progress' => ['In Arbeit', 'bug-badge-progress'],
|
||||
'done' => ['Behoben', 'badge-active'],
|
||||
'rejected' => ['Abgelehnt', 'badge-disabled'],
|
||||
];
|
||||
|
||||
// Bereiche der Website, in denen der Fehler aufgetreten ist.
|
||||
const BUG_AREAS = [
|
||||
'dashboard' => 'Dashboard',
|
||||
'profile' => 'Mein Profil',
|
||||
'contributions' => 'Lumipunkte',
|
||||
'shop' => 'Lumishop',
|
||||
'members' => 'Mitglieder',
|
||||
'raids' => 'Raids',
|
||||
'premades' => 'Premades',
|
||||
'events' => 'Events',
|
||||
'map' => 'Karte',
|
||||
'warehouse' => 'Lagerhaus',
|
||||
'login' => 'Login / Discord',
|
||||
'home' => 'Startseite',
|
||||
'admin' => 'Admin-Bereich',
|
||||
'other' => 'Sonstiges',
|
||||
];
|
||||
|
||||
// Schutz gegen versehentliches Mehrfach-Absenden bzw. Spam.
|
||||
const BUG_MAX_PER_HOUR = 10;
|
||||
|
||||
function bug_status_label(string $status): string
|
||||
{
|
||||
return BUG_STATUSES[$status][0] ?? $status;
|
||||
}
|
||||
|
||||
function bug_status_badge(string $status): string
|
||||
{
|
||||
return '<span class="badge ' . e(BUG_STATUSES[$status][1] ?? '') . '">' . e(bug_status_label($status)) . '</span>';
|
||||
}
|
||||
|
||||
function bug_area_label(string $area): string
|
||||
{
|
||||
return BUG_AREAS[$area] ?? BUG_AREAS['other'];
|
||||
}
|
||||
|
||||
/** Anzahl offener Meldungen (fuer das Abzeichen in der Seitenleiste). */
|
||||
function bug_open_count(): int
|
||||
{
|
||||
try {
|
||||
return (int) db()->query("SELECT COUNT(*) FROM bug_reports WHERE status = 'open'")->fetchColumn();
|
||||
} catch (PDOException $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -139,6 +139,7 @@ function icon(string $name): string
|
|||
'box' => '<path d="M21 8 12 3 3 8v8l9 5 9-5z"/><path d="M3 8l9 5 9-5"/><line x1="12" y1="13" x2="12" y2="21"/>',
|
||||
'ticket' => '<path d="M3 8a2 2 0 0 0 2-2h14a2 2 0 0 0 2 2v2a2 2 0 0 0 0 4v2a2 2 0 0 0-2 2H5a2 2 0 0 0-2-2v-2a2 2 0 0 0 0-4z"/><line x1="14" y1="7" x2="14" y2="9"/><line x1="14" y1="11" x2="14" y2="13"/><line x1="14" y1="15" x2="14" y2="17"/>',
|
||||
'message' => '<path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/><line x1="8.5" y1="10.5" x2="15.5" y2="10.5"/><line x1="8.5" y1="14" x2="13" y2="14"/>',
|
||||
'bug' => '<rect x="8" y="6" width="8" height="14" rx="4"/><path d="M19 7l-3 2"/><path d="M5 7l3 2"/><path d="M19 19l-3-2"/><path d="M5 19l3-2"/><path d="M20 13h-4"/><path d="M4 13h4"/><path d="M10 4l1 2"/><path d="M14 4l-1 2"/>',
|
||||
'shield-check' => '<path d="M12 21c4.5-1.8 7-5.2 7-9.5V6l-7-3-7 3v5.5c0 4.3 2.5 7.7 7 9.5z"/><polyline points="9 12 11.2 14.2 15.5 9.8"/>',
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,14 @@ if ($canViewContributions && $shellUser) {
|
|||
}
|
||||
$canViewMembers = $currentUser && user_has_permission('members.view');
|
||||
$canViewReports = $currentUser && user_has_permission('reports.view');
|
||||
$showAdminMenu = $canViewUsers || $canManageRoles || $canViewReports;
|
||||
$canManageBugs = $currentUser && user_has_permission('bugs.manage');
|
||||
// Offene Fehlermeldungen als Zahl am Menuepunkt.
|
||||
$bugOpenCount = 0;
|
||||
if ($canManageBugs) {
|
||||
require_once __DIR__ . '/bugs.php';
|
||||
$bugOpenCount = bug_open_count();
|
||||
}
|
||||
$showAdminMenu = $canViewUsers || $canManageRoles || $canViewReports || $canManageBugs;
|
||||
// Neue Discord-Anmeldungen, die auf Freischaltung warten - als Zahl am Menuepunkt.
|
||||
$pendingUserCount = $canViewUsers
|
||||
? (int) db()->query("SELECT COUNT(*) FROM users WHERE status = 'pending'")->fetchColumn()
|
||||
|
|
@ -58,6 +65,7 @@ $isContributionsActive = in_array($currentScript, ['contributions.php', 'contrib
|
|||
$isShopActive = in_array($currentScript, ['shop.php', 'shop_orders.php', 'shop_manage.php'], true);
|
||||
$isMembersActive = $currentScript === 'members.php';
|
||||
$isReportsActive = $currentScript === 'reports.php';
|
||||
$isBugsActive = $currentScript === 'bugs.php';
|
||||
$isUsersActive = in_array($currentScript, ['users.php', 'user_form.php', 'user_delete.php', 'user_approve.php'], true);
|
||||
$isRolesActive = in_array($currentScript, ['roles.php', 'role_form.php', 'role_delete.php'], true);
|
||||
|
||||
|
|
@ -83,6 +91,7 @@ $pageBackgrounds = [
|
|||
'role_form.php' => 'bg-roles',
|
||||
'role_delete.php' => 'bg-roles',
|
||||
'reports.php' => 'bg-reports',
|
||||
'bugs.php' => 'bg-reports',
|
||||
];
|
||||
$pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
|
||||
|
||||
|
|
@ -218,6 +227,14 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
|||
<?= icon('flag') ?><span class="label">Reports</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canManageBugs): ?>
|
||||
<a href="/bugs.php" class="sidebar-link<?= $isBugsActive ? ' active' : '' ?>" title="Fehlermeldungen">
|
||||
<?= icon('bug') ?><span class="label">Fehlermeldungen</span>
|
||||
<?php if ($bugOpenCount > 0): ?>
|
||||
<span class="sidebar-badge" title="Offene Fehlermeldungen"><?= $bugOpenCount ?></span>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
<?php if ($sidebarPoints !== null): ?>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ const CORE_PERMISSIONS = [
|
|||
['key' => 'members.view', 'description' => 'Mitgliederliste einsehen'],
|
||||
['key' => 'reports.view', 'description' => 'Eingegangene Reports einsehen'],
|
||||
['key' => 'reports.manage', 'description' => 'Reports löschen/archivieren und die Punkte-Gewichtung verwalten'],
|
||||
['key' => 'bugs.manage', 'description' => 'Fehlermeldungen der Mitglieder einsehen, beantworten und bearbeiten'],
|
||||
];
|
||||
|
||||
function user_has_permission(string $key): bool
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
||||
const SCHEMA_VERSION = 11;
|
||||
const SCHEMA_VERSION = 12;
|
||||
|
||||
/**
|
||||
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
||||
|
|
@ -189,6 +189,30 @@ CREATE TABLE IF NOT EXISTS settings (
|
|||
`key` VARCHAR(100) NOT NULL PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
'bug_reports' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS bug_reports (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT UNSIGNED NULL,
|
||||
title VARCHAR(150) NOT NULL,
|
||||
-- Schluessel aus BUG_AREAS in includes/bugs.php (raids, shop, ...)
|
||||
area VARCHAR(30) NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
-- optional: Link zu einem Screenshot o.ae.
|
||||
screenshot_url VARCHAR(500) NULL,
|
||||
-- Browser/Geraet des Melders, hilft beim Nachstellen
|
||||
user_agent VARCHAR(255) NULL,
|
||||
status ENUM('open', 'in_progress', 'done', 'rejected') NOT NULL DEFAULT 'open',
|
||||
-- Antwort der Leitung, sieht der Melder im Dashboard
|
||||
admin_note TEXT NULL,
|
||||
handled_by INT UNSIGNED NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (handled_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_bug_reports_status (status),
|
||||
INDEX idx_bug_reports_user (user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,26 @@ CREATE TABLE IF NOT EXISTS settings (
|
|||
value TEXT NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Fehlermeldungen der Mitglieder (Dashboard), bearbeitet unter /bugs.php
|
||||
CREATE TABLE IF NOT EXISTS bug_reports (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT UNSIGNED NULL,
|
||||
title VARCHAR(150) NOT NULL,
|
||||
area VARCHAR(30) NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
screenshot_url VARCHAR(500) NULL,
|
||||
user_agent VARCHAR(255) NULL,
|
||||
status ENUM('open', 'in_progress', 'done', 'rejected') NOT NULL DEFAULT 'open',
|
||||
admin_note TEXT NULL,
|
||||
handled_by INT UNSIGNED NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (handled_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_bug_reports_status (status),
|
||||
INDEX idx_bug_reports_user (user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_roles (
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
role_id INT UNSIGNED NOT NULL,
|
||||
|
|
|
|||
Loading…
Reference in a new issue