Block moving members into locked groups in the raid editor
Drag&drop moves and the underlying raid_move_action.php had no idea about locked_groups, so an admin could still drag a member into a group that was explicitly locked. Locked drop zones are now flagged in the markup, the frontend refuses the drag/drop, and the endpoint rejects the move server-side as well. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
73b670a305
commit
5f64c6fe75
4 changed files with 37 additions and 6 deletions
|
|
@ -153,6 +153,25 @@ a:hover { color: var(--gold-hover); text-decoration: underline; }
|
||||||
|
|
||||||
.sidebar-user strong { color: var(--text); }
|
.sidebar-user strong { color: var(--text); }
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
display: inline-block;
|
||||||
|
border-radius: 50%;
|
||||||
|
object-fit: cover;
|
||||||
|
flex-shrink: 0;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-placeholder {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 700;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero .avatar { margin-bottom: 1rem; }
|
||||||
|
|
||||||
.app-content {
|
.app-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|
|
||||||
|
|
@ -219,9 +219,11 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelectorAll('.raid-drop-zone').forEach(function (zone) {
|
document.querySelectorAll('.raid-drop-zone').forEach(function (zone) {
|
||||||
|
var isLocked = zone.getAttribute('data-locked') === '1';
|
||||||
|
|
||||||
zone.addEventListener('dragover', function (e) {
|
zone.addEventListener('dragover', function (e) {
|
||||||
var card = zone.closest('.raid-card');
|
var card = zone.closest('.raid-card');
|
||||||
if (!card || !card.classList.contains('editing')) return;
|
if (!card || !card.classList.contains('editing') || isLocked) return;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
zone.classList.add('drag-over');
|
zone.classList.add('drag-over');
|
||||||
});
|
});
|
||||||
|
|
@ -232,7 +234,7 @@
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
zone.classList.remove('drag-over');
|
zone.classList.remove('drag-over');
|
||||||
var card = zone.closest('.raid-card');
|
var card = zone.closest('.raid-card');
|
||||||
if (!card || !card.classList.contains('editing')) return;
|
if (!card || !card.classList.contains('editing') || isLocked) return;
|
||||||
|
|
||||||
var raw = e.dataTransfer.getData('text/plain');
|
var raw = e.dataTransfer.getData('text/plain');
|
||||||
if (!raw) return;
|
if (!raw) return;
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,18 @@ if ($raidId <= 0 || $discordId <= 0 || !is_numeric($group) || (int) $group < 0)
|
||||||
json_response(false, 'Ungültige Anfrage.');
|
json_response(false, 'Ungültige Anfrage.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$group = (int) $group;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
move_signup($raidId, $discordId, (int) $group);
|
if ($group > 0) {
|
||||||
|
$raid = fetch_raid_by_id($raidId);
|
||||||
|
$lockedGroups = is_array($raid['locked_groups'] ?? null) ? array_map('intval', $raid['locked_groups']) : [];
|
||||||
|
if (in_array($group, $lockedGroups, true)) {
|
||||||
|
json_response(false, 'Diese Gruppe ist gesperrt.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
move_signup($raidId, $discordId, $group);
|
||||||
json_response(true, 'Spieler wurde verschoben.');
|
json_response(true, 'Spieler wurde verschoben.');
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
json_response(false, 'Verschieben fehlgeschlagen: ' . $e->getMessage());
|
json_response(false, 'Verschieben fehlgeschlagen: ' . $e->getMessage());
|
||||||
|
|
|
||||||
|
|
@ -263,9 +263,9 @@ include __DIR__ . '/includes/header.php';
|
||||||
<?php if (!empty($groupNames)): ?>
|
<?php if (!empty($groupNames)): ?>
|
||||||
<div class="raid-groups">
|
<div class="raid-groups">
|
||||||
<?php foreach ($groupNames as $index => $groupName): ?>
|
<?php foreach ($groupNames as $index => $groupName): ?>
|
||||||
<?php $members = $signupsByGroup[$index + 1] ?? []; ?>
|
<?php $members = $signupsByGroup[$index + 1] ?? []; $isLockedGroup = in_array($index + 1, $lockedGroups, true); ?>
|
||||||
<div class="raid-group raid-drop-zone" data-group="<?= $index + 1 ?>">
|
<div class="raid-group raid-drop-zone<?= $isLockedGroup ? ' raid-group-locked' : '' ?>" data-group="<?= $index + 1 ?>" data-locked="<?= $isLockedGroup ? '1' : '0' ?>">
|
||||||
<h3><?= e($groupName) ?> (<?= count($members) ?>)<?= in_array($index + 1, $lockedGroups, true) ? ' ' . icon('lock') : '' ?></h3>
|
<h3><?= e($groupName) ?> (<?= count($members) ?>)<?= $isLockedGroup ? ' ' . icon('lock') : '' ?></h3>
|
||||||
<?php if (empty($members)): ?>
|
<?php if (empty($members)): ?>
|
||||||
<p class="text-muted raid-empty-hint">Keine Anmeldungen</p>
|
<p class="text-muted raid-empty-hint">Keine Anmeldungen</p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue