Activity check (website + bot), videos in the wiki, contributor search list
- Activity check: created on the website (activity.php, activity.manage) or with /aktivitaetscheck; the bot posts "I'm in" / "I'm out" buttons; title, text, color, image and button labels are configurable with a live preview; deadline; consequences for non-responders (DM, remove/add role, optionally also for "I'm out"); close early or cancel; overview of in / out / pending - Wiki: a video link alone on a line (YouTube incl. Shorts/start time, Twitch, Vimeo, .mp4/.webm) becomes an embedded player, plus a "Video" button in the editor - Wiki: "Add contributor" as a search list with avatar, group and class instead of a dropdown Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
905e954118
commit
392994e1cd
13 changed files with 802 additions and 14 deletions
23
README.md
23
README.md
|
|
@ -682,11 +682,14 @@ Unter **Wiki** im Menü liegt der Einsteiger-Guide der Legion: Kapitel mit Unter
|
|||
automatisch nummeriert (3. / 3.1.), mit Suche, „WIP“-Markierung, Verlauf aller Änderungen
|
||||
und Wiederherstellen alter Versionen. Geschrieben wird in einem einfachen Textformat mit
|
||||
Knöpfen (fett, Überschrift, Liste, Tabelle, Link, `[[Wiki-Link]]`, Bild-Upload) und
|
||||
Live-Vorschau (`includes/wiki.php`, `wiki_render()`); eingegebenes HTML ist nie aktiv.
|
||||
Live-Vorschau (`includes/wiki.php`, `wiki_render()`); eingegebenes HTML ist nie aktiv. **Videos:**
|
||||
Ein Link zu YouTube (auch Shorts und Startzeit), Twitch (Clip oder Video), Vimeo oder einer
|
||||
Videodatei (.mp4/.webm) allein in einer Zeile wird zum eingebetteten Player - im Editor über
|
||||
den Knopf „▶ Video“ (`wiki_video_embed()`; YouTube über youtube-nocookie.com).
|
||||
|
||||
- **Lesen:** `wiki.view` - bekommen beim Update alle Gruppen, die ins Dashboard dürfen.
|
||||
- **Schreiben:** `wiki.edit` für ganze Gruppen, oder einzelne Mitglieder, die die Leitung im
|
||||
Wiki unter „Mitwirkende“ hinzufügt (Tabelle `wiki_contributors`).
|
||||
Wiki unter „Mitwirkende“ hinzufügt (Tabelle `wiki_contributors`, Suchliste mit Avatar und Gruppe).
|
||||
- **Verwalten:** `wiki.manage` - Seiten löschen und verschieben, Mitwirkende verwalten,
|
||||
alte Versionen wiederherstellen.
|
||||
|
||||
|
|
@ -770,6 +773,22 @@ die Moderation. Es gelten dieselben Regeln wie bei Kommentaren: Schimpfwortfilte
|
|||
Links bzw. von neuen Mitgliedern erst nach Freigabe (Moderation → Freigabe), Melden-Knopf,
|
||||
höchstens 8 neue Termine pro Stunde (`calendar_action.php`).
|
||||
|
||||
## Aktivitätscheck
|
||||
|
||||
**Aktivitätscheck** im Menü (`activity.php`, Berechtigung `activity.manage`) bzw. `/aktivitaetscheck`
|
||||
im Discord: Der Bot postet im gewählten Kanal eine Nachricht mit den Knöpfen „Ich bin da“ und
|
||||
„Ich bin nicht da“ (Knopftexte, Titel, Text, Farbe und Bild frei wählbar, mit Live-Vorschau).
|
||||
Antworten kann, wer die Zielrolle hat; die Antwort lässt sich bis zum Ende ändern. Nach der
|
||||
eingestellten Zeit - oder vorher über „Jetzt abschließen“ (Website) bzw.
|
||||
`/aktivitaetscheck_beenden` - bekommen alle ohne Rückmeldung die gewählten Folgen: PN (Text mit
|
||||
{name}/{titel}/{server}), Rolle entfernen, Rolle geben; auf Wunsch auch alle mit „nicht da“.
|
||||
Die Liste landet immer im Log-Kanal. „Abbrechen“ beendet ohne Folgen. Die Website zeigt je
|
||||
Check, wer da / nicht da / noch offen ist.
|
||||
|
||||
Im Bot: `cogs/activity.py` (Tabellen `activity_checks`, `activity_responses`, Knöpfe über
|
||||
DynamicItem auch nach Neustarts), API `/api/activity-checks` in `api.py`. Der Bot kann Rollen nur
|
||||
unterhalb seiner eigenen Rolle ändern.
|
||||
|
||||
## Moderation (Galeriebilder und Kommentare)
|
||||
|
||||
`includes/moderation.php`, Seite **Admin → Moderation** (`moderation.php`, Berechtigung
|
||||
|
|
|
|||
319
activity.php
Normal file
319
activity.php
Normal file
|
|
@ -0,0 +1,319 @@
|
|||
<?php
|
||||
/**
|
||||
* Aktivitaetschecks: im Discord einen Check mit "Ich bin da" / "Ich bin nicht da" posten,
|
||||
* Rueckmeldungen verfolgen und den Check (vorzeitig) abschliessen. Den Check selbst verwaltet
|
||||
* der Bot (cogs/activity.py) - diese Seite spricht mit ihm ueber includes/activity_api.php.
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/activity_api.php';
|
||||
require_permission('activity.manage');
|
||||
|
||||
$detailId = (int) ($_GET['id'] ?? 0);
|
||||
$apiError = null;
|
||||
$checks = [];
|
||||
$detail = null;
|
||||
try {
|
||||
if ($detailId > 0) {
|
||||
$detail = activity_api_request('GET', '/' . $detailId)['check'] ?? null;
|
||||
} else {
|
||||
$checks = activity_api_request('GET', '', ['guild_id' => events_guild_id()])['checks'] ?? [];
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
$apiError = $e->getMessage();
|
||||
}
|
||||
if ($detailId > 0 && !$detail && !$apiError) {
|
||||
show_not_found();
|
||||
}
|
||||
|
||||
// Kanaele und Rollen fuer das Formular
|
||||
$channels = [];
|
||||
$roles = [];
|
||||
$pickerError = null;
|
||||
if ($detailId === 0) {
|
||||
try {
|
||||
$channels = guilds_api_request('/channels')['channels'] ?? [];
|
||||
$roles = guilds_api_request('/roles')['roles'] ?? [];
|
||||
} catch (Throwable $e) {
|
||||
$pickerError = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/** Discord-IDs -> Website-Konten (Name + Profilbild), fuer die Listen in der Detailansicht. */
|
||||
$usersByDiscord = [];
|
||||
if ($detail) {
|
||||
$ids = array_merge(array_column($detail['responses'] ?? [], 'user_id'), array_column($detail['pending'] ?? [], 'user_id'),
|
||||
array_column($detail['result']['missing'] ?? [], 'user_id'));
|
||||
$ids = array_values(array_unique(array_map('strval', $ids)));
|
||||
if ($ids) {
|
||||
$stmt = db()->prepare('SELECT id, username, display_name, avatar_filename, discord_id FROM users WHERE discord_id IN ('
|
||||
. implode(',', array_fill(0, count($ids), '?')) . ')');
|
||||
$stmt->execute($ids);
|
||||
foreach ($stmt->fetchAll() as $row) {
|
||||
$usersByDiscord[(string) $row['discord_id']] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
$person = static function (string $discordId, string $fallbackName) use ($usersByDiscord): string {
|
||||
$user = $usersByDiscord[$discordId] ?? null;
|
||||
$name = $user ? ($user['display_name'] !== '' ? $user['display_name'] : $user['username']) : $fallbackName;
|
||||
$avatar = avatar_html($user ?: ['id' => $discordId, 'display_name' => $fallbackName], 28);
|
||||
return '<li class="activity-person">' . $avatar . ($user ? '<a href="/member.php?id=' . (int) $user['id'] . '">' . e($name) . '</a>' : '<span>' . e($name) . '</span>') . '</li>';
|
||||
};
|
||||
|
||||
/** "noch 2 Tage 4 Std." bzw. "vor 3 Std." */
|
||||
$relative = static function (int $timestamp): string {
|
||||
$diff = $timestamp - time();
|
||||
$abs = abs($diff);
|
||||
$text = $abs >= 86400 ? floor($abs / 86400) . ' Tg. ' . floor(($abs % 86400) / 3600) . ' Std.'
|
||||
: ($abs >= 3600 ? floor($abs / 3600) . ' Std. ' . floor(($abs % 3600) / 60) . ' Min.' : max(1, (int) floor($abs / 60)) . ' Min.');
|
||||
return $diff >= 0 ? 'noch ' . $text : 'vor ' . $text;
|
||||
};
|
||||
|
||||
$roleOptions = static function (string $selected = '', bool $withNone = false) use ($roles): string {
|
||||
$html = $withNone ? '<option value="">– keine –</option>' : '<option value="">– Rolle wählen –</option>';
|
||||
foreach ($roles as $role) {
|
||||
$rid = (string) ($role['role_id'] ?? '');
|
||||
$html .= '<option value="' . e($rid) . '"' . ($rid === $selected ? ' selected' : '') . '>@' . e((string) ($role['name'] ?? '')) . '</option>';
|
||||
}
|
||||
return $html;
|
||||
};
|
||||
|
||||
$openChecks = array_values(array_filter($checks, static fn ($c) => ($c['status'] ?? '') === 'open'));
|
||||
$pastChecks = array_values(array_filter($checks, static fn ($c) => ($c['status'] ?? '') !== 'open'));
|
||||
|
||||
$pageTitle = $detail ? 'Aktivitätscheck: ' . $detail['title'] : 'Aktivitätschecks';
|
||||
$containerWide = true;
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<?php if ($apiError): ?>
|
||||
<div class="panel"><div class="flash flash-error">Der Discord-Bot ist gerade nicht erreichbar: <?= e($apiError) ?></div></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($detail): ?>
|
||||
<?php
|
||||
$c = $detail['counts'] ?? [];
|
||||
$isOpen = $detail['status'] === 'open';
|
||||
$present = array_values(array_filter($detail['responses'] ?? [], static fn ($r) => $r['status'] === 'present'));
|
||||
$absent = array_values(array_filter($detail['responses'] ?? [], static fn ($r) => $r['status'] === 'absent'));
|
||||
$missing = $isOpen ? ($detail['pending'] ?? []) : ($detail['result']['missing'] ?? []);
|
||||
?>
|
||||
<div class="panel activity-detail-head">
|
||||
<a href="/activity.php" class="text-muted">‹ Alle Aktivitätschecks</a>
|
||||
<div class="raid-header">
|
||||
<h1>📋 <?= e($detail['title']) ?></h1>
|
||||
<span class="badge <?= $isOpen ? 'badge-active' : '' ?>"><?= $isOpen ? 'Läuft' : ($detail['status'] === 'cancelled' ? 'Abgebrochen' : 'Abgeschlossen') ?></span>
|
||||
</div>
|
||||
<p class="text-muted">
|
||||
#<?= e((string) ($detail['channel_name'] ?? $detail['channel_id'])) ?> · für @<?= e((string) ($detail['target_role_name'] ?? '?')) ?> ·
|
||||
<?= $isOpen ? 'endet ' . e(date('d.m.Y H:i', (int) $detail['deadline'])) . ' Uhr (' . e($relative((int) $detail['deadline'])) . ')'
|
||||
: 'beendet ' . e(date('d.m.Y H:i', (int) $detail['closed_at'])) . ' Uhr von ' . e((string) $detail['closed_by']) ?>
|
||||
<?php if (!empty($detail['jump_url'])): ?> · <a href="<?= e($detail['jump_url']) ?>" target="_blank" rel="noopener">Im Discord ansehen</a><?php endif; ?>
|
||||
</p>
|
||||
<?php if ($isOpen): ?>
|
||||
<div class="activity-actions">
|
||||
<form method="post" action="/activity_action.php" class="inline-form"
|
||||
onsubmit="return confirm('Jetzt abschließen? Alle ohne Rückmeldung (<?= (int) ($c['pending'] ?? 0) ?>) bekommen sofort die eingestellten Folgen.');">
|
||||
<?= csrf_field() ?><input type="hidden" name="action" value="close"><input type="hidden" name="id" value="<?= (int) $detail['check_id'] ?>">
|
||||
<button type="submit" class="button-success">✓ Jetzt abschließen</button>
|
||||
</form>
|
||||
<form method="post" action="/activity_action.php" class="inline-form" onsubmit="return confirm('Ohne Folgen abbrechen?');">
|
||||
<?= csrf_field() ?><input type="hidden" name="action" value="cancel"><input type="hidden" name="id" value="<?= (int) $detail['check_id'] ?>">
|
||||
<button type="submit" class="button-secondary">Abbrechen (ohne Folgen)</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="activity-consequences">
|
||||
<strong>Folgen ohne Rückmeldung<?= !empty($detail['apply_to_absent']) ? ' (auch bei „nicht da“)' : '' ?>:</strong>
|
||||
<?php
|
||||
$parts = [];
|
||||
if (!empty($detail['dm_enabled'])) $parts[] = '✉️ PN';
|
||||
if (!empty($detail['remove_role_id'])) $parts[] = '➖ @' . ($detail['remove_role_name'] ?? $detail['remove_role_id']) . ' entfernen';
|
||||
if (!empty($detail['add_role_id'])) $parts[] = '➕ @' . ($detail['add_role_name'] ?? $detail['add_role_id']) . ' geben';
|
||||
?>
|
||||
<?= $parts ? e(implode(' · ', $parts)) : '<span class="text-muted">keine - nur Liste im Log-Kanal</span>' ?>
|
||||
<?php if (!$isOpen && !empty($detail['result']) && $detail['status'] === 'closed'): ?>
|
||||
<br><span class="text-muted">Ergebnis: <?= (int) ($detail['result']['dm_sent'] ?? 0) ?> PN verschickt<?= !empty($detail['result']['dm_failed']) ? ' (' . (int) $detail['result']['dm_failed'] . ' mit geschlossenen PNs)' : '' ?>,
|
||||
<?= (int) ($detail['result']['roles_changed'] ?? 0) ?> Rollen geändert<?= !empty($detail['result']['role_errors']) ? ', ' . (int) $detail['result']['role_errors'] . ' Fehler (fehlen dem Bot Rechte?)' : '' ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="activity-columns">
|
||||
<div class="panel activity-column activity-present">
|
||||
<h2>✅ Da <span class="chip-count"><?= count($present) ?></span></h2>
|
||||
<ul><?php foreach ($present as $r): ?><?= $person((string) $r['user_id'], (string) $r['user_name']) ?><?php endforeach; ?></ul>
|
||||
<?php if (!$present): ?><p class="text-muted">Noch niemand.</p><?php endif; ?>
|
||||
</div>
|
||||
<div class="panel activity-column activity-absent">
|
||||
<h2>❌ Nicht da <span class="chip-count"><?= count($absent) ?></span></h2>
|
||||
<ul><?php foreach ($absent as $r): ?><?= $person((string) $r['user_id'], (string) $r['user_name']) ?><?php endforeach; ?></ul>
|
||||
<?php if (!$absent): ?><p class="text-muted">Niemand.</p><?php endif; ?>
|
||||
</div>
|
||||
<div class="panel activity-column activity-missing">
|
||||
<h2>⏳ <?= $isOpen ? 'Noch offen' : 'Ohne Rückmeldung' ?> <span class="chip-count"><?= count($missing) ?></span></h2>
|
||||
<ul><?php foreach ($missing as $r): ?><?= $person((string) $r['user_id'], (string) ($r['user_name'] ?? $r['name'] ?? '?')) ?><?php endforeach; ?></ul>
|
||||
<?php if (!$missing): ?><p class="text-muted"><?= $isOpen ? 'Alle haben sich gemeldet 🎉' : 'Alle haben sich gemeldet 🎉' ?></p><?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!$isOpen): ?>
|
||||
<div class="panel">
|
||||
<form method="post" action="/activity_action.php" onsubmit="return confirm('Diesen Check samt Nachricht im Discord endgültig löschen?');">
|
||||
<?= csrf_field() ?><input type="hidden" name="action" value="delete"><input type="hidden" name="id" value="<?= (int) $detail['check_id'] ?>">
|
||||
<button type="submit" class="button-danger button-small">Check löschen</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif (!$apiError): ?>
|
||||
<div class="panel">
|
||||
<div class="raid-header">
|
||||
<h1>📋 Aktivitätschecks</h1>
|
||||
<?php if (!$pickerError): ?>
|
||||
<button type="button" class="button-success" data-toggle-activity-form>+ Neuer Aktivitätscheck</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<p class="text-muted">
|
||||
Der Bot postet eine Nachricht mit den Knöpfen „Ich bin da“ und „Ich bin nicht da“. Wer die Zielrolle hat, meldet sich
|
||||
dort zurück. Zur Frist - oder vorher über „Jetzt abschließen“ - bekommen alle ohne Rückmeldung die eingestellten Folgen.
|
||||
Im Discord geht das auch mit <code>/aktivitaetscheck</code>.
|
||||
</p>
|
||||
<?php if ($pickerError): ?>
|
||||
<div class="flash flash-error">Kanäle/Rollen konnten nicht geladen werden: <?= e($pickerError) ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!$pickerError): ?>
|
||||
<div class="panel activity-create" id="activity-create" hidden>
|
||||
<h2>Neuer Aktivitätscheck</h2>
|
||||
<form method="post" action="/activity_action.php" class="activity-form" id="activity-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="create">
|
||||
<div class="activity-form-grid">
|
||||
<div class="activity-form-fields">
|
||||
<fieldset>
|
||||
<legend>Aussehen</legend>
|
||||
<label>Titel<input type="text" name="title" maxlength="100" required value="Aktivitätscheck" data-preview="title"></label>
|
||||
<label>Nachricht<textarea name="message" rows="5" maxlength="3500" required data-preview="message">Hey zusammen! 👋
|
||||
Bitte meldet euch kurz zurück, ob ihr noch aktiv dabei seid. Einfach unten auf den passenden Knopf klicken.</textarea></label>
|
||||
<div class="activity-color-row">
|
||||
<span>Farbe</span>
|
||||
<?php foreach (ACTIVITY_COLORS as $hex => $label): ?>
|
||||
<label class="activity-swatch" title="<?= e($label) ?>" style="--swatch: <?= e($hex) ?>">
|
||||
<input type="radio" name="color" value="<?= e($hex) ?>" <?= $hex === '#c9a227' ? 'checked' : '' ?> data-preview="color">
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
<input type="color" name="color_custom" value="#c9a227" title="Eigene Farbe" data-preview="color-custom">
|
||||
</div>
|
||||
<label><span>Bild <span class="text-muted">(optional, https-Link)</span></span><input type="url" name="image_url" maxlength="500" placeholder="https://…" data-preview="image"></label>
|
||||
<div class="activity-row">
|
||||
<label>Knopf „da“<input type="text" name="yes_label" maxlength="60" placeholder="Ich bin da" data-preview="yes"></label>
|
||||
<label>Knopf „nicht da“<input type="text" name="no_label" maxlength="60" placeholder="Ich bin nicht da" data-preview="no"></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Wo und für wen</legend>
|
||||
<label>Kanal
|
||||
<select name="channel_id" required>
|
||||
<option value="">– Kanal wählen –</option>
|
||||
<?php foreach ($channels as $channel): ?>
|
||||
<option value="<?= e((string) $channel['channel_id']) ?>" <?= empty($channel['can_post']) ? 'disabled' : '' ?>>
|
||||
#<?= e((string) $channel['name']) ?><?= !empty($channel['category']) ? ' (' . e((string) $channel['category']) . ')' : '' ?><?= empty($channel['can_post']) ? ' – Bot darf hier nicht posten' : '' ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
<label><span>Wer soll sich melden? <span class="text-muted">(Zielrolle)</span></span>
|
||||
<select name="target_role_id" required data-preview="role"><?= $roleOptions() ?></select>
|
||||
</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="ping_role" value="1" checked data-preview="ping"> Zielrolle beim Posten pingen</label>
|
||||
<div class="activity-row">
|
||||
<label>Zeit zum Zurückmelden<input type="number" name="duration_value" min="1" max="60" value="3" required data-preview="duration"></label>
|
||||
<label> <select name="duration_unit" data-preview="duration">
|
||||
<option value="hours">Stunden</option>
|
||||
<option value="days" selected>Tage</option>
|
||||
</select></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Was passiert ohne Rückmeldung?</legend>
|
||||
<label class="checkbox-label"><input type="checkbox" name="dm_enabled" value="1" data-toggle-dm> Private Nachricht (PN) schicken</label>
|
||||
<label class="activity-dm" hidden><span>Text der PN <span class="text-muted">- Platzhalter: {name}, {titel}, {server}</span></span>
|
||||
<textarea name="dm_message" rows="3" maxlength="1800"><?= e(ACTIVITY_DEFAULT_DM) ?></textarea>
|
||||
</label>
|
||||
<div class="activity-row">
|
||||
<label>Rolle entfernen<select name="remove_role_id"><?= $roleOptions('', true) ?></select></label>
|
||||
<label><span>Rolle geben <span class="text-muted">(z.B. „Inaktiv“)</span></span><select name="add_role_id"><?= $roleOptions('', true) ?></select></label>
|
||||
</div>
|
||||
<label class="checkbox-label"><input type="checkbox" name="apply_to_absent" value="1"> Folgen auch für alle mit „Ich bin nicht da“</label>
|
||||
<p class="field-hint">Die Liste aller ohne Rückmeldung landet immer im Log-Kanal. Rollen ändern kann der Bot nur bei Rollen unterhalb seiner eigenen.</p>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="activity-preview-wrap">
|
||||
<span class="event-preview-label">Vorschau in Discord</span>
|
||||
<div class="discord-preview">
|
||||
<div class="discord-ping" data-out="ping">@<span data-out="role">Rolle</span></div>
|
||||
<div class="discord-embed" data-out="embed">
|
||||
<strong class="discord-embed-title">📋 <span data-out="title">Aktivitätscheck</span></strong>
|
||||
<div class="discord-embed-text" data-out="message"></div>
|
||||
<div class="discord-embed-field"><b>Rückmeldungen</b><span>✅ 0 da · ❌ 0 nicht da · ⏳ … offen</span></div>
|
||||
<div class="discord-embed-field"><b>⏰ Rückmeldung bis</b><span data-out="deadline">…</span></div>
|
||||
<img class="discord-embed-image" data-out="image" alt="" hidden>
|
||||
<div class="discord-embed-footer">Aktivitätscheck #…</div>
|
||||
</div>
|
||||
<div class="discord-buttons">
|
||||
<span class="discord-button discord-button-green">✅ <span data-out="yes">Ich bin da</span></span>
|
||||
<span class="discord-button">❌ <span data-out="no">Ich bin nicht da</span></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button type="submit" class="button-success">📋 Check jetzt posten</button>
|
||||
<button type="button" class="button-secondary" data-toggle-activity-form>Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="panel">
|
||||
<h2>Laufende Checks <span class="chip-count"><?= count($openChecks) ?></span></h2>
|
||||
<?php if (!$openChecks): ?><p class="text-muted">Gerade läuft kein Aktivitätscheck.</p><?php endif; ?>
|
||||
<div class="activity-cards">
|
||||
<?php foreach ($openChecks as $check): ?>
|
||||
<?php
|
||||
$c = $check['counts'] ?? [];
|
||||
$total = max(1, (int) ($c['present'] ?? 0) + (int) ($c['absent'] ?? 0) + (int) ($c['pending'] ?? 0));
|
||||
?>
|
||||
<a class="activity-card" href="/activity.php?id=<?= (int) $check['check_id'] ?>" style="--accent: #<?= e(str_pad(dechex((int) $check['color']), 6, '0', STR_PAD_LEFT)) ?>">
|
||||
<strong>📋 <?= e($check['title']) ?></strong>
|
||||
<span class="text-muted">#<?= e((string) ($check['channel_name'] ?? '?')) ?> · @<?= e((string) ($check['target_role_name'] ?? '?')) ?> · <?= e($relative((int) $check['deadline'])) ?></span>
|
||||
<div class="activity-bar" title="<?= (int) ($c['present'] ?? 0) ?> da, <?= (int) ($c['absent'] ?? 0) ?> nicht da, <?= (int) ($c['pending'] ?? 0) ?> offen">
|
||||
<i class="bar-present" style="width: <?= round(100 * (int) ($c['present'] ?? 0) / $total, 1) ?>%"></i>
|
||||
<i class="bar-absent" style="width: <?= round(100 * (int) ($c['absent'] ?? 0) / $total, 1) ?>%"></i>
|
||||
</div>
|
||||
<span class="activity-counts">✅ <?= (int) ($c['present'] ?? 0) ?> · ❌ <?= (int) ($c['absent'] ?? 0) ?> · ⏳ <?= (int) ($c['pending'] ?? 0) ?> offen</span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($pastChecks): ?>
|
||||
<div class="panel">
|
||||
<h2>Beendet</h2>
|
||||
<ul class="activity-past">
|
||||
<?php foreach ($pastChecks as $check): ?>
|
||||
<?php $c = $check['counts'] ?? []; ?>
|
||||
<li>
|
||||
<a href="/activity.php?id=<?= (int) $check['check_id'] ?>"><strong><?= e($check['title']) ?></strong></a>
|
||||
<span class="text-muted"><?= e(date('d.m.Y', (int) ($check['closed_at'] ?: $check['deadline']))) ?> ·
|
||||
<?= $check['status'] === 'cancelled' ? 'abgebrochen' : '✅ ' . (int) ($c['present'] ?? 0) . ' · ❌ ' . (int) ($c['absent'] ?? 0) . ' · ohne Rückmeldung: ' . count($check['result']['missing'] ?? []) ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<script src="<?= e(asset_url('/assets/js/activity.js')) ?>"></script>
|
||||
<?php endif; ?>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
111
activity_action.php
Normal file
111
activity_action.php
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
/**
|
||||
* Aktivitaetschecks anlegen, abschliessen, abbrechen, loeschen - weitergereicht an den Bot.
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/activity_api.php';
|
||||
require_permission('activity.manage');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
redirect('/activity.php');
|
||||
}
|
||||
verify_csrf();
|
||||
|
||||
$action = (string) ($_POST['action'] ?? '');
|
||||
$id = (int) ($_POST['id'] ?? 0);
|
||||
$me = current_user();
|
||||
$myName = $me['display_name'] !== '' ? $me['display_name'] : $me['username'];
|
||||
|
||||
/** Ganze Zahl aus einem ID-Feld (Discord-IDs sind 17-20 Stellen), null wenn leer. */
|
||||
$idField = static function (string $name): ?int {
|
||||
$value = trim((string) ($_POST[$name] ?? ''));
|
||||
return preg_match('/^\d{5,20}$/', $value) ? (int) $value : null;
|
||||
};
|
||||
|
||||
try {
|
||||
switch ($action) {
|
||||
case 'create':
|
||||
$title = trim((string) ($_POST['title'] ?? ''));
|
||||
$message = trim(str_replace("\r\n", "\n", (string) ($_POST['message'] ?? '')));
|
||||
$channelId = $idField('channel_id');
|
||||
$roleId = $idField('target_role_id');
|
||||
$value = max(1, min(60, (int) ($_POST['duration_value'] ?? 3)));
|
||||
$minutes = ($_POST['duration_unit'] ?? 'days') === 'hours' ? $value * 60 : $value * 1440;
|
||||
// Farbe: eigene Farbe gewinnt, wenn sie von der Auswahl abweicht
|
||||
$color = (string) ($_POST['color'] ?? '#c9a227');
|
||||
$custom = (string) ($_POST['color_custom'] ?? '');
|
||||
if (preg_match('/^#[0-9a-f]{6}$/i', $custom) && strtolower($custom) !== '#c9a227') {
|
||||
$color = $custom;
|
||||
}
|
||||
$image = trim((string) ($_POST['image_url'] ?? ''));
|
||||
|
||||
if ($title === '' || $message === '' || $channelId === null || $roleId === null) {
|
||||
throw new InvalidArgumentException('Bitte Titel, Nachricht, Kanal und Zielrolle ausfüllen.');
|
||||
}
|
||||
if ($image !== '' && !preg_match('#^https://\S+$#', $image)) {
|
||||
throw new InvalidArgumentException('Das Bild muss ein https-Link sein.');
|
||||
}
|
||||
$dmEnabled = !empty($_POST['dm_enabled']);
|
||||
$body = [
|
||||
'guild_id' => events_guild_id(),
|
||||
'channel_id' => $channelId,
|
||||
'target_role_id' => $roleId,
|
||||
'title' => mb_substr($title, 0, 100),
|
||||
'message' => mb_substr($message, 0, 3500),
|
||||
'color' => preg_match('/^#[0-9a-f]{6}$/i', $color) ? hexdec(substr($color, 1)) : 0xC9A227,
|
||||
'image_url' => $image !== '' ? $image : null,
|
||||
'ping_role' => !empty($_POST['ping_role']),
|
||||
'yes_label' => mb_substr(trim((string) ($_POST['yes_label'] ?? '')), 0, 60) ?: null,
|
||||
'no_label' => mb_substr(trim((string) ($_POST['no_label'] ?? '')), 0, 60) ?: null,
|
||||
'duration_minutes' => $minutes,
|
||||
'dm_enabled' => $dmEnabled,
|
||||
'dm_message' => $dmEnabled ? mb_substr(trim((string) ($_POST['dm_message'] ?? '')), 0, 1800) : null,
|
||||
'remove_role_id' => $idField('remove_role_id'),
|
||||
'add_role_id' => $idField('add_role_id'),
|
||||
'apply_to_absent' => !empty($_POST['apply_to_absent']),
|
||||
'created_by' => (int) ($me['discord_id'] ?? 0),
|
||||
];
|
||||
$result = activity_api_request('POST', '', [], $body);
|
||||
$consequences = array_filter([
|
||||
$dmEnabled ? 'PN' : null,
|
||||
$body['remove_role_id'] ? 'Rolle entfernen' : null,
|
||||
$body['add_role_id'] ? 'Rolle geben' : null,
|
||||
]);
|
||||
admin_log('📋 Aktivitätscheck gestartet', [
|
||||
'Titel' => $body['title'],
|
||||
'Dauer' => $minutes >= 1440 ? ($minutes / 1440) . ' Tage' : ($minutes / 60) . ' Stunden',
|
||||
'Folgen' => $consequences ? implode(', ', $consequences) : 'keine',
|
||||
], 'info', 'events');
|
||||
set_flash('success', 'Aktivitätscheck gepostet - die Leute können sich jetzt im Discord zurückmelden.');
|
||||
redirect('/activity.php?id=' . (int) ($result['check_id'] ?? 0));
|
||||
|
||||
case 'close':
|
||||
case 'cancel':
|
||||
$result = activity_api_request('POST', '/' . $id . '/close', [], [
|
||||
'cancel' => $action === 'cancel',
|
||||
'closed_by' => $myName . ' (Website)',
|
||||
])['result'] ?? [];
|
||||
admin_log($action === 'cancel' ? '🚫 Aktivitätscheck abgebrochen' : '📋 Aktivitätscheck abgeschlossen', [
|
||||
'Check' => '#' . $id,
|
||||
'Ohne Rückmeldung' => $action === 'cancel' ? '' : (string) count($result['missing'] ?? []),
|
||||
], $action === 'cancel' ? 'warning' : 'success', 'events');
|
||||
set_flash('success', $action === 'cancel'
|
||||
? 'Aktivitätscheck abgebrochen - ohne Folgen.'
|
||||
: 'Aktivitätscheck abgeschlossen. Ohne Rückmeldung: ' . count($result['missing'] ?? []) . '.');
|
||||
redirect('/activity.php?id=' . $id);
|
||||
|
||||
case 'delete':
|
||||
activity_api_request('DELETE', '/' . $id);
|
||||
admin_log('🗑️ Aktivitätscheck gelöscht', ['Check' => '#' . $id], 'warning', 'events');
|
||||
set_flash('success', 'Aktivitätscheck gelöscht.');
|
||||
redirect('/activity.php');
|
||||
}
|
||||
} catch (InvalidArgumentException $e) {
|
||||
set_flash('error', $e->getMessage());
|
||||
redirect('/activity.php');
|
||||
} catch (Throwable $e) {
|
||||
set_flash('error', 'Der Discord-Bot hat nicht mitgespielt: ' . $e->getMessage());
|
||||
redirect($id > 0 ? '/activity.php?id=' . $id : '/activity.php');
|
||||
}
|
||||
|
||||
redirect('/activity.php');
|
||||
|
|
@ -530,6 +530,7 @@ input[type="email"],
|
|||
input[type="password"],
|
||||
input[type="number"],
|
||||
input[type="search"],
|
||||
input[type="url"],
|
||||
input[type="datetime-local"],
|
||||
textarea,
|
||||
select {
|
||||
|
|
@ -5519,3 +5520,93 @@ a.calendar-agenda-entry:hover { text-decoration: none; filter: brightness(1.2);
|
|||
/* Kommentarfeld: Avatar neben dem Feld (Formulare sind sonst global untereinander) */
|
||||
.comment-form { flex-direction: row; }
|
||||
.comment-form textarea { font-family: inherit; font-size: 0.95rem; }
|
||||
|
||||
/* ---- Wiki: eingebettete Videos ---- */
|
||||
.wiki-video {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
max-width: 860px;
|
||||
aspect-ratio: 16 / 9;
|
||||
margin: 1rem 0;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
background: #000;
|
||||
border: 1px solid var(--border);
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
.wiki-video iframe, .wiki-video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
|
||||
.wiki-video-portrait { max-width: 340px; aspect-ratio: 9 / 16; }
|
||||
.wiki-video-file video { object-fit: contain; background: #000; }
|
||||
|
||||
/* Wiki: Mitwirkende hinzufuegen mit Suchliste (Avatare rund) */
|
||||
.wiki-contributor-add { align-items: center; }
|
||||
.wiki-contributor-add .item-picker { flex: 1 1 240px; min-width: 0; }
|
||||
.item-picker-round .item-picker-thumb { border-radius: 50%; object-fit: cover; }
|
||||
.item-picker[data-picker-round] .item-picker-preview { border-radius: 50% !important; object-fit: cover; }
|
||||
|
||||
/* ---- Aktivitaetschecks ---- */
|
||||
.activity-form-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
|
||||
@media (max-width: 1000px) { .activity-form-grid { grid-template-columns: 1fr; } }
|
||||
.activity-form-fields { display: flex; flex-direction: column; gap: 1rem; }
|
||||
.activity-form fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem 1rem 1rem; margin: 0; display: flex; flex-direction: column; gap: 0.7rem; }
|
||||
.activity-form legend { padding: 0 0.4rem; color: var(--gold); font-weight: 700; }
|
||||
.activity-form label { display: flex; flex-direction: column; gap: 0.3rem; }
|
||||
.activity-form label.checkbox-label { flex-direction: row; align-items: center; gap: 0.5rem; }
|
||||
.activity-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
|
||||
.activity-color-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
|
||||
.activity-color-row > span { margin-right: 0.3rem; }
|
||||
.activity-swatch { position: relative; flex-direction: row !important; width: 28px; height: 28px; border-radius: 50%; background: var(--swatch); cursor: pointer; border: 2px solid transparent; }
|
||||
.activity-swatch input { position: absolute; opacity: 0; }
|
||||
.activity-swatch:has(input:checked) { border-color: #fff; box-shadow: 0 0 0 2px var(--swatch); }
|
||||
.activity-color-row input[type="color"] { width: 36px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; }
|
||||
|
||||
.activity-preview-wrap { position: sticky; top: 1rem; }
|
||||
.discord-preview { margin-top: 0.4rem; padding: 1rem; border-radius: 10px; background: #313338; color: #dbdee1; font-size: 0.92rem; }
|
||||
.discord-ping { display: inline-block; margin-bottom: 0.4rem; padding: 0 0.2rem; border-radius: 3px; background: rgba(88, 101, 242, 0.3); color: #c9cdfb; font-weight: 600; }
|
||||
.discord-ping[hidden] { display: none; }
|
||||
.discord-embed { border-left: 4px solid #c9a227; border-radius: 4px; background: #2b2d31; padding: 0.7rem 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; max-width: 520px; }
|
||||
.discord-embed-title { color: #fff; font-size: 1rem; }
|
||||
.discord-embed-text { line-height: 1.45; overflow-wrap: anywhere; }
|
||||
.discord-embed-field { display: flex; flex-direction: column; font-size: 0.85rem; }
|
||||
.discord-embed-field b { color: #fff; }
|
||||
.discord-embed-image { max-width: 100%; border-radius: 4px; }
|
||||
.discord-embed-image[hidden] { display: none; }
|
||||
.discord-embed-footer { font-size: 0.75rem; color: #949ba4; }
|
||||
.discord-buttons { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
|
||||
.discord-button { padding: 0.35rem 0.9rem; border-radius: 4px; background: #4e5058; color: #fff; font-weight: 600; font-size: 0.85rem; }
|
||||
.discord-button-green { background: #248046; }
|
||||
|
||||
.activity-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.8rem; }
|
||||
.activity-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
padding: 0.9rem 1rem;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-left: 4px solid var(--accent, var(--gold));
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
color: var(--text);
|
||||
}
|
||||
.activity-card:hover { text-decoration: none; background: rgba(255, 255, 255, 0.06); }
|
||||
.activity-card .text-muted { font-size: 0.82rem; }
|
||||
.activity-bar { display: flex; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
|
||||
.activity-bar i { display: block; height: 100%; }
|
||||
.bar-present { background: #3ba55d; }
|
||||
.bar-absent { background: #ed4245; }
|
||||
.activity-counts { font-size: 0.82rem; color: var(--text-muted); }
|
||||
.activity-past { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
|
||||
.activity-past li { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; align-items: baseline; }
|
||||
|
||||
.activity-detail-head .raid-header { margin-top: 0.4rem; }
|
||||
.activity-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0; }
|
||||
.activity-consequences { margin-top: 0.4rem; font-size: 0.9rem; }
|
||||
.activity-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
|
||||
@media (max-width: 900px) { .activity-columns { grid-template-columns: 1fr; } }
|
||||
.activity-column h2 { display: flex; align-items: center; gap: 0.5rem; font-size: 1.1rem; }
|
||||
.activity-column ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
|
||||
.activity-person { display: flex; align-items: center; gap: 0.5rem; }
|
||||
.activity-present { border-top: 3px solid #3ba55d; }
|
||||
.activity-absent { border-top: 3px solid #ed4245; }
|
||||
.activity-missing { border-top: 3px solid #f0b232; }
|
||||
.activity-form textarea { font-family: inherit; resize: vertical; }
|
||||
|
|
|
|||
93
assets/js/activity.js
Normal file
93
assets/js/activity.js
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* Aktivitaetscheck anlegen: Formular ein-/ausblenden und Live-Vorschau, wie die Nachricht im
|
||||
* Discord aussehen wird (Farbe, Titel, Text, Bild, Knoepfe, Frist).
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var panel = document.getElementById('activity-create');
|
||||
var form = document.getElementById('activity-form');
|
||||
if (!panel || !form) return;
|
||||
|
||||
document.querySelectorAll('[data-toggle-activity-form]').forEach(function (button) {
|
||||
button.addEventListener('click', function () {
|
||||
panel.hidden = !panel.hidden;
|
||||
if (!panel.hidden) {
|
||||
panel.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
f.title.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var f = form.elements; // form.title waere das title-Attribut des Formulars, nicht das Feld
|
||||
var dmToggle = form.querySelector('[data-toggle-dm]');
|
||||
var dmField = form.querySelector('.activity-dm');
|
||||
dmToggle.addEventListener('change', function () { dmField.hidden = !dmToggle.checked; });
|
||||
|
||||
function out(name) { return form.querySelector('[data-out="' + name + '"]'); }
|
||||
|
||||
// Discord-Formatierung grob nachbilden: **fett**, *kursiv*, Zeilenumbrueche (Text sicher als Text)
|
||||
function discordText(text) {
|
||||
var div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML
|
||||
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
|
||||
.replace(/(^|[^*])\*([^*\n]+)\*/g, '$1<em>$2</em>')
|
||||
.replace(/\n/g, '<br>');
|
||||
}
|
||||
|
||||
function color() {
|
||||
var custom = f.color_custom.value;
|
||||
var picked = form.querySelector('input[name="color"]:checked');
|
||||
return custom && custom.toLowerCase() !== '#c9a227' ? custom : (picked ? picked.value : '#c9a227');
|
||||
}
|
||||
|
||||
function update() {
|
||||
out('title').textContent = f.title.value || 'Aktivitätscheck';
|
||||
out('message').innerHTML = discordText(f.message.value);
|
||||
out('embed').style.borderLeftColor = color();
|
||||
|
||||
var role = f.target_role_id.options[f.target_role_id.selectedIndex];
|
||||
out('role').textContent = role && role.value ? role.textContent.replace(/^@/, '') : 'Rolle';
|
||||
out('ping').hidden = !f.ping_role.checked;
|
||||
|
||||
out('yes').textContent = f.yes_label.value.trim() || 'Ich bin da';
|
||||
out('no').textContent = f.no_label.value.trim() || 'Ich bin nicht da';
|
||||
|
||||
var value = Math.max(1, parseInt(f.duration_value.value, 10) || 1);
|
||||
var ms = value * (f.duration_unit.value === 'hours' ? 3600e3 : 86400e3);
|
||||
var end = new Date(Date.now() + ms);
|
||||
out('deadline').textContent = end.toLocaleString('de-DE', { weekday: 'long', day: '2-digit', month: 'long', hour: '2-digit', minute: '2-digit' })
|
||||
+ ' (in ' + value + (f.duration_unit.value === 'hours' ? (value === 1 ? ' Stunde' : ' Stunden') : (value === 1 ? ' Tag' : ' Tagen')) + ')';
|
||||
|
||||
var image = f.image_url.value.trim();
|
||||
var img = out('image');
|
||||
if (/^https:\/\/\S+$/.test(image)) {
|
||||
img.src = image;
|
||||
img.hidden = false;
|
||||
} else {
|
||||
img.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
form.addEventListener('input', update);
|
||||
form.addEventListener('change', update);
|
||||
// Eigene Farbe gewaehlt -> Auswahlkreise abwaehlen, Kreis gewaehlt -> eigene Farbe zuruecksetzen
|
||||
f.color_custom.addEventListener('input', function () {
|
||||
form.querySelectorAll('input[name="color"]').forEach(function (r) { r.checked = false; });
|
||||
});
|
||||
form.querySelectorAll('input[name="color"]').forEach(function (radio) {
|
||||
radio.addEventListener('change', function () { f.color_custom.value = '#c9a227'; });
|
||||
});
|
||||
|
||||
form.addEventListener('submit', function (event) {
|
||||
var consequences = [];
|
||||
if (dmToggle.checked) consequences.push('PN');
|
||||
if (f.remove_role_id.value) consequences.push('Rolle entfernen');
|
||||
if (f.add_role_id.value) consequences.push('Rolle geben');
|
||||
var text = 'Check jetzt im Discord posten?\n\nFolgen ohne Rückmeldung: ' + (consequences.length ? consequences.join(', ') : 'keine (nur Liste im Log-Kanal)');
|
||||
if (!window.confirm(text)) event.preventDefault();
|
||||
});
|
||||
|
||||
update();
|
||||
})();
|
||||
|
|
@ -6,7 +6,8 @@
|
|||
* name - der Text selbst wird gesendet (freie Eingabe erlaubt, z.B. neue Gegenstaende)
|
||||
* id - ein verstecktes Feld bekommt die ID; nur Eintraege aus der Liste sind gueltig
|
||||
* submit - wie name, schickt nach der Auswahl das Formular ab (Suche im Verlauf)
|
||||
* Optional data-picker-empty: Text, wenn nichts passt.
|
||||
* Optional data-picker-empty: Text, wenn nichts passt; data-picker-invalid: Meldung ohne Auswahl;
|
||||
* data-picker-round: runde Bilder (Avatare).
|
||||
* Von aussen: element.itemPicker.set(idOderName) und element.itemPicker.refresh().
|
||||
*/
|
||||
(function () {
|
||||
|
|
@ -67,11 +68,14 @@
|
|||
var iconSlot = root.querySelector('.item-picker-icon');
|
||||
var searchIcon = iconSlot ? iconSlot.innerHTML : '';
|
||||
var emptyText = root.dataset.pickerEmpty || 'Kein Gegenstand gefunden.';
|
||||
var invalidText = root.dataset.pickerInvalid || 'Bitte einen Gegenstand aus der Liste wählen.';
|
||||
|
||||
var list = document.createElement('ul');
|
||||
list.className = 'item-picker-list';
|
||||
list.id = (input.id || 'item-picker-' + Math.random().toString(36).slice(2)) + '-list';
|
||||
list.setAttribute('role', 'listbox');
|
||||
// Personen (Avatare) rund statt eckiger Gegenstandsbilder
|
||||
if (root.hasAttribute('data-picker-round')) list.classList.add('item-picker-round');
|
||||
list.hidden = true;
|
||||
document.body.appendChild(list);
|
||||
|
||||
|
|
@ -113,7 +117,7 @@
|
|||
hidden.dataset.max = item && item.qty != null ? item.qty : '';
|
||||
hidden.dispatchEvent(new Event('change'));
|
||||
}
|
||||
input.setCustomValidity(id || !input.required ? '' : 'Bitte einen Gegenstand aus der Liste wählen.');
|
||||
input.setCustomValidity(id || !input.required ? '' : invalidText);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,14 @@
|
|||
if (title) replaceSelection('', '', '[[' + title.trim() + ']]');
|
||||
} else if (btn.dataset.insert === 'image') {
|
||||
imageInput.click();
|
||||
} else if (btn.dataset.insert === 'video') {
|
||||
var video = window.prompt('Link zum Video - YouTube, Twitch (Clip oder Video), Vimeo oder eine Videodatei (.mp4/.webm):', 'https://');
|
||||
if (video && /^https?:\/\/\S+$/.test(video.trim())) {
|
||||
// Allein in einer Zeile wird der Link zum eingebetteten Player
|
||||
insertBlock(video.trim());
|
||||
} else if (video && video.trim() !== 'https://') {
|
||||
window.alert('Das sieht nicht nach einem Link aus. Bitte die komplette Adresse einfügen (https://…).');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
36
includes/activity_api.php
Normal file
36
includes/activity_api.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/events_api.php';
|
||||
|
||||
/**
|
||||
* Aktivitaetschecks des Discord-Bots (/api/activity-checks, cogs/activity.py im Bot).
|
||||
* Der Bot postet die Nachricht mit den Buttons "Ich bin da" / "Ich bin nicht da", sammelt die
|
||||
* Antworten und fuehrt beim Abschluss die Folgen aus - die Website legt Checks an, zeigt sie an
|
||||
* und kann sie vorzeitig beenden.
|
||||
*
|
||||
* @param array<string, mixed> $queryParams
|
||||
* @param array<string, mixed>|null $jsonBody
|
||||
* @return array<string, mixed>
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
function activity_api_request(string $method, string $path = '', array $queryParams = [], ?array $jsonBody = null): array
|
||||
{
|
||||
$base = preg_replace('#/raids$#', '', raids_api_config()['url']);
|
||||
|
||||
return bot_api_request($method, $base . '/activity-checks' . $path, $queryParams, $jsonBody, 'Aktivitätscheck-API');
|
||||
}
|
||||
|
||||
/** Farben zur schnellen Auswahl (Discord-Embed-Farbe links am Rand). */
|
||||
const ACTIVITY_COLORS = [
|
||||
'#c9a227' => 'Gold',
|
||||
'#5865f2' => 'Blurple',
|
||||
'#3ba55d' => 'Grün',
|
||||
'#ed4245' => 'Rot',
|
||||
'#f0b232' => 'Orange',
|
||||
'#9b59b6' => 'Lila',
|
||||
'#1abc9c' => 'Türkis',
|
||||
];
|
||||
|
||||
const ACTIVITY_DEFAULT_DM = 'Hallo {name}! Du hast dich beim Aktivitätscheck **{titel}** auf **{server}** nicht zurückgemeldet. '
|
||||
. 'Melde dich bitte bei der Gildenleitung, wenn du weiterhin dabei sein möchtest.';
|
||||
|
|
@ -14,6 +14,7 @@ $canManageRoles = $currentUser && user_has_permission('roles.manage');
|
|||
$canViewRaids = $currentUser && user_has_permission('raids.view');
|
||||
$canViewPremades = $currentUser && user_has_permission('premades.view');
|
||||
$canViewEvents = $currentUser && user_has_permission('events.view');
|
||||
$canManageActivity = $currentUser && user_has_permission('activity.manage');
|
||||
$canViewMap = $currentUser && user_has_permission('map.view');
|
||||
$canViewWarehouse = $currentUser && user_has_permission('warehouse.view');
|
||||
$canViewContributions = $currentUser && user_has_permission('contributions.view');
|
||||
|
|
@ -64,6 +65,7 @@ $isRaidsActive = $currentScript === 'raids.php';
|
|||
$isPremadesActive = $currentScript === 'premades.php';
|
||||
$isEventsActive = $currentScript === 'events.php';
|
||||
$isCalendarActive = $currentScript === 'calendar.php';
|
||||
$isActivityActive = $currentScript === 'activity.php';
|
||||
$isMapActive = $currentScript === 'map.php';
|
||||
$isWarehouseActive = $currentScript === 'warehouse.php';
|
||||
$isContributionsActive = in_array($currentScript, ['contributions.php', 'contributions_award.php'], true);
|
||||
|
|
@ -85,6 +87,7 @@ $pageBackgrounds = [
|
|||
'premades.php' => 'bg-premades',
|
||||
'events.php' => 'bg-events',
|
||||
'calendar.php' => 'bg-events',
|
||||
'activity.php' => 'bg-events',
|
||||
'map.php' => 'bg-map',
|
||||
'warehouse.php' => 'bg-warehouse',
|
||||
'contributions.php' => 'bg-contributions',
|
||||
|
|
@ -224,6 +227,11 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
|||
<?= icon('bell') ?><span class="label">Events</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canManageActivity): ?>
|
||||
<a href="/activity.php" class="sidebar-link<?= $isActivityActive ? ' active' : '' ?>" title="Aktivitätscheck">
|
||||
<?= icon('check') ?><span class="label">Aktivitätscheck</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewMap): ?>
|
||||
<a href="/map.php" class="sidebar-link<?= $isMapActive ? ' active' : '' ?>" title="Karte">
|
||||
<?= icon('map') ?><span class="label">Karte</span>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ const CORE_PERMISSIONS = [
|
|||
['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' => 'activity.manage', 'description' => 'Aktivitätschecks im Discord starten, ansehen und beenden (inkl. Folgen wie PN und Rollenänderung)'],
|
||||
['key' => 'map.view', 'description' => 'Interaktive Karte und Taktiken ansehen'],
|
||||
['key' => 'map.tactics', 'description' => 'Taktiken auf der Karte anlegen, zeichnen und bearbeiten'],
|
||||
['key' => 'warehouse.view', 'description' => 'Lagerhaus: Bestand und Verlauf einsehen'],
|
||||
|
|
|
|||
|
|
@ -190,6 +190,76 @@ function wiki_safe_url(string $url, bool $image = false): ?string
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Video zum Einbetten, wenn die Zeile nur aus einem Video-Link besteht: YouTube (auch Shorts,
|
||||
* youtu.be, Startzeit ?t=), Twitch (Clips und Videos), Vimeo oder eine Videodatei (.mp4/.webm).
|
||||
* Eingebettet wird nur ueber feste Player-Adressen - die ID wird streng geprueft, der Rest der
|
||||
* Adresse nie uebernommen.
|
||||
*/
|
||||
function wiki_video_embed(string $line): ?string
|
||||
{
|
||||
$url = trim($line);
|
||||
if (!preg_match('#^https?://\S+$#i', $url)) {
|
||||
return null;
|
||||
}
|
||||
$parts = parse_url($url);
|
||||
$host = strtolower(preg_replace('/^(www\.|m\.)/', '', (string) ($parts['host'] ?? '')) ?? '');
|
||||
$path = (string) ($parts['path'] ?? '');
|
||||
parse_str((string) ($parts['query'] ?? ''), $query);
|
||||
$title = 'Video';
|
||||
$frame = static fn (string $src, string $class = '') => '<div class="wiki-video' . $class . '"><iframe src="' . e($src) . '" title="' . e($title)
|
||||
. '" loading="lazy" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen"'
|
||||
. ' allowfullscreen referrerpolicy="strict-origin-when-cross-origin"></iframe></div>';
|
||||
|
||||
// YouTube: watch?v=ID, youtu.be/ID, shorts/ID, embed/ID, live/ID
|
||||
$youtubeId = null;
|
||||
$isShort = false;
|
||||
if ($host === 'youtube.com' || $host === 'youtube-nocookie.com') {
|
||||
if ($path === '/watch' && isset($query['v'])) {
|
||||
$youtubeId = (string) $query['v'];
|
||||
} elseif (preg_match('#^/(shorts|embed|live)/([\w-]{11})#', $path, $m)) {
|
||||
$youtubeId = $m[2];
|
||||
$isShort = $m[1] === 'shorts';
|
||||
}
|
||||
} elseif ($host === 'youtu.be' && preg_match('#^/([\w-]{11})#', $path, $m)) {
|
||||
$youtubeId = $m[1];
|
||||
}
|
||||
if ($youtubeId !== null && preg_match('/^[\w-]{11}$/', $youtubeId)) {
|
||||
// Startzeit: ?t=90, ?t=1m30s oder ?start=90
|
||||
$start = 0;
|
||||
$t = (string) ($query['t'] ?? $query['start'] ?? '');
|
||||
if (preg_match('/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/', $t, $tm) && $t !== '') {
|
||||
$start = (int) ($tm[1] ?? 0) * 3600 + (int) ($tm[2] ?? 0) * 60 + (int) ($tm[3] ?? 0);
|
||||
}
|
||||
return $frame('https://www.youtube-nocookie.com/embed/' . $youtubeId . '?rel=0' . ($start > 0 ? '&start=' . $start : ''), $isShort ? ' wiki-video-portrait' : '');
|
||||
}
|
||||
|
||||
// Twitch braucht die eigene Domain als "parent"
|
||||
$parent = preg_replace('/:\d+$/', '', (string) ($_SERVER['HTTP_HOST'] ?? 'lumina-ascendes.de'));
|
||||
if ($host === 'clips.twitch.tv' && preg_match('#^/([\w-]+)$#', $path, $m)) {
|
||||
return $frame('https://clips.twitch.tv/embed?clip=' . $m[1] . '&parent=' . $parent . '&autoplay=false');
|
||||
}
|
||||
if ($host === 'twitch.tv') {
|
||||
if (preg_match('#^/[\w]+/clip/([\w-]+)$#', $path, $m)) {
|
||||
return $frame('https://clips.twitch.tv/embed?clip=' . $m[1] . '&parent=' . $parent . '&autoplay=false');
|
||||
}
|
||||
if (preg_match('#^/videos/(\d+)$#', $path, $m)) {
|
||||
return $frame('https://player.twitch.tv/?video=v' . $m[1] . '&parent=' . $parent . '&autoplay=false');
|
||||
}
|
||||
}
|
||||
|
||||
// Vimeo: vimeo.com/123456789
|
||||
if ($host === 'vimeo.com' && preg_match('#^/(\d+)$#', $path, $m)) {
|
||||
return $frame('https://player.vimeo.com/video/' . $m[1]);
|
||||
}
|
||||
|
||||
// Videodatei (z.B. auf Discord oder einem eigenen Server)
|
||||
if (preg_match('#\.(mp4|webm|mov)$#i', $path)) {
|
||||
return '<div class="wiki-video wiki-video-file"><video src="' . e($url) . '" controls preload="metadata" playsinline></video></div>';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Inline-Formatierung einer (bereits maskierten) Zeile. */
|
||||
function wiki_inline(string $html): string
|
||||
{
|
||||
|
|
@ -258,6 +328,7 @@ function wiki_anchor(string $text): string
|
|||
* ## Ueberschrift, ### Unterueberschrift - Liste / 1. nummerierte Liste
|
||||
* **fett**, *kursiv*, ~~durchgestrichen~~, `Code` > Hinweis-Kasten
|
||||
* [Text](https://...), [[Seitentitel]], 
|
||||
* Video-Link allein in einer Zeile (YouTube, Twitch, Vimeo, .mp4) -> eingebetteter Player
|
||||
* | Tabelle | mit | Spalten | (zweite Zeile | --- | macht die erste zur Kopfzeile)
|
||||
* --- Trennlinie
|
||||
*/
|
||||
|
|
@ -292,6 +363,14 @@ function wiki_render(string $text): string
|
|||
continue;
|
||||
}
|
||||
|
||||
// Video-Link allein in einer Zeile
|
||||
$video = wiki_video_embed($trim);
|
||||
if ($video !== null) {
|
||||
$out[] = $video;
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Tabelle: aufeinanderfolgende Zeilen, die mit | beginnen
|
||||
if ($trim[0] === '|') {
|
||||
$rows = [];
|
||||
|
|
@ -351,7 +430,7 @@ function wiki_render(string $text): string
|
|||
$para = [];
|
||||
while ($i < $n) {
|
||||
$t = trim($lines[$i]);
|
||||
if ($t === '' || $t[0] === '|' || $t[0] === '>' || preg_match('/^(#{1,4}\s|[-*]\s|\d+\.\s|-{3,}$)/', $t)) {
|
||||
if ($t === '' || $t[0] === '|' || $t[0] === '>' || preg_match('/^(#{1,4}\s|[-*]\s|\d+\.\s|-{3,}$)/', $t) || wiki_video_embed($t) !== null) {
|
||||
break;
|
||||
}
|
||||
$para[] = wiki_inline(e($t));
|
||||
|
|
|
|||
35
wiki.php
35
wiki.php
|
|
@ -57,11 +57,25 @@ $contributors = db()->query(
|
|||
$addableMembers = [];
|
||||
if ($canManage && !$page && $query === '') {
|
||||
$addableMembers = db()->query(
|
||||
"SELECT id, COALESCE(NULLIF(display_name, ''), username) AS name FROM users
|
||||
WHERE status = 'active' AND id NOT IN (SELECT user_id FROM wiki_contributors)
|
||||
"SELECT u.id, COALESCE(NULLIF(u.display_name, ''), u.username) AS name, u.avatar_filename, u.class_name,
|
||||
(SELECT COALESCE(NULLIF(r.display_name, ''), r.name) FROM user_roles ur JOIN roles r ON r.id = ur.role_id
|
||||
WHERE ur.user_id = u.id ORDER BY COALESCE(r.roster_order, 999), r.name LIMIT 1) AS top_role
|
||||
FROM users u
|
||||
WHERE u.status = 'active' AND u.id NOT IN (SELECT user_id FROM wiki_contributors)
|
||||
ORDER BY name"
|
||||
)->fetchAll();
|
||||
}
|
||||
// Fuer die Suchliste (assets/js/item-picker.js): Avatar, Name, Gruppe und Klasse
|
||||
$contributorPickerItems = [];
|
||||
foreach ($addableMembers as $member) {
|
||||
$contributorPickerItems[] = [
|
||||
'id' => (int) $member['id'],
|
||||
'name' => (string) $member['name'],
|
||||
'category' => trim(($member['top_role'] ?? 'Mitglied') . (!empty($member['class_name']) ? ' · ' . $member['class_name'] : '')),
|
||||
'icon' => !empty($member['avatar_filename']) ? '/assets/uploads/avatars/' . rawurlencode((string) $member['avatar_filename']) : null,
|
||||
'qty' => null,
|
||||
];
|
||||
}
|
||||
$pageCount = count($flat);
|
||||
|
||||
$pageTitle = $page ? $page['title'] . ' - Wiki' : 'Wiki';
|
||||
|
|
@ -278,14 +292,17 @@ $nameOf = static fn (array $u): string => $u['display_name'] !== '' ? $u['displa
|
|||
<form method="post" action="/wiki_action.php" class="wiki-contributor-add">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="contributor_add">
|
||||
<select name="user_id" required aria-label="Mitglied auswählen">
|
||||
<option value="">Mitglied auswählen …</option>
|
||||
<?php foreach ($addableMembers as $member): ?>
|
||||
<option value="<?= (int) $member['id'] ?>"><?= e($member['name']) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<button type="submit" class="button-small">Als Mitwirkende/n hinzufügen</button>
|
||||
<div class="item-picker" data-picker-items="wiki-contributor-list" data-picker-mode="id" data-picker-round data-picker-empty="Kein Mitglied gefunden." data-picker-invalid="Bitte ein Mitglied aus der Liste wählen.">
|
||||
<input type="hidden" name="user_id">
|
||||
<label class="search-field">
|
||||
<span class="item-picker-icon"><?= icon('search') ?></span>
|
||||
<input type="text" class="item-picker-input" id="wiki-contributor-search" required placeholder="Mitglied suchen …" aria-label="Mitglied auswählen">
|
||||
</label>
|
||||
</div>
|
||||
<button type="submit" class="button-small">+ Hinzufügen</button>
|
||||
</form>
|
||||
<script type="application/json" id="wiki-contributor-list"><?= json_encode($contributorPickerItems, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP) ?></script>
|
||||
<script src="<?= e(asset_url('/assets/js/item-picker.js')) ?>"></script>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<button type="button" data-insert="link" title="Link einfügen">Link</button>
|
||||
<button type="button" data-insert="wikilink" title="Link auf eine andere Wiki-Seite">Wiki-Link</button>
|
||||
<button type="button" data-insert="image" title="Bild hochladen">Bild</button>
|
||||
<button type="button" data-insert="video" title="Video einbetten (YouTube, Twitch, Vimeo oder .mp4-Link)">▶ Video</button>
|
||||
<input type="file" id="wiki-image-input" accept="image/png,image/jpeg,image/gif,image/webp" hidden>
|
||||
<span class="wiki-toolbar-spacer"></span>
|
||||
<button type="button" id="wiki-preview-toggle" class="wiki-preview-toggle" aria-pressed="false">Vorschau</button>
|
||||
|
|
@ -88,6 +89,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<code>[Text](https://…)</code><span>Link</span>
|
||||
<code>[[Sealed Dungeons]]</code><span>Link auf eine andere Wiki-Seite</span>
|
||||
<code></code><span>Bild (einfacher über den Knopf „Bild“)</span>
|
||||
<code>https://youtu.be/…</code><span>Video: Link zu YouTube, Twitch, Vimeo oder einer .mp4-Datei allein in eine Zeile (oder Knopf „Video“)</span>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue