- calendar.php: raids and events live from the bot API (no duplicate data), recurring events projected forward, agenda list, mobile view with dots - Optionally public (without login, titles and times only), linked on the homepage - Members add their own entries (calendar_entries), participants via "I'm in", same protections as comments (filter, approval, report button, rate limit) - Moderation also covers calendar entries Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
90 lines
5.8 KiB
PHP
90 lines
5.8 KiB
PHP
<?php
|
||
/**
|
||
* Ein Termin eines Mitglieds in der Terminliste des Kalenders (eingebunden in calendar.php).
|
||
*
|
||
* @var array $entry mit row, people, joined, reported
|
||
* @var bool $isModerator
|
||
* @var int $myId
|
||
* @var callable $entryFields
|
||
*/
|
||
$row = $entry['row'];
|
||
$entryId = (int) $row['id'];
|
||
$isAuthor = (int) $row['user_id'] === $myId;
|
||
$ends = $row['ends_at'] ? strtotime((string) $row['ends_at']) : null;
|
||
$actionForm = static function (string $action, string $label, string $class, string $confirm = '') use ($entryId): string {
|
||
return '<form class="inline-form" method="post" action="/calendar_action.php"' . ($confirm !== '' ? ' onsubmit="return confirm("' . e($confirm) . '");"' : '') . '>'
|
||
. csrf_field() . '<input type="hidden" name="action" value="' . $action . '"><input type="hidden" name="id" value="' . $entryId . '">'
|
||
. '<button type="submit" class="button-small ' . $class . '">' . $label . '</button></form>';
|
||
};
|
||
?>
|
||
<div class="calendar-member-entry calendar-member<?= $row['status'] === 'pending' ? ' is-pending' : '' ?>" id="termin-<?= $entryId ?>">
|
||
<div class="calendar-member-head">
|
||
<span class="calendar-time"><?= date('H:i', $entry['time']) ?><?= $ends ? '–' . (date('Y-m-d', $ends) === date('Y-m-d', $entry['time']) ? date('H:i', $ends) : date('d.m. H:i', $ends)) : '' ?> Uhr</span>
|
||
<strong class="calendar-member-title"><?= e((string) $row['title']) ?></strong>
|
||
<?php if ($row['status'] === 'pending'): ?>
|
||
<span class="pending-badge-inline" title="<?= e((string) $row['moderation_note']) ?>">Wartet auf Freigabe</span>
|
||
<?php endif; ?>
|
||
<span class="calendar-member-author">
|
||
<?= avatar_html(['id' => $row['user_id'], 'username' => $row['username'], 'display_name' => $row['display_name'], 'avatar_filename' => $row['avatar_filename']], 22) ?>
|
||
<a href="/member.php?id=<?= (int) $row['user_id'] ?>"><?= e((string) $row['author']) ?></a>
|
||
</span>
|
||
</div>
|
||
<?php if (!empty($row['description'])): ?>
|
||
<p class="calendar-member-description"><?= gallery_comment_html((string) $row['description']) ?></p>
|
||
<?php endif; ?>
|
||
<div class="calendar-member-foot">
|
||
<div class="calendar-participants" title="<?= e(implode(', ', array_map(static fn ($p) => $p['display_name'] !== '' ? $p['display_name'] : $p['username'], $entry['people']))) ?>">
|
||
<?php foreach (array_slice($entry['people'], 0, 8) as $person): ?>
|
||
<?= avatar_html($person, 24) ?>
|
||
<?php endforeach; ?>
|
||
<span class="text-muted"><?= count($entry['people']) ?> dabei</span>
|
||
</div>
|
||
<div class="calendar-member-actions">
|
||
<?php if (!$entry['past']): ?>
|
||
<?= $entry['joined']
|
||
? $actionForm('leave', 'Absagen', 'button-secondary')
|
||
: $actionForm('join', '✋ Bin dabei', 'button-success') ?>
|
||
<?php endif; ?>
|
||
<?php if ($isModerator && $row['status'] === 'pending'): ?>
|
||
<form class="inline-form" method="post" action="/moderation_action.php">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="approve"><input type="hidden" name="type" value="calendar">
|
||
<input type="hidden" name="id" value="<?= $entryId ?>"><input type="hidden" name="back" value="calendar">
|
||
<button type="submit" class="button-small button-success">Freigeben</button>
|
||
</form>
|
||
<?php endif; ?>
|
||
<?php if ($isAuthor): ?>
|
||
<details class="calendar-edit">
|
||
<summary class="icon-button" title="Bearbeiten" aria-label="Bearbeiten"><?= icon('edit') ?></summary>
|
||
<form method="post" action="/calendar_action.php" class="calendar-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="update">
|
||
<input type="hidden" name="id" value="<?= $entryId ?>">
|
||
<?= $entryFields($row) ?>
|
||
<div class="actions"><button type="submit">Speichern</button></div>
|
||
</form>
|
||
</details>
|
||
<?php endif; ?>
|
||
<?php if ($isAuthor || $isModerator): ?>
|
||
<form class="inline-form" method="post" action="/calendar_action.php" onsubmit="return confirm('Diesen Termin löschen?');">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="delete"><input type="hidden" name="id" value="<?= $entryId ?>">
|
||
<button type="submit" class="icon-button icon-button-danger" title="Löschen" aria-label="Löschen"><?= icon('trash') ?></button>
|
||
</form>
|
||
<?php endif; ?>
|
||
<?php if (!$isAuthor): ?>
|
||
<?php if ($entry['reported']): ?>
|
||
<span class="report-done" title="Du hast das gemeldet - danke!"><?= icon('flag') ?> Gemeldet</span>
|
||
<?php else: ?>
|
||
<form class="inline-form" method="post" action="/moderation_action.php"
|
||
onsubmit="var r = prompt("Was ist daran nicht in Ordnung? (optional)"); if (r === null) return false; this.reason.value = r; return true;">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="action" value="report"><input type="hidden" name="type" value="calendar">
|
||
<input type="hidden" name="id" value="<?= $entryId ?>"><input type="hidden" name="reason" value="">
|
||
<button type="submit" class="icon-button report-button" title="Melden" aria-label="Melden"><?= icon('flag') ?></button>
|
||
</form>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
</div>
|