New "Karte" tab: a tiled zoom/pan map of the game world with a category sidebar (groups, per-category marker counts, show all / hide all, search) and marker popups, plus tactic layers drawn on top of it. Markers are placed by clicking the map (map.manage) and live in freely editable two-level categories, each with its own emoji and colour. A tactic (map.tactics) is a separate drawing layer that can be toggled on and off: rally points, dashed routes, areas and text notes in any colour, finished by double click, an explicit button or Enter, removed by clicking them. Coordinates are stored as a fraction of the map's width/height rather than in pixels, so re-tiling the map at a different resolution never moves anything. The map data lives entirely in the website database - the Discord bot is not involved. tools/make_map_tiles.php slices a high-resolution image into the zoom pyramid locally; the resulting folder is uploaded by FTP and picked up automatically, one region per folder. Leaflet 1.9.4 is vendored under assets/vendor/ so there is still no CDN and no build step. New permissions map.view / map.manage / map.tactics and four new tables - existing installs have to add both once (see README). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
61 lines
2.6 KiB
PHP
61 lines
2.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
// Feste Kern-Berechtigungen, die das System versteht/pflegt.
|
|
// Admins können in der Oberfläche zusätzliche eigene Berechtigungen anlegen,
|
|
// die dann z.B. für spätere Features verwendet werden können.
|
|
const CORE_PERMISSIONS = [
|
|
['key' => 'dashboard.view', 'description' => 'Zugriff auf das Mitglieder-Dashboard'],
|
|
['key' => 'admin.access', 'description' => 'Zugriff auf den Admin-Bereich'],
|
|
['key' => 'users.view', 'description' => 'Benutzerliste einsehen'],
|
|
['key' => 'users.create', 'description' => 'Neue Benutzer anlegen'],
|
|
['key' => 'users.edit', 'description' => 'Benutzer bearbeiten'],
|
|
['key' => 'users.delete', 'description' => 'Benutzer löschen'],
|
|
['key' => 'roles.manage', 'description' => 'Berechtigungsgruppen verwalten'],
|
|
['key' => 'raids.view', 'description' => 'Raids einsehen'],
|
|
['key' => 'raids.manage', 'description' => 'Raids archivieren/wiederherstellen'],
|
|
['key' => 'premades.view', 'description' => 'Premade-Gruppen einsehen'],
|
|
['key' => 'premades.manage', 'description' => 'Alle Premade-Gruppen verwalten (nicht nur die eigene)'],
|
|
['key' => 'events.view', 'description' => 'Geplante Event-Erinnerungen einsehen'],
|
|
['key' => 'events.manage', 'description' => 'Event-Erinnerungen planen, bearbeiten und löschen'],
|
|
['key' => 'map.view', 'description' => 'Taktikkarte ansehen'],
|
|
['key' => 'map.manage', 'description' => 'Marker und Kategorien der Karte verwalten'],
|
|
['key' => 'map.tactics', 'description' => 'Taktiken auf der Karte anlegen und bearbeiten'],
|
|
['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'],
|
|
];
|
|
|
|
function user_has_permission(string $key): bool
|
|
{
|
|
$user = current_user();
|
|
if (!$user) {
|
|
return false;
|
|
}
|
|
|
|
static $cache = [];
|
|
if (array_key_exists($key, $cache)) {
|
|
return $cache[$key];
|
|
}
|
|
|
|
$stmt = db()->prepare(
|
|
'SELECT COUNT(*) FROM user_roles ur
|
|
JOIN role_permissions rp ON rp.role_id = ur.role_id
|
|
JOIN permissions p ON p.id = rp.permission_id
|
|
WHERE ur.user_id = ? AND p.key = ?'
|
|
);
|
|
$stmt->execute([$user['id'], $key]);
|
|
|
|
$cache[$key] = ((int) $stmt->fetchColumn()) > 0;
|
|
return $cache[$key];
|
|
}
|
|
|
|
function require_permission(string $key): void
|
|
{
|
|
require_login();
|
|
if (!user_has_permission($key)) {
|
|
http_response_code(403);
|
|
include __DIR__ . '/forbidden.php';
|
|
exit;
|
|
}
|
|
}
|