- New permission raids.create (granted on update to every group that has raids.view): whoever creates a raid on the website becomes its raid lead (raid_settings.lead_user_id, schema v49), shown with a crown on the raid card and in the signup list. - The raid lead manages their own raid: edit, move players, invite premades, fill in the attendance list and archive it. Restoring, deleting for good and the Lumipunkte stay with the leadership (raids.manage, raids.points). Checked on the server via raid_can_manage() in every raid action. - Raids created by a member without raids.points bring no automatic points (0/0) until the leadership sets them when editing; raids of the leadership keep the fixed +1. - The attendance reminder of the bot (bot_api.php) goes to the raid lead, even if not signed up; raids without a lead (created in Discord) remind the signed-up raids.manage members as before. - Core permission descriptions are cut to the 255 characters of the column when synced - a longer one made the schema sync throw on every request (found while testing this change). - Privacy policy (raid lead is visible to all), data export, patch notes, README and the tour updated; raid_created_at() folded into raid_posted_at(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
188 lines
8.8 KiB
PHP
188 lines
8.8 KiB
PHP
<?php
|
||
require_once __DIR__ . '/includes/bootstrap.php';
|
||
require_once __DIR__ . '/includes/raid_attendance.php';
|
||
require_login();
|
||
|
||
$raidId = (int) ($_GET['raid'] ?? 0);
|
||
// Die Leitung fuer jeden Raid, der Raid-Lead fuer seinen eigenen (Link auch in der Erinnerung per Discord-PN)
|
||
if (!raid_can_manage($raidId)) {
|
||
show_not_found();
|
||
}
|
||
$raid = null;
|
||
$apiError = null;
|
||
try {
|
||
$raid = $raidId > 0 ? fetch_raid_by_id($raidId) : null;
|
||
} catch (Throwable $e) {
|
||
$apiError = $e->getMessage();
|
||
}
|
||
|
||
if (!$raid && !$apiError) {
|
||
set_flash('error', 'Dieser Raid wurde nicht gefunden.');
|
||
redirect('/raids.php');
|
||
}
|
||
|
||
raid_settings_ensure_defaults([$raidId]);
|
||
$settings = raid_settings_get($raidId);
|
||
$attendance = raid_attendance_get($raidId);
|
||
$userIds = raid_user_ids_by_discord();
|
||
|
||
// Zeilen der Liste: alle Anmeldungen plus bereits erfasste Personen, die (inzwischen) nicht
|
||
// mehr angemeldet sind oder von Hand hinzugefuegt wurden.
|
||
$rows = [];
|
||
if ($raid) {
|
||
$split = raid_signups_split($raid);
|
||
$groupNames = array_values(array_filter(array_map('trim', explode(',', (string) ($raid['groups'] ?? '')))));
|
||
foreach (['groups' => null, 'bench' => 'Ersatzbank', 'declined' => 'Abgemeldet'] as $key => $label) {
|
||
foreach ($split[$key] as $signup) {
|
||
$discordId = (string) ($signup['user_id'] ?? '');
|
||
if ($discordId === '') {
|
||
continue;
|
||
}
|
||
$group = (int) ($signup['group'] ?? 0);
|
||
$rows[$discordId] = [
|
||
'discord_id' => $discordId,
|
||
'name' => (string) ($signup['name'] ?? '?'),
|
||
'class' => (string) ($signup['class'] ?? ''),
|
||
'where' => $label ?? ($groupNames[$group - 1] ?? 'Gruppe ' . $group),
|
||
'section' => $key,
|
||
];
|
||
}
|
||
}
|
||
}
|
||
foreach ($attendance as $discordId => $entry) {
|
||
if (!isset($rows[$discordId])) {
|
||
$rows[$discordId] = [
|
||
'discord_id' => $discordId,
|
||
'name' => $entry['name'] !== '' ? $entry['name'] : $discordId,
|
||
'class' => '',
|
||
'where' => 'Nachgetragen',
|
||
'section' => 'extra',
|
||
];
|
||
}
|
||
}
|
||
|
||
// Zum Nachtragen: Website-Konten mit Discord-Verknuepfung, die noch nicht in der Liste stehen.
|
||
$addable = array_values(array_filter(member_picker_rows(), static fn (array $u): bool =>
|
||
!empty($u['discord_id']) && !isset($rows[(string) $u['discord_id']])));
|
||
|
||
$title = $raid ? (string) ($raid['title'] ?? 'Raid') : 'Raid';
|
||
$timestamp = $raid ? (int) ($raid['timestamp'] ?? 0) : 0;
|
||
$isArchived = $raid && (!empty($raid['archived']) || !empty($raid['archived_at']));
|
||
|
||
$pageTitle = 'Anwesenheit';
|
||
include __DIR__ . '/includes/header.php';
|
||
?>
|
||
<div class="panel">
|
||
<div class="attendance-head">
|
||
<div>
|
||
<h1>Anwesenheit: <?= e($title) ?></h1>
|
||
<p class="text-muted">
|
||
<?= $timestamp ? e(date('d.m.Y H:i', $timestamp)) . ' Uhr' : '' ?>
|
||
<?= $isArchived ? ' · archiviert' : '' ?>
|
||
<?= $settings['lead_name'] !== null ? ' · Raid-Lead: ' . e((string) $settings['lead_name']) : '' ?>
|
||
</p>
|
||
</div>
|
||
<a href="/raids.php">Zurück zu den Raids</a>
|
||
</div>
|
||
|
||
<?php if ($apiError): ?>
|
||
<div class="flash flash-error">Die Raid-Daten konnten nicht geladen werden: <?= e($apiError) ?></div>
|
||
<?php endif; ?>
|
||
|
||
<div class="attendance-status">
|
||
<?php if ($settings['attendance_checked_at']): ?>
|
||
<span class="badge badge-active">Kontrolliert</span>
|
||
am <?= e(date('d.m.Y H:i', strtotime((string) $settings['attendance_checked_at']))) ?>
|
||
<?= $settings['checked_by'] ? 'von ' . e((string) $settings['checked_by']) : '' ?>
|
||
<?php else: ?>
|
||
<span class="badge badge-pending">Noch nicht kontrolliert</span>
|
||
<?php endif; ?>
|
||
<span class="text-muted attendance-auto">
|
||
<?= contribution_coin(16) ?>
|
||
<?php if ($settings['points_present'] > 0 || $settings['points_absent'] > 0): ?>
|
||
Beim Archivieren: +<?= (int) $settings['points_present'] ?> für Anwesende<?= $settings['points_absent'] > 0 ? ', −' . (int) $settings['points_absent'] . ' für Abwesende' : '' ?>.
|
||
<?php if ($settings['auto_result']): ?><br><?= e((string) $settings['auto_result']) ?><?php endif; ?>
|
||
<?php else: ?>
|
||
Keine automatischen Lumipunkte für diesen Raid eingestellt.
|
||
<?php endif; ?>
|
||
</span>
|
||
</div>
|
||
|
||
<form method="post" action="/raid_attendance_action.php" id="attendance-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="raid_id" value="<?= $raidId ?>">
|
||
|
||
<div class="attendance-bulk">
|
||
<span class="text-muted">Schnell setzen:</span>
|
||
<button type="button" class="button-secondary button-small" data-bulk="groups:present">Alle in Gruppen anwesend</button>
|
||
<button type="button" class="button-secondary button-small" data-bulk="bench:absent">Ersatzbank abwesend</button>
|
||
<button type="button" class="button-secondary button-small" data-bulk="all:">Alles zurücksetzen</button>
|
||
</div>
|
||
|
||
<?php if (empty($rows)): ?>
|
||
<p class="text-muted">Für diesen Raid gibt es keine Anmeldungen.</p>
|
||
<?php else: ?>
|
||
<div class="attendance-list">
|
||
<?php foreach ($rows as $row): ?>
|
||
<?php
|
||
$current = $attendance[$row['discord_id']]['status'] ?? '';
|
||
$current = isset(RAID_ATTENDANCE_STATUSES[$current]) ? $current : '';
|
||
$hasAccount = isset($userIds[$row['discord_id']]);
|
||
?>
|
||
<div class="attendance-row" data-section="<?= e($row['section']) ?>">
|
||
<input type="hidden" name="names[<?= e($row['discord_id']) ?>]" value="<?= e($row['name']) ?>">
|
||
<div class="attendance-person">
|
||
<strong><?= e($row['name']) ?></strong>
|
||
<span class="text-muted"><?= e($row['where']) ?><?= $row['class'] !== '' && $row['class'] !== 'Abgemeldet' ? ' · ' . e($row['class']) : '' ?></span>
|
||
<?php if (!$hasAccount): ?>
|
||
<span class="badge" title="Ohne Website-Konto mit Discord-Verknüpfung gibt es keine Lumipunkte">kein Website-Konto</span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<div class="attendance-choice" role="radiogroup" aria-label="Anwesenheit von <?= e($row['name']) ?>">
|
||
<?php foreach (RAID_ATTENDANCE_STATUSES as $value => $label): ?>
|
||
<label class="attendance-option attendance-<?= e($value) ?>">
|
||
<input type="radio" name="status[<?= e($row['discord_id']) ?>]" value="<?= e($value) ?>" <?= $current === $value ? 'checked' : '' ?>>
|
||
<?= e($label) ?>
|
||
</label>
|
||
<?php endforeach; ?>
|
||
<label class="attendance-option attendance-none" title="Noch nicht erfasst">
|
||
<input type="radio" name="status[<?= e($row['discord_id']) ?>]" value="" <?= $current === '' ? 'checked' : '' ?>>
|
||
–
|
||
</label>
|
||
</div>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php if (!empty($addable)): ?>
|
||
<div class="attendance-add">
|
||
<label for="attendance-add">Nicht angemeldet, aber dabei gewesen?</label>
|
||
<?= member_picker('add_discord_id', 'attendance-members', array_map(static fn ($u) => member_picker_item($u, 'discord_id'), $addable), [
|
||
'input_id' => 'attendance-add',
|
||
'placeholder' => 'Mitglied nachtragen (als anwesend) …',
|
||
]) ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<div class="actions">
|
||
<button type="submit" name="mark_checked" value="1">Speichern & als kontrolliert markieren</button>
|
||
<button type="submit" class="button-secondary">Nur speichern</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
|
||
<script>
|
||
document.querySelectorAll('[data-bulk]').forEach(function (button) {
|
||
button.addEventListener('click', function () {
|
||
var parts = button.getAttribute('data-bulk').split(':');
|
||
document.querySelectorAll('.attendance-row').forEach(function (row) {
|
||
if (parts[0] !== 'all' && row.getAttribute('data-section') !== parts[0]) return;
|
||
var radio = row.querySelector('input[type="radio"][value="' + parts[1] + '"]');
|
||
if (radio) radio.checked = true;
|
||
});
|
||
});
|
||
});
|
||
</script>
|
||
<script src="<?= e(asset_url('/assets/js/item-picker.js')) ?>"></script>
|
||
<?php include __DIR__ . '/includes/footer.php'; ?>
|