Bilder erscheinen erst zur Startzeit; Einsendungen sieht nur die Leitung (hunt.manage) mit sekundengenauer Uhrzeit des Hochladens, sie erkennt an oder lehnt ab. Punkte automatisch (je Ort 5/4/3/3/3, Bonusbild 5 innerhalb von 24 Stunden), Rangliste laesst sich veroeffentlichen. Bilder nur ueber hunt_image.php, Datenauskunft, Kontoloeschung und Datenschutzerklaerung ergaenzt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
407 lines
26 KiB
PHP
407 lines
26 KiB
PHP
<?php
|
||
/**
|
||
* Schnitzeljagd (includes/hunt.php): Uebersicht der Jagden und eine einzelne Jagd. Mitglieder sehen ab dem Start die
|
||
* gesuchten Orte und senden je Ort zwei Screenshots ein; die Leitung (hunt.manage) verwaltet die Jagd, sieht alle
|
||
* Einsendungen mit sekundengenauer Uhrzeit und die Rangliste.
|
||
*/
|
||
require_once __DIR__ . '/includes/bootstrap.php';
|
||
require_once __DIR__ . '/includes/hunt.php';
|
||
require_login();
|
||
$canManage = hunt_can_manage();
|
||
if (!$canManage && !hunt_can_take_part()) {
|
||
show_not_found();
|
||
}
|
||
$me = current_user();
|
||
$form = $_SESSION['hunt_form'] ?? [];
|
||
unset($_SESSION['hunt_form']);
|
||
$toInput = static fn (?string $datetime): string => $datetime ? date('Y-m-d\TH:i', strtotime($datetime)) : '';
|
||
|
||
/** Status einer Jagd als Abzeichen. */
|
||
$huntBadge = static function (array $hunt): string {
|
||
if (empty($hunt['is_published'])) {
|
||
return '<span class="badge badge-disabled">Entwurf</span>';
|
||
}
|
||
if (!hunt_started($hunt)) {
|
||
return '<span class="badge badge-pending">Startet ' . e(hunt_date((string) $hunt['starts_at'])) . '</span>';
|
||
}
|
||
return hunt_closed($hunt) ? '<span class="badge">Beendet</span>' : '<span class="badge badge-active">Läuft</span>';
|
||
};
|
||
|
||
/** Formular zum Anlegen bzw. Bearbeiten einer Jagd. */
|
||
$huntForm = static function (?array $hunt) use ($form, $toInput): string {
|
||
$value = static fn (string $key, string $fallback = ''): string => e((string) ($form[$key] ?? $fallback));
|
||
$start = $hunt ? $toInput($hunt['starts_at']) : date('Y-m-d', strtotime('+1 day')) . 'T20:00';
|
||
$html = '<form method="post" action="/hunt_action.php" class="hunt-form">' . csrf_field()
|
||
. '<input type="hidden" name="action" value="save_hunt">'
|
||
. '<input type="hidden" name="hunt_id" value="' . (int) ($hunt['id'] ?? 0) . '">'
|
||
. '<div class="hunt-form-grid">'
|
||
. '<label class="hunt-form-wide">Titel<input type="text" name="title" maxlength="120" required value="' . $value('title', (string) ($hunt['title'] ?? 'Schnitzeljagd')) . '"></label>'
|
||
. '<label>Start <span class="text-muted">(ab dann sehen alle die Bilder)</span><input type="datetime-local" name="starts_at" required value="' . $value('starts_at', $start) . '"></label>'
|
||
. '<label>Einsendeschluss <span class="text-muted">(optional)</span><input type="datetime-local" name="ends_at" value="' . $value('ends_at', $toInput($hunt['ends_at'] ?? null)) . '"></label>'
|
||
. '<label class="hunt-form-wide">Ablauf und Regeln <span class="text-muted">(optional, sehen alle Mitglieder)</span>'
|
||
. '<textarea name="description" rows="7" maxlength="5000" placeholder="z.B. Teilnahme nur mit einem Charakter, Uhrzeit muss auf dem Bild zu sehen sein …">' . $value('description', (string) ($hunt['description'] ?? '')) . '</textarea></label>'
|
||
. '</div>'
|
||
. '<label class="checkbox-label"><input type="checkbox" name="is_published" value="1"' . (!$hunt || !empty($hunt['is_published']) ? ' checked' : '') . '>'
|
||
. ' Für Mitglieder sichtbar – die Bilder erscheinen trotzdem erst zum Start</label>'
|
||
. '<div class="actions"><button type="submit">' . ($hunt ? 'Speichern' : 'Schnitzeljagd anlegen') . '</button></div>'
|
||
. '</form>';
|
||
return $html;
|
||
};
|
||
|
||
$hunt = isset($_GET['id']) ? hunt_find((int) $_GET['id']) : null;
|
||
if (isset($_GET['id']) && !$hunt) {
|
||
show_not_found();
|
||
}
|
||
|
||
// ---------------------------------------------------------------- Uebersicht
|
||
if (!$hunt) {
|
||
$hunts = db()->query(
|
||
'SELECT h.*, (SELECT COUNT(*) FROM hunt_spots sp WHERE sp.hunt_id = h.id) AS spot_count
|
||
FROM hunts h' . ($canManage ? '' : ' WHERE h.is_published = 1') . ' ORDER BY h.starts_at DESC'
|
||
)->fetchAll();
|
||
// Mitglieder landen direkt in der Jagd, wenn es nur eine gibt
|
||
if (!$canManage && count($hunts) === 1) {
|
||
redirect('/hunt.php?id=' . (int) $hunts[0]['id']);
|
||
}
|
||
$pageTitle = 'Schnitzeljagd';
|
||
include __DIR__ . '/includes/header.php';
|
||
?>
|
||
<div class="panel">
|
||
<div class="raid-header">
|
||
<h1>Schnitzeljagd</h1>
|
||
</div>
|
||
<p class="text-muted">
|
||
Zum Start erscheinen hier die Bilder der gesuchten Orte. Finde sie im Spiel und lade je Ort einen Screenshot
|
||
vom Ort und einen von deiner Karte mit deinem Standort hoch. Deine Bilder sieht nur die Leitung – mit der genauen Uhrzeit.
|
||
</p>
|
||
</div>
|
||
<?php if ($canManage): ?>
|
||
<details class="panel hunt-collapse"<?= $form ? ' open' : '' ?>>
|
||
<summary><h2><?= icon('map-pin') ?> Neue Schnitzeljagd</h2></summary>
|
||
<?= $huntForm(null) ?>
|
||
</details>
|
||
<?php endif; ?>
|
||
<?php if (!$hunts): ?>
|
||
<div class="panel"><p class="text-muted">Gerade ist keine Schnitzeljagd geplant.</p></div>
|
||
<?php else: ?>
|
||
<div class="hunt-list">
|
||
<?php foreach ($hunts as $item): ?>
|
||
<a class="panel hunt-list-item" href="/hunt.php?id=<?= (int) $item['id'] ?>">
|
||
<strong><?= e($item['title']) ?></strong>
|
||
<span><?= $huntBadge($item) ?></span>
|
||
<span class="text-muted">
|
||
<?= e(hunt_date((string) $item['starts_at'])) ?>
|
||
<?php if ($canManage): ?> · <?= (int) $item['spot_count'] ?> <?= (int) $item['spot_count'] === 1 ? 'Bild' : 'Bilder' ?><?php endif; ?>
|
||
</span>
|
||
</a>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
<?php
|
||
include __DIR__ . '/includes/footer.php';
|
||
exit;
|
||
}
|
||
|
||
// ---------------------------------------------------------------- Einzelne Jagd
|
||
$huntId = (int) $hunt['id'];
|
||
$spots = hunt_spots($huntId);
|
||
$started = hunt_started($hunt);
|
||
$running = hunt_running($hunt);
|
||
$showSpots = $canManage || $started;
|
||
$own = hunt_own_submissions($huntId, (int) $me['id']);
|
||
$bySpot = ($canManage || !empty($hunt['results_public'])) ? hunt_submissions_by_spot($huntId) : [];
|
||
$board = $bySpot ? hunt_leaderboard($bySpot) : [];
|
||
|
||
// Nummern der Orte ("Ort 1", "Ort 2" ...) - das Bonusbild zaehlt nicht mit
|
||
$labels = [];
|
||
$number = 0;
|
||
foreach ($spots as $spot) {
|
||
$labels[(int) $spot['id']] = hunt_spot_label($spot, empty($spot['is_bonus']) ? ++$number : 0);
|
||
}
|
||
$pendingTotal = 0;
|
||
foreach ($bySpot as $rows) {
|
||
$pendingTotal += count(array_filter($rows, static fn (array $r): bool => $r['status'] === 'pending'));
|
||
}
|
||
|
||
$pageTitle = $hunt['title'] . ' - Schnitzeljagd';
|
||
include __DIR__ . '/includes/header.php';
|
||
?>
|
||
<div class="panel">
|
||
<div class="raid-header">
|
||
<h1><?= e($hunt['title']) ?></h1>
|
||
<?= $huntBadge($hunt) ?>
|
||
</div>
|
||
<p class="hunt-dates">
|
||
<span><?= icon('calendar') ?> Start: <strong><?= e(hunt_date((string) $hunt['starts_at'])) ?></strong></span>
|
||
<?php if (!empty($hunt['ends_at'])): ?>
|
||
<span><?= icon('flag') ?> Einsendeschluss: <strong><?= e(hunt_date((string) $hunt['ends_at'])) ?></strong></span>
|
||
<?php endif; ?>
|
||
</p>
|
||
<?php if (trim((string) $hunt['description']) !== ''): ?>
|
||
<div class="hunt-description"><?= nl2br(e((string) $hunt['description'])) ?></div>
|
||
<?php endif; ?>
|
||
<p class="field-hint">
|
||
Je Ort zählen die 5 schnellsten anerkannten Einsendungen (<?= implode(' / ', HUNT_RANK_POINTS) ?> Punkte).
|
||
Wer das Bonusbild innerhalb von <?= HUNT_BONUS_HOURS ?> Stunden findet, bekommt <?= HUNT_BONUS_POINTS ?> Punkte.
|
||
Es zählt die Uhrzeit, zu der deine Bilder hier hochgeladen wurden.
|
||
</p>
|
||
<?php if (!$started): ?>
|
||
<p class="hunt-wait"><?= icon('eye') ?> Die Bilder erscheinen <?= e(hunt_date((string) $hunt['starts_at'])) ?> hier – die Seite lädt dann von selbst neu.</p>
|
||
<?php elseif (!$running && !empty($hunt['is_published'])): ?>
|
||
<p class="hunt-wait"><?= icon('lock') ?> Die Schnitzeljagd ist beendet, Einsendungen sind nicht mehr möglich.</p>
|
||
<?php endif; ?>
|
||
<p><a href="/hunt.php" class="text-muted">← Alle Schnitzeljagden</a></p>
|
||
</div>
|
||
|
||
<?php if ($canManage): ?>
|
||
<nav class="filter-tabs hunt-tabs">
|
||
<a class="filter-tab" href="#orte">Orte <span class="filter-tab-count"><?= count($spots) ?></span></a>
|
||
<a class="filter-tab" href="#einsendungen">Einsendungen <span class="filter-tab-count"><?= $pendingTotal ?> offen</span></a>
|
||
<a class="filter-tab" href="#rangliste">Rangliste</a>
|
||
<a class="filter-tab" href="#einstellungen">Einstellungen</a>
|
||
</nav>
|
||
<?php endif; ?>
|
||
|
||
<?php // ---------------------------------------------------------------- Orte ?>
|
||
<?php if ($showSpots): ?>
|
||
<div class="panel" id="orte">
|
||
<h2>Gesuchte Orte</h2>
|
||
<?php if ($canManage && !$started): ?>
|
||
<p class="field-hint"><?= icon('lock') ?> Nur die Leitung sieht die Bilder schon jetzt – die Mitglieder erst zum Start.</p>
|
||
<?php endif; ?>
|
||
<?php if (!$spots): ?>
|
||
<p class="text-muted"><?= $canManage ? 'Noch keine Bilder – unten den ersten Ort hochladen.' : 'Hier sind noch keine Bilder.' ?></p>
|
||
<?php endif; ?>
|
||
<div class="hunt-spots">
|
||
<?php foreach ($spots as $spot): ?>
|
||
<?php
|
||
$spotId = (int) $spot['id'];
|
||
$label = $labels[$spotId];
|
||
$mine = $own[$spotId] ?? null;
|
||
?>
|
||
<article class="hunt-spot<?= !empty($spot['is_bonus']) ? ' hunt-spot-bonus' : '' ?>" id="ort-<?= $spotId ?>">
|
||
<?= hunt_thumb_html('spot', $spotId, 'orte', $label, 'hunt-spot-image') ?>
|
||
<div class="hunt-spot-body">
|
||
<h3><?= e($label) ?></h3>
|
||
<?php if (!empty($spot['is_bonus'])): ?>
|
||
<p class="field-hint">Zählt bis <?= e(hunt_date(date('Y-m-d H:i:s', hunt_bonus_deadline($hunt)))) ?></p>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($mine): ?>
|
||
<div class="hunt-own">
|
||
<div class="hunt-own-head">
|
||
<?= hunt_status_badge((string) $mine['status']) ?>
|
||
<span class="text-muted">eingesendet <?= e(hunt_time((string) $mine['submitted_at'])) ?></span>
|
||
</div>
|
||
<div class="hunt-pair">
|
||
<?= hunt_thumb_html('shot', (int) $mine['id'], 'mine-' . $spotId, 'Dein Screenshot vom Ort') ?>
|
||
<?= hunt_thumb_html('map', (int) $mine['id'], 'mine-' . $spotId, 'Deine Karte mit Standort') ?>
|
||
</div>
|
||
<?php if (!empty($mine['review_note'])): ?>
|
||
<p class="hunt-review-note"><?= icon('message') ?> <?= e((string) $mine['review_note']) ?></p>
|
||
<?php endif; ?>
|
||
<?php if ($running && $mine['status'] !== 'accepted'): ?>
|
||
<form method="post" action="/hunt_action.php" class="inline-form" data-confirm="Deine Einsendung für diesen Ort zurückziehen? Sendest du später neu ein, zählt die neue Uhrzeit." data-confirm-title="Einsendung zurückziehen" data-confirm-danger data-confirm-ok="Zurückziehen">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="withdraw">
|
||
<input type="hidden" name="spot_id" value="<?= $spotId ?>">
|
||
<button type="submit" class="text-button">Zurückziehen</button>
|
||
</form>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php // Die Leitung wertet aus und macht nicht mit - bei ihr nur die Verwaltung ?>
|
||
<?php if ($running && !$canManage && (!$mine || $mine['status'] === 'rejected')): ?>
|
||
<form method="post" action="/hunt_action.php" enctype="multipart/form-data" class="hunt-submit-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="submit">
|
||
<input type="hidden" name="spot_id" value="<?= $spotId ?>">
|
||
<label>Screenshot vom Ort
|
||
<input type="file" name="screenshot" accept="image/png,image/jpeg,image/gif,image/webp" required data-max-size="<?= HUNT_MAX_SIDE ?>" data-paste>
|
||
</label>
|
||
<label>Karte mit deinem Standort
|
||
<input type="file" name="map" accept="image/png,image/jpeg,image/gif,image/webp" required data-max-size="<?= HUNT_MAX_SIDE ?>" data-paste>
|
||
</label>
|
||
<input type="text" name="note" maxlength="255" placeholder="Bemerkung (optional), z.B. dein Charaktername">
|
||
<div class="field-hint">Uhrzeit muss zu sehen sein (UI nicht ausblenden), auf der Karte Ort und Uhrzeit. Je Bild höchstens 10 MB.</div>
|
||
<button type="submit"><?= $mine ? 'Neu einsenden' : 'Einsenden' ?></button>
|
||
</form>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($canManage): ?>
|
||
<details class="hunt-spot-edit">
|
||
<summary class="text-muted"><?= icon('edit') ?> Bearbeiten</summary>
|
||
<form method="post" action="/hunt_action.php" enctype="multipart/form-data">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="update_spot">
|
||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||
<input type="hidden" name="spot_id" value="<?= $spotId ?>">
|
||
<input type="text" name="title" maxlength="120" placeholder="Hinweis (optional)" value="<?= e((string) $spot['title']) ?>">
|
||
<label class="checkbox-label"><input type="checkbox" name="is_bonus" value="1"<?= !empty($spot['is_bonus']) ? ' checked' : '' ?>> Bonusbild</label>
|
||
<label>Anderes Bild <span class="text-muted">(optional)</span>
|
||
<input type="file" name="image" accept="image/png,image/jpeg,image/gif,image/webp" data-max-size="<?= HUNT_MAX_SIDE ?>">
|
||
</label>
|
||
<div class="actions"><button type="submit" class="button-small">Speichern</button></div>
|
||
</form>
|
||
<form method="post" action="/hunt_action.php" class="inline-form" data-confirm="Diesen Ort samt allen Einsendungen dafür endgültig löschen?" data-confirm-title="Ort löschen" data-confirm-danger data-confirm-ok="Löschen">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="delete_spot">
|
||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||
<input type="hidden" name="spot_id" value="<?= $spotId ?>">
|
||
<button type="submit" class="text-button"><?= icon('trash') ?> Ort löschen</button>
|
||
</form>
|
||
</details>
|
||
<?php endif; ?>
|
||
</div>
|
||
</article>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
|
||
<?php if ($canManage): ?>
|
||
<form method="post" action="/hunt_action.php" enctype="multipart/form-data" class="hunt-add-spot">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="add_spot">
|
||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||
<h3>Ort hinzufügen</h3>
|
||
<input type="file" name="image" accept="image/png,image/jpeg,image/gif,image/webp" required data-max-size="<?= HUNT_MAX_SIDE ?>" data-paste>
|
||
<input type="text" name="title" maxlength="120" placeholder="Hinweis (optional), z.B. „Irgendwo in Verteron“">
|
||
<label class="checkbox-label"><input type="checkbox" name="is_bonus" value="1"> Bonusbild (<?= HUNT_BONUS_POINTS ?> Punkte für alle, die es innerhalb von <?= HUNT_BONUS_HOURS ?> Stunden finden)</label>
|
||
<div class="actions"><button type="submit">Hochladen</button></div>
|
||
</form>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php // ---------------------------------------------------------------- Einsendungen (nur Leitung) ?>
|
||
<?php if ($canManage): ?>
|
||
<div class="panel" id="einsendungen">
|
||
<h2>Einsendungen</h2>
|
||
<p class="text-muted">Nur die Leitung sieht diese Bilder. Je Ort nach Uhrzeit des Hochladens sortiert – Platz und Punkte zählen nur anerkannte Einsendungen.</p>
|
||
<?php if (!$spots): ?>
|
||
<p class="text-muted">Noch keine Orte.</p>
|
||
<?php endif; ?>
|
||
<?php foreach ($spots as $spot): ?>
|
||
<?php $spotId = (int) $spot['id']; $rows = $bySpot[$spotId] ?? []; ?>
|
||
<section class="hunt-review-spot">
|
||
<h3><?= hunt_thumb_html('spot', $spotId, 'review-spot-' . $spotId, $labels[$spotId], 'hunt-review-spot-thumb') ?> <?= e($labels[$spotId]) ?>
|
||
<span class="text-muted"><?= count($rows) ?> <?= count($rows) === 1 ? 'Einsendung' : 'Einsendungen' ?></span></h3>
|
||
<?php if (!$rows): ?>
|
||
<p class="text-muted">Noch keine Einsendungen.</p>
|
||
<?php endif; ?>
|
||
<?php foreach ($rows as $row): ?>
|
||
<?php
|
||
$memberName = $row['user_id'] === null ? 'Gelöschtes Konto' : ($row['display_name'] !== '' ? $row['display_name'] : $row['username']);
|
||
$reviewer = $row['reviewer_username'] !== null ? ($row['reviewer_display_name'] !== '' ? $row['reviewer_display_name'] : $row['reviewer_username']) : null;
|
||
?>
|
||
<div class="hunt-submission hunt-submission-<?= e((string) $row['status']) ?>" id="einsendung-<?= (int) $row['id'] ?>">
|
||
<div class="hunt-submission-place">
|
||
<?php if ($row['rank'] !== null): ?>
|
||
<strong><?= (int) $row['rank'] ?>.</strong>
|
||
<?php endif; ?>
|
||
<?php if ($row['status'] === 'accepted'): ?>
|
||
<span class="hunt-points"><?= (int) $row['points'] ?> P.</span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<div class="hunt-submission-user">
|
||
<?= avatar_html(['id' => $row['user_id'], 'username' => $row['username'], 'display_name' => $row['display_name'], 'discord_id' => $row['discord_id'], 'avatar_filename' => $row['avatar_filename']], 32) ?>
|
||
<div>
|
||
<strong><?= e($memberName) ?></strong>
|
||
<span class="hunt-submission-time" title="Zeitpunkt des Hochladens"><?= icon('calendar') ?> <?= e(hunt_time((string) $row['submitted_at'])) ?></span>
|
||
<?php if (!empty($row['note'])): ?>
|
||
<span class="text-muted">„<?= e((string) $row['note']) ?>“</span>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
<div class="hunt-pair">
|
||
<?= hunt_thumb_html('shot', (int) $row['id'], 'sub-' . (int) $row['id'], $memberName . ': Screenshot vom Ort (' . hunt_time((string) $row['submitted_at']) . ')') ?>
|
||
<?= hunt_thumb_html('map', (int) $row['id'], 'sub-' . (int) $row['id'], $memberName . ': Karte mit Standort (' . hunt_time((string) $row['submitted_at']) . ')') ?>
|
||
</div>
|
||
<form method="post" action="/hunt_action.php" class="hunt-review-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="review">
|
||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||
<input type="hidden" name="submission_id" value="<?= (int) $row['id'] ?>">
|
||
<div class="hunt-review-head">
|
||
<?= hunt_status_badge((string) $row['status']) ?>
|
||
<?php if ($reviewer !== null): ?>
|
||
<span class="field-hint">von <?= e($reviewer) ?></span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<input type="text" name="review_note" maxlength="255" placeholder="Begründung (optional, sieht das Mitglied)" value="<?= e((string) ($row['review_note'] ?? '')) ?>">
|
||
<div class="hunt-review-buttons">
|
||
<button type="submit" name="status" value="accepted" class="button-small button-success">Anerkennen</button>
|
||
<button type="submit" name="status" value="rejected" class="button-small button-danger">Ablehnen</button>
|
||
<?php if ($row['status'] !== 'pending'): ?>
|
||
<button type="submit" name="status" value="pending" class="button-small button-secondary">Zurücksetzen</button>
|
||
<?php endif; ?>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</section>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php // ---------------------------------------------------------------- Rangliste ?>
|
||
<?php if ($canManage || !empty($hunt['results_public'])): ?>
|
||
<div class="panel" id="rangliste">
|
||
<div class="raid-header">
|
||
<h2>Rangliste</h2>
|
||
<?php if ($canManage): ?>
|
||
<form method="post" action="/hunt_action.php" class="inline-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="results">
|
||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||
<input type="hidden" name="public" value="<?= empty($hunt['results_public']) ? '1' : '0' ?>">
|
||
<button type="submit" class="button-small<?= empty($hunt['results_public']) ? '' : ' button-secondary' ?>">
|
||
<?= empty($hunt['results_public']) ? 'Für Mitglieder veröffentlichen' : 'Wieder verbergen' ?>
|
||
</button>
|
||
</form>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php if ($canManage): ?>
|
||
<p class="field-hint"><?= !empty($hunt['results_public']) ? 'Die Mitglieder sehen diese Rangliste (ohne die Bilder der anderen).' : 'Nur die Leitung sieht die Rangliste, bis sie veröffentlicht wird.' ?>
|
||
<?= $pendingTotal > 0 ? ' Noch ' . $pendingTotal . ' ungeprüfte ' . ($pendingTotal === 1 ? 'Einsendung' : 'Einsendungen') . ' – sie zählen erst nach dem Anerkennen.' : '' ?></p>
|
||
<?php endif; ?>
|
||
<?php if (!$board): ?>
|
||
<p class="text-muted">Noch keine anerkannten Einsendungen.</p>
|
||
<?php else: ?>
|
||
<div class="table-scroll">
|
||
<table class="hunt-board">
|
||
<thead><tr><th>Platz</th><th>Mitglied</th><th>Gefunden</th><th>Punkte</th></tr></thead>
|
||
<tbody>
|
||
<?php $place = 0; $lastPoints = null; foreach ($board as $i => $entry): ?>
|
||
<?php if ($entry['points'] !== $lastPoints) { $place = $i + 1; $lastPoints = $entry['points']; } ?>
|
||
<tr<?= (int) $entry['user']['id'] === (int) $me['id'] ? ' class="hunt-board-me"' : '' ?>>
|
||
<td><strong><?= $place ?>.</strong></td>
|
||
<td class="hunt-board-user"><?= avatar_html($entry['user'], 28) ?> <?= e($entry['user']['display_name'] !== '' ? $entry['user']['display_name'] : $entry['user']['username']) ?></td>
|
||
<td><?= (int) $entry['found'] ?> / <?= count($spots) ?></td>
|
||
<td><strong><?= (int) $entry['points'] ?></strong></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php // ---------------------------------------------------------------- Einstellungen (nur Leitung) ?>
|
||
<?php if ($canManage): ?>
|
||
<details class="panel hunt-collapse" id="einstellungen"<?= $form ? ' open' : '' ?>>
|
||
<summary><h2><?= icon('edit') ?> Einstellungen</h2></summary>
|
||
<?= $huntForm($hunt) ?>
|
||
<form method="post" action="/hunt_action.php" class="inline-form hunt-delete" data-confirm="Diese Schnitzeljagd samt allen Bildern und Einsendungen endgültig löschen?" data-confirm-title="Schnitzeljagd löschen" data-confirm-danger data-confirm-ok="Löschen">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="delete_hunt">
|
||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||
<button type="submit" class="button-small button-danger"><?= icon('trash') ?> Schnitzeljagd löschen</button>
|
||
</form>
|
||
</details>
|
||
<?php endif; ?>
|
||
|
||
<script src="<?= e(asset_url('/assets/js/image-resize.js')) ?>"></script>
|
||
<script src="<?= e(asset_url('/assets/js/lightbox.js')) ?>" defer></script>
|
||
<?php include __DIR__ . '/includes/footer.php'; ?>
|