Premades: apply for a place in the group or on the reserve, leads accept or decline on the website
Asked for: "füge ein, dass man sich für premaids auch bewerben kann" - every premade with a free place takes
applications unless its lead switches them off, and the bot sends DMs (a new application to the lead, a decline
to the applicant). Later: "man soll sich auch auf reserveplätze bewerben können".
- includes/premade_applications.php: the applications live on the website (premade_applications: premade ID and
name, lead at that time, applicant, class, wished place group/reserve, message, status open/accepted/declined/
withdrawn/closed, reason, who decided when; premade_options.applications_open). Rules: one open application
per premade, at most 3 open in total, 7 days pause after a decline by the same premade, none while invited,
when full or switched off. premade_applications_sync() matches them with the bot: applications of dissolved
premades are closed, whoever is in the premade by now counts as accepted, name and lead stay current,
decisions expire after 30 days.
- premades.php: "Bewerben" under every other premade with a free place. The popup asks for the place (group or
reserve, taken places greyed out; the group is preselected unless it is full), the class (main preselected)
and an optional message. "Meine Bewerbungen" lists the own ones with the answer for 14 days, withdrawing
works there and on the card. Leads and the leadership (premades.manage) see open applications on the card,
also outside the edit mode, with a "Reserve" tag and a confirmation that names the place; their number shows
at the menu item "Premades" (premades without a lead count for the leadership). The edit mode switches
applications off and on.
- premade_action.php: apply (checks the rules and the chosen place again), withdraw, application_accept (the
bot puts the applicant on the wished place, on the other one if it was taken meanwhile; an open invitation
becomes the membership on its place), application_decline (optional reason), applications_toggle. An
invitation to someone with an open application carries its class, also when accepted in Discord.
Dissolving a premade closes its applications, a new lead takes over the open ones.
- includes/raids_api.php: add_premade_member() passes the wished place and returns the place the bot gave;
premade_free_slots().
- Bot (already deployed, with a backup): POST /api/premades/{id}/applications sends the DMs (to the lead with
place, class, message and a link to the card; to the applicant with the reason), POST /members with source
"application" tells the applicant where they ended up and, when the leadership accepted, the lead;
add_premade_member() takes the wished place. If the bot cannot send a DM, the application is stored anyway.
- Live updates of the page and the menu number, schema version 62 (tables also in sql/schema.sql).
- Privacy: privacy policy (what is stored, who sees it, for how long), data export section premade_bewerbungen,
account deletion, data reset area "Premade-Bewerbungen".
- Patch notes and README.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
785eab611e
commit
1c0109264a
17 changed files with 822 additions and 15 deletions
19
README.md
19
README.md
|
|
@ -345,6 +345,25 @@ Platz in der Gruppe, sonst die Reserve; das vergibt der Bot (`premade_members.re
|
|||
Popup mit der Klassenauswahl). Die Klasse steht unter dem Namen, auch in der Premade-Übersicht des Bots.
|
||||
- Beim Einladen einer Premade in einen Raid kommt ihre Reserve auf die Ersatzbank des Raids.
|
||||
- Das Dashboard zeigt alle eigenen Premades (die geleiteten zuerst).
|
||||
- **Bewerbungen** (`includes/premade_applications.php`): Unter jeder fremden Premade mit freiem Platz (Gruppe oder
|
||||
Reserve) steht „Bewerben“ - im Popup der Platz (Gruppe oder Reserve, nur freie wählbar), die Klasse (Main
|
||||
vorausgewählt) und eine Nachricht an den Lead (höchstens 500 Zeichen). Gespeichert auf der Website in
|
||||
`premade_applications` (Premade-ID und -Name, Lead zum Zeitpunkt, Bewerber, Klasse, gewünschter Platz, Nachricht,
|
||||
Status open/accepted/declined/withdrawn/closed, Begründung, wer wann entschieden hat). Grenzen: eine offene
|
||||
Bewerbung je Premade, höchstens 3 offene insgesamt, nach einer Absage bei derselben Premade 7 Tage Pause. Lead und
|
||||
Leitung (`premades.manage`) sehen offene Bewerbungen auf der Karte (auch ohne Bearbeiten-Modus) und als Zahl am
|
||||
Menüpunkt „Premades“ (bei Gruppen ohne Lead nur die Leitung), nehmen an (`add_premade_member` mit `source`
|
||||
`application` und `reserve`: der Bot trägt auf den gewünschten Platz ein, ist der inzwischen belegt auf den anderen,
|
||||
und meldet den Platz zurück; eine offene Einladung wird dabei zur Mitgliedschaft auf ihrem Platz) oder lehnen ab,
|
||||
auf Wunsch mit Begründung. Eine Einladung an jemanden mit offener Bewerbung trägt die Klasse aus der Bewerbung
|
||||
(`premade_application_class()`, gilt also auch beim Annehmen im Discord). Im Bearbeiten-Modus lassen sich Bewerbungen
|
||||
abschalten (`premade_options.applications_open`). „Meine Bewerbungen“ zeigt die eigenen samt Antwort (14 Tage),
|
||||
Zurückziehen geht dort und auf der Karte. `premade_applications_sync()` gleicht beim Anzeigen mit dem Bot ab:
|
||||
Bewerbungen aufgelöster Premades werden `closed`, wer inzwischen drin ist, gilt als angenommen, Name und Lead
|
||||
bleiben aktuell, Entscheidungen verfallen nach 30 Tagen. PNs verschickt der Bot: `POST /api/premades/{id}/applications`
|
||||
mit `event` `applied` (an den Lead, mit Knopf zur Website) bzw. `declined` (an den Bewerber, mit Begründung), bei
|
||||
`source` `application` an den Bewerber (und an den Lead, wenn die Leitung angenommen hat). Ein Bot ohne den
|
||||
Endpunkt ändert nichts an der Bewerbung, dann gibt es nur keine PN.
|
||||
|
||||
Neue Berechtigungen `premades.view` (Premades einsehen, eigene verwalten) und `premades.manage`
|
||||
(alle Premades verwalten, nicht nur die eigene) müssen bei einem vor diesem Update installierten
|
||||
|
|
|
|||
|
|
@ -1724,6 +1724,56 @@ body.lumina-dialog-open { overflow: hidden; }
|
|||
|
||||
.premade-invite-row:last-child { border-bottom: none; }
|
||||
|
||||
/* Bewerbungen (includes/premade_applications.php): Stand in "Meine Bewerbungen" */
|
||||
.premade-application-state { margin-top: 0.15rem; font-size: 0.88rem; color: var(--text-muted); }
|
||||
.premade-application-state.is-open { color: var(--gold); }
|
||||
.premade-application-state.is-accepted { color: var(--success); }
|
||||
.premade-application-state.is-declined { color: #f08a86; }
|
||||
|
||||
/* Unter der Aufstellung: Bewerben (fremde Premades) bzw. die offenen Bewerbungen (Lead und Leitung) */
|
||||
.premade-apply { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-top: 0.9rem; }
|
||||
.premade-applications { margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--border); }
|
||||
.premade-applications h3 { margin: 0 0 0.35rem; font-size: 1rem; }
|
||||
.premade-application { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
|
||||
.premade-application:last-child { border-bottom: 0; padding-bottom: 0; }
|
||||
.premade-application .avatar { flex-shrink: 0; }
|
||||
.premade-application-body { flex: 1; min-width: 12rem; }
|
||||
.premade-application-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.5rem; }
|
||||
/* Bewerbung fuer den Reserveplatz - wie das Reserve-Schild am Platz in der Aufstellung */
|
||||
.premade-application-reserve { padding: 0.05rem 0.45rem 0.1rem; border-radius: 6px; background: #4b5d78; color: #e8edf5; font-size: 0.65rem; font-weight: 700; line-height: 1.5; text-transform: uppercase; letter-spacing: 0.05em; }
|
||||
.premade-application-message { margin: 0.3rem 0 0; padding: 0.4rem 0.65rem; border-left: 2px solid rgba(201, 162, 39, 0.5); background: rgba(0, 0, 0, 0.2); font-size: 0.9rem; overflow-wrap: anywhere; }
|
||||
.premade-application-actions { display: flex; gap: 0.4rem; align-self: center; }
|
||||
.premade-applications-toggle { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; }
|
||||
.premade-applications-toggle .field-hint { flex: 1; min-width: 12rem; }
|
||||
.premade-apply-form { gap: 0.6rem; }
|
||||
.premade-apply-form label { margin-top: 0.2rem; }
|
||||
/* Am Handy passen beide Knoepfe nicht nebeneinander - dann untereinander in voller Breite */
|
||||
.premade-apply-form .actions { flex-wrap: wrap; }
|
||||
.premade-apply-form .actions button { flex: 1 1 auto; }
|
||||
/* Platz der Bewerbung: Gruppe oder Reserve als Schalter wie bei der Anwesenheit */
|
||||
.premade-apply-slot { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; margin: 0.2rem 0 0; padding: 0; border: 0; }
|
||||
.premade-apply-slot legend { margin-bottom: 0.35rem; padding: 0; font-weight: 600; font-size: 0.9rem; }
|
||||
.premade-apply-slot-options { display: flex; flex-wrap: wrap; gap: 0.4rem; }
|
||||
.premade-apply-form .premade-apply-slot-option {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
padding: 0.35rem 0.85rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 999px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
.premade-apply-slot-option input { position: absolute; opacity: 0; pointer-events: none; }
|
||||
.premade-apply-slot-option:hover { border-color: var(--text-muted); }
|
||||
.premade-apply-slot-option:has(input:checked) { border-color: var(--gold); background: rgba(201, 162, 39, 0.14); color: var(--gold); }
|
||||
.premade-apply-slot-option:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
|
||||
.premade-apply-slot-option:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
|
||||
.premade-apply-slot-option:has(input:disabled):hover { border-color: var(--border); }
|
||||
.premade-apply-slot-full { display: none; }
|
||||
.premade-apply-slot-option:has(input:disabled) .premade-apply-slot-full { display: inline; }
|
||||
|
||||
.premade-manage {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
|||
|
|
@ -218,6 +218,31 @@
|
|||
});
|
||||
});
|
||||
|
||||
// ---- Bewerben: Klasse und Nachricht an den Lead ----
|
||||
var applyModal = document.getElementById('premade-apply-modal');
|
||||
wireModal(applyModal);
|
||||
if (applyModal) {
|
||||
var applyCancel = applyModal.querySelector('.modal-cancel');
|
||||
if (applyCancel) applyCancel.addEventListener('click', function () { closeModal(applyModal); });
|
||||
}
|
||||
|
||||
document.querySelectorAll('.premade-apply-btn').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
if (!applyModal) return;
|
||||
document.getElementById('premade-apply-premade-id').value = btn.getAttribute('data-premade-id') || '';
|
||||
applyModal.querySelector('.premade-apply-name').textContent = btn.getAttribute('data-premade-name') || '';
|
||||
// Platz: nur freie sind waehlbar - vorausgewaehlt die Gruppe, ist sie voll die Reserve
|
||||
var groupFree = btn.getAttribute('data-group-free') !== '0';
|
||||
var reserveFree = btn.getAttribute('data-reserve-free') !== '0';
|
||||
applyModal.querySelectorAll('input[name="slot"]').forEach(function (radio) {
|
||||
radio.disabled = !(radio.value === 'reserve' ? reserveFree : groupFree);
|
||||
radio.checked = radio.value === (groupFree ? 'group' : 'reserve');
|
||||
});
|
||||
openModal(applyModal);
|
||||
document.getElementById('premade-apply-message').focus();
|
||||
});
|
||||
});
|
||||
|
||||
// ---- Klasse wechseln (Symbol im eigenen Platz) ----
|
||||
var classModal = document.getElementById('premade-class-modal');
|
||||
var classForm = document.getElementById('premade-class-form');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/data_export.php'; // Fristen der Download-Links
|
||||
require_once __DIR__ . '/includes/premade_applications.php'; // Speicherdauer der Bewerbungen
|
||||
|
||||
$operator = legal_operator();
|
||||
$complete = legal_complete();
|
||||
|
|
@ -198,7 +199,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<ul>
|
||||
<li><strong>Profil:</strong> Anzeigename, Klassen und Main-Klasse, Profiltext und -hintergrund, Profilbild, deine Charaktere (Name, Klasse, Stufe, Notiz, Bilder, Berufe mit Stufe und Hauptberuf, Sammel-Spezialisierung – die Berufe stehen auch in der Übersicht „Berufe“), Galeriebilder mit Beschreibung (und ob eins davon auf der Startseite gezeigt wird), Kommentare und Reaktionen sowie Gear-Sets, die du auf deinem Profil zeigst oder per Link bzw. Buildcode teilst – wer den Link oder Code hat, sieht das Set mit deinem Namen und kann es als eigenes übernehmen, solange du es teilst.</li>
|
||||
<li><strong>Aktivität:</strong> wann du dich zuletzt angemeldet hast und zuletzt aktiv warst (in der Mitgliederliste sichtbar), deine tägliche Lumipunkte-Belohnung, die Einführungstour, gelesene Patchnotes, wann du zuletzt in die Galerie und auf die Raid-Seite geschaut hast (für die Anzeige neuer Bilder und Raids) und die Reihenfolge deiner Menüpunkte.</li>
|
||||
<li><strong>Raids und Premades:</strong> deine Anmeldungen mit Klasse und Gruppe, deine Anwesenheit (anwesend, abwesend, entschuldigt) und die dafür vergebenen Lumipunkte; bei Raids, die du selbst anlegst, dass du ihr Raid-Lead bist (für alle sichtbar). Leitest du eine Premade, das Banner, das du für sie wählst oder hochlädst - eigene Bilder mit dem Vermerk, wer sie hochgeladen hat, und mit derselben Freigabe wie Galeriebilder.</li>
|
||||
<li><strong>Raids und Premades:</strong> deine Anmeldungen mit Klasse und Gruppe, deine Anwesenheit (anwesend, abwesend, entschuldigt) und die dafür vergebenen Lumipunkte; bei Raids, die du selbst anlegst, dass du ihr Raid-Lead bist (für alle sichtbar). Leitest du eine Premade, das Banner, das du für sie wählst oder hochlädst - eigene Bilder mit dem Vermerk, wer sie hochgeladen hat, und mit derselben Freigabe wie Galeriebilder. Bewirbst du dich bei einer Premade, die Klasse, den gewünschten Platz (Gruppe oder Reserve), deine Nachricht und die Antwort samt Begründung - das sehen du, der Lead der Premade und die Legionsleitung.</li>
|
||||
<li><strong>Lumipunkte und Lumishop:</strong> Punktevergaben und -abzüge, deine Shop-Anträge mit Bemerkung (z. B. Charaktername) und deren Bearbeitung.</li>
|
||||
<li><strong>Lagerhaus:</strong> Ein- und Auslagerungen mit dem Namen der Person, von der etwas kam oder die etwas bekommen hat.</li>
|
||||
<li><strong>Legionsbeiträge:</strong> in welchen Zeiträumen (Zyklen) du deinen Beitrag in Kina bezahlt hast und wer das wann abgehakt hat, ob du für einzelne Zyklen befreit bist (Zeitraum und ein Grund, den die Legionsleitung einträgt) und welche Zyklen für alle ausgesetzt wurden. Das sieht nur die Legionsleitung mit dem Recht dafür.</li>
|
||||
|
|
@ -227,7 +228,7 @@ include __DIR__ . '/includes/header.php';
|
|||
</p>
|
||||
<ul>
|
||||
<li><strong>Raids:</strong> Anmeldungen mit Discord-ID, Name, Klasse und Gruppe - meldest du dich ab, stehst du danach unter „Abgemeldet“, damit die Raidleitung die Absage sieht. Meldest du dich im Discord an, fragt der Bot bei der Website deine Main-Klasse ab (dort im Profil wählbar, sonst nimmt er deine Klassenrolle auf Discord) und ob du ein freigeschaltetes Konto hast - ohne gibt es keine Lumipunkte, darauf weist er dich hin. Zum Start eines Raids erinnert der Bot die Raidleitung per Direktnachricht daran, die Anwesenheit einzutragen.</li>
|
||||
<li><strong>Premades:</strong> Gruppen mit Gründer, Mitgliedern, deren Status, Platz (Reihenfolge in der Gruppe oder die Reserve) und Klasse. Die Klasse wählt die Website mit deiner Main-Klasse aus deinen Discord-Rollen vor; ändern kannst du sie jederzeit. Einladungen und Hinweise verschickt der Bot per Direktnachricht.</li>
|
||||
<li><strong>Premades:</strong> Gruppen mit Gründer, Mitgliedern, deren Status, Platz (Reihenfolge in der Gruppe oder die Reserve) und Klasse. Die Klasse wählt die Website mit deiner Main-Klasse aus deinen Discord-Rollen vor; ändern kannst du sie jederzeit. Einladungen und Hinweise verschickt der Bot per Direktnachricht - auch zu Bewerbungen: dem Lead deinen Namen, die Klasse, den gewünschten Platz und deine Nachricht, dir die Antwort. Die Bewerbungen selbst speichert nur die Website.</li>
|
||||
<li><strong>Events:</strong> geplante Erinnerungen samt Discord-ID der Person, die sie angelegt hat.</li>
|
||||
<li><strong>Meldungen über Spieler:</strong> gemeldete und meldende Person (Discord-ID und Name), Grund, Zeitpunkt, Beweis-Links und Punkte. Wer gemeldet hat, sieht nur die Legionsleitung. Meldungen löscht der Bot nach 10 Tagen automatisch.</li>
|
||||
<li><strong>Aktivitätschecks:</strong> wer auf einen Check geantwortet hat (Discord-ID, Name, Antwort, Zeitpunkt) und wer nicht.</li>
|
||||
|
|
@ -321,7 +322,8 @@ include __DIR__ . '/includes/header.php';
|
|||
<p>
|
||||
Dabei löschen wir dein Profil samt Profilbild und Profiltext, deine Charaktere, Galeriebilder (mit den
|
||||
Kommentaren darunter) und von dir hochgeladene Premade-Banner, Gear-Sets, privaten Taktiken, Gruppen und einzeln vergebenen Rechte, Terminteilnahmen,
|
||||
Befreiungen von den Legionsbeiträgen, Bilder an deinen Fehlermeldungen sowie deine Login- und Discord-Zugangsschlüssel.
|
||||
Bewerbungen für Premades, Befreiungen von den Legionsbeiträgen, Bilder an deinen Fehlermeldungen sowie deine Login- und
|
||||
Discord-Zugangsschlüssel.
|
||||
Was du zur Legion beigetragen hast - Kommentare, Reaktionen, Wiki-Bearbeitungen, öffentliche Taktiken, Termine,
|
||||
Lumipunkte, Shop-Anträge, Lagerhaus-Buchungen, bezahlte Legionsbeiträge, Raid-Anwesenheiten und Fehlermeldungen -
|
||||
bleibt erhalten, aber ohne deinen Namen,
|
||||
|
|
@ -348,6 +350,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<tr><td>Meldungen über Spieler im Discord-Bot</td><td>nach 10 Tagen</td></tr>
|
||||
<tr><td>Audit-Log</td><td>nach <?= AUDIT_LOG_KEEP_MONTHS ?> Monaten</td></tr>
|
||||
<tr><td>Raid-Anmeldungen, Premades und Aktivitätschecks im Discord-Bot</td><td>solange sie für die Organisation der Legion gebraucht werden, auf Wunsch sofort</td></tr>
|
||||
<tr><td>Bewerbungen für Premades</td><td><?= PREMADE_APPLICATION_KEEP_DAYS ?> Tage nach der Antwort bzw. dem Zurückziehen</td></tr>
|
||||
<tr><td>Konto und Inhalte im Mitgliederbereich</td><td><?= ACCOUNT_DELETION_DAYS ?> Tage nach dem Löschantrag (siehe oben)</td></tr>
|
||||
<tr><td>Download-Links für eine Datenauskunft</td><td>gültig <?= DATA_EXPORT_LINK_DAYS ?> Tage, Eintrag gelöscht <?= DATA_EXPORT_LINK_KEEP_DAYS ?> Tage nach Ablauf</td></tr>
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -273,6 +273,7 @@ function account_anonymize(int $userId, ?array $actor = null): void
|
|||
'DELETE FROM calendar_participants WHERE user_id = ?',
|
||||
'DELETE FROM data_export_links WHERE user_id = ?',
|
||||
'DELETE FROM dues_exemptions WHERE user_id = ?', // Befreiungen von Legionsbeitraegen - der Grund ist oft persoenlich
|
||||
'DELETE FROM premade_applications WHERE user_id = ?', // Bewerbungen fuer Premades samt Nachricht
|
||||
"DELETE FROM tactic_revisions WHERE owner_id = ? AND visibility = 'private'",
|
||||
"DELETE FROM tactics WHERE created_by = ? AND visibility = 'private'", // Schritte und Zeichnungen per CASCADE
|
||||
] as $sql) {
|
||||
|
|
|
|||
|
|
@ -204,6 +204,10 @@ function data_export_collect(int $userId): array
|
|||
),
|
||||
'lumipunkte' => ['summe' => array_sum(array_map('intval', array_column($points, 'points'))), 'verlauf' => $points],
|
||||
'shop_antraege' => data_export_strip(data_export_rows('SELECT * FROM shop_orders WHERE user_id = ? ORDER BY id', [$userId]), ['user_id', 'decided_by', 'delivered_by', 'award_id', 'warehouse_movement_id']),
|
||||
'premade_bewerbungen' => data_export_rows(
|
||||
'SELECT premade_name, class_name, IF(reserve, \'Reserve\', \'Gruppe\') AS platz, message, status, reason, created_at, decided_at FROM premade_applications WHERE user_id = ? ORDER BY created_at',
|
||||
[$userId]
|
||||
),
|
||||
'legionsbeitraege' => [
|
||||
'bezahlt' => data_export_rows(
|
||||
'SELECT c.starts_on AS zyklus_von, c.ends_on AS zyklus_bis, c.amount AS kina, e.updated_at AS abgehakt_am
|
||||
|
|
@ -378,6 +382,7 @@ function data_export_readme(array $export): string
|
|||
' kalender_* Termine, die du eingetragen hast, und deine Teilnahmen',
|
||||
' lumipunkte Punktestand und jede Vergabe bzw. jeder Abzug',
|
||||
' shop_antraege deine Anträge im Lumishop',
|
||||
' premade_bewerbungen deine Bewerbungen für Premades mit Klasse, Platz, Nachricht und Antwort',
|
||||
' legionsbeitraege Zyklen, in denen du deinen Legionsbeitrag (Kina) bezahlt hast, und Befreiungen davon',
|
||||
' lagerhaus Übergaben zwischen dir und der Legion',
|
||||
' raid_anwesenheit deine eingetragene Anwesenheit bei Raids',
|
||||
|
|
|
|||
|
|
@ -48,6 +48,14 @@ const DATA_RESET_AREAS = [
|
|||
'delete' => ['DELETE FROM warehouse_movements', "DELETE FROM warehouse_items WHERE source = 'custom'"],
|
||||
'reset_ids' => ['warehouse_movements'],
|
||||
],
|
||||
'premade_applications' => [
|
||||
'label' => 'Premade-Bewerbungen',
|
||||
'description' => 'Alle Bewerbungen für Premades und ob Leads sie abgeschaltet haben. Die Premades selbst liegen beim Bot und bleiben.',
|
||||
'count' => 'SELECT COUNT(*) FROM premade_applications',
|
||||
'unit' => ['Bewerbung', 'Bewerbungen'],
|
||||
'delete' => ['DELETE FROM premade_applications', 'DELETE FROM premade_options'],
|
||||
'reset_ids' => ['premade_applications'],
|
||||
],
|
||||
'dues' => [
|
||||
'label' => 'Legionsbeiträge',
|
||||
'description' => 'Alle Zyklen mit den abgehakten Zahlungen, ausgesetzte Zyklen und alle Befreiungen. Betrag und Rhythmus bleiben eingestellt - die Zyklen entstehen ab dem eingestellten Beginn neu.',
|
||||
|
|
|
|||
|
|
@ -277,8 +277,8 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => !i
|
|||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewPremades): ?>
|
||||
<a href="/premades.php" data-nav="/premades.php"<?= $navOrder('/premades.php') ?> class="sidebar-link<?= $isPremadesActive ? ' active' : '' ?>" title="Premades">
|
||||
<?= icon('shield') ?><span class="label">Premades</span>
|
||||
<a href="/premades.php" data-nav="/premades.php" data-badge="/premades.php"<?= $navOrder('/premades.php') ?> class="sidebar-link<?= $isPremadesActive ? ' active' : '' ?>" title="Premades">
|
||||
<?= icon('shield') ?><span class="label">Premades</span><?= nav_badge_html($navBadges, '/premades.php') ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewRaids || $canViewEvents): ?>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
// Stand der Datenschutzerklaerung - bei inhaltlichen Aenderungen an datenschutz.php mitziehen.
|
||||
const LEGAL_PRIVACY_UPDATED = '2026-09-26';
|
||||
const LEGAL_PRIVACY_UPDATED = '2026-09-27';
|
||||
|
||||
// Betreiber: ladungsfaehige Anschrift ueber den Impressum-Service Online-Impressum.de (Clear-Media UG,
|
||||
// nimmt Post an und leitet sie weiter; online-impressum.de/lumina-ascendes - die Seite dort heisst
|
||||
|
|
|
|||
|
|
@ -53,6 +53,14 @@ function nav_badges(array $user, string $currentScript, ?array $seen = null): ar
|
|||
$badges['/shop.php'] = $plain($count, 'Offene Anträge');
|
||||
}
|
||||
}
|
||||
// Offene Bewerbungen fuer die eigene(n) Premade(s) - mit premades.manage auch fuer Premades ohne Lead
|
||||
if (user_has_permission('premades.view')) {
|
||||
require_once __DIR__ . '/premade_applications.php';
|
||||
$count = premade_applications_badge(!empty($user['discord_id']) ? (int) $user['discord_id'] : null, user_has_permission('premades.manage'));
|
||||
if ($count > 0) {
|
||||
$badges['/premades.php'] = $plain($count, $count === 1 ? '1 offene Bewerbung' : $count . ' offene Bewerbungen');
|
||||
}
|
||||
}
|
||||
// Anstehende Raids (zwischengespeichert, includes/raids_api.php) - golden, solange seit dem letzten
|
||||
// Besuch der Raid-Seite einer gepostet wurde (wer nie dort war: die letzten 7 Tage)
|
||||
if (user_has_permission('raids.view')) {
|
||||
|
|
@ -322,6 +330,8 @@ function live_fingerprint_parts(string $path, array $params, int $userId): ?arra
|
|||
md5((string) json_encode(fetch_premades(3))),
|
||||
$sum('SELECT COUNT(*), ' . $crc('premade_id, banner, focus') . ' FROM premade_banners'),
|
||||
$sum('SELECT COUNT(*), ' . $crc('id, status') . ' FROM member_gallery WHERE premade_id IS NOT NULL'),
|
||||
$sum('SELECT COUNT(*), COALESCE(MAX(id), 0), ' . $crc('id, status') . ' FROM premade_applications'),
|
||||
$sum('SELECT COUNT(*), ' . $crc('premade_id, applications_open') . ' FROM premade_options'),
|
||||
];
|
||||
} catch (Throwable $e) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,16 @@ const PATCHNOTE_TYPES = [
|
|||
];
|
||||
|
||||
const PATCHNOTES = [
|
||||
[
|
||||
'id' => '2026-09-27-a',
|
||||
'date' => '2026-09-27',
|
||||
'title' => 'Bei Premades bewerben',
|
||||
'summary' => 'Du möchtest in eine Premade? Bewirb dich jetzt direkt bei ihr – für die Gruppe oder die Reserve. Der Lead bekommt deine Bewerbung per Discord-PN.',
|
||||
'changes' => [
|
||||
['type' => 'neu', 'area' => 'Premades', 'text' => 'Unter jeder Premade mit freiem Platz steht „Bewerben“: Wähle, ob du in die Gruppe oder auf die Reserve möchtest, dazu deine Klasse, und schreib dem Lead auf Wunsch ein paar Zeilen. Deine Bewerbung kommt beim Lead per Discord-PN an, die Antwort bekommst du ebenso – und unter „Meine Bewerbungen“ siehst du, was daraus geworden ist. Offene Bewerbungen kannst du jederzeit zurückziehen.'],
|
||||
['type' => 'neu', 'area' => 'Premades', 'text' => 'Für Leads: Offene Bewerbungen stehen auf deiner Premade-Karte und als Zahl am Menüpunkt „Premades“. Mit „Aufnehmen“ landet, wer sich beworben hat, direkt auf dem gewünschten Platz – in der Gruppe oder auf der Reserve. Beim Ablehnen kannst du eine Begründung mitschicken. Im Bearbeiten-Modus lassen sich Bewerbungen für deine Gruppe abschalten.'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => '2026-09-26-h',
|
||||
'date' => '2026-09-26',
|
||||
|
|
|
|||
268
includes/premade_applications.php
Normal file
268
includes/premade_applications.php
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Bewerbungen fuer Premades (premades.php, premade_action.php): Ein Mitglied bewirbt sich bei einer Premade, in der
|
||||
* noch ein Platz frei ist - fuer die Gruppe oder die Reserve, mit der Klasse, als die es mitspielen moechte, und auf
|
||||
* Wunsch einer kurzen Nachricht. Der Lead (bzw. die Leitung mit premades.manage) nimmt an oder lehnt ab, auf Wunsch
|
||||
* mit Begruendung. Leads koennen Bewerbungen fuer ihre Gruppe abschalten.
|
||||
*
|
||||
* Die Premades liegen beim Discord-Bot, die Bewerbungen hier (premade_applications, premade_options je Premade-ID).
|
||||
* Beim Annehmen traegt der Bot den Spieler auf den gewuenschten Platz ein (add_premade_member mit source
|
||||
* 'application'), und er verschickt die PNs: an den Lead bei einer neuen Bewerbung, an den Bewerber bei Annahme und
|
||||
* Ablehnung (premade_application_notify).
|
||||
*/
|
||||
|
||||
const PREMADE_APPLICATION_MESSAGE_MAX = 500;
|
||||
const PREMADE_APPLICATION_REASON_MAX = 500;
|
||||
// So viele offene Bewerbungen darf ein Mitglied gleichzeitig haben
|
||||
const PREMADE_APPLICATION_OPEN_MAX = 3;
|
||||
// Nach einer Absage bei derselben Premade erst nach so vielen Tagen wieder
|
||||
const PREMADE_APPLICATION_COOLDOWN_DAYS = 7;
|
||||
// "Meine Bewerbungen" zeigt Entscheidungen so lange, danach verfallen sie (steht so in der Datenschutzerklaerung)
|
||||
const PREMADE_APPLICATION_SHOW_DAYS = 14;
|
||||
const PREMADE_APPLICATION_KEEP_DAYS = 30;
|
||||
|
||||
/** Offene Bewerbungen aller Premades mit Name und Profilbild der Bewerber: [premade_id => [Zeile, …]], aelteste zuerst. */
|
||||
function premade_applications_open(): array
|
||||
{
|
||||
try {
|
||||
$rows = db()->query(
|
||||
"SELECT a.*, u.username, u.display_name, u.discord_username, u.avatar_filename
|
||||
FROM premade_applications a JOIN users u ON u.id = a.user_id
|
||||
WHERE a.status = 'open' ORDER BY a.created_at, a.id"
|
||||
)->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
return []; // Tabelle kommt erst mit dem naechsten Schema-Abgleich
|
||||
}
|
||||
$out = [];
|
||||
foreach ($rows as $row) {
|
||||
$row['name'] = premade_applicant_name($row);
|
||||
$out[(int) $row['premade_id']][] = $row;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/** Anzeigename eines Bewerbers aus einer Zeile mit display_name, discord_username und username (Tabelle users). */
|
||||
function premade_applicant_name(array $row): string
|
||||
{
|
||||
return (string) ((string) ($row['display_name'] ?? '') !== '' ? $row['display_name'] : (($row['discord_username'] ?? '') ?: ($row['username'] ?? '')));
|
||||
}
|
||||
|
||||
/** Bewerbungen eines Mitglieds: die offenen und die in den letzten PREMADE_APPLICATION_SHOW_DAYS entschiedenen, neueste zuerst. */
|
||||
function premade_applications_of(int $userId): array
|
||||
{
|
||||
try {
|
||||
$stmt = db()->prepare(
|
||||
"SELECT * FROM premade_applications
|
||||
WHERE user_id = ? AND (status = 'open' OR decided_at > ?)
|
||||
ORDER BY created_at DESC, id DESC"
|
||||
);
|
||||
$stmt->execute([$userId, date('Y-m-d H:i:s', time() - PREMADE_APPLICATION_SHOW_DAYS * 86400)]);
|
||||
return $stmt->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/** Premades, deren Lead gerade keine Bewerbungen annimmt: [premade_id => true]. */
|
||||
function premade_applications_closed(): array
|
||||
{
|
||||
try {
|
||||
$ids = db()->query('SELECT premade_id FROM premade_options WHERE applications_open = 0')->fetchAll(PDO::FETCH_COLUMN);
|
||||
} catch (PDOException $e) {
|
||||
return [];
|
||||
}
|
||||
return array_fill_keys(array_map('intval', $ids), true);
|
||||
}
|
||||
|
||||
/** Bewerbungen fuer eine Premade erlauben oder abschalten (offene bleiben zur Entscheidung stehen). */
|
||||
function premade_applications_set_open(int $premadeId, bool $open, int $userId): void
|
||||
{
|
||||
db()->prepare(
|
||||
'INSERT INTO premade_options (premade_id, applications_open, updated_by) VALUES (?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE applications_open = VALUES(applications_open), updated_by = VALUES(updated_by)'
|
||||
)->execute([$premadeId, $open ? 1 : 0, $userId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Warum sich ein Mitglied gerade nicht bei dieser Premade bewerben kann - null, wenn es geht, sonst [Kennung, Text]:
|
||||
* member (schon drin oder eingeladen), pending (Bewerbung offen), full, closed, cooldown (nach einer Absage) oder
|
||||
* limit (zu viele offene Bewerbungen). $mine = seine Bewerbungen (premade_applications_of).
|
||||
*
|
||||
* @return array{0: string, 1: string}|null
|
||||
*/
|
||||
function premade_application_blocker(array $premade, int $discordId, array $mine, bool $closed): ?array
|
||||
{
|
||||
$premadeId = (int) ($premade['id'] ?? 0);
|
||||
if (premade_has_user($premade, $discordId)) {
|
||||
return ['member', 'Du bist schon in dieser Premade oder eingeladen.'];
|
||||
}
|
||||
foreach ($mine as $row) {
|
||||
if ((int) $row['premade_id'] === $premadeId && $row['status'] === 'open') {
|
||||
return ['pending', 'Deine Bewerbung wartet noch auf eine Antwort.'];
|
||||
}
|
||||
}
|
||||
if (premade_is_full($premade)) {
|
||||
return ['full', 'Die Premade ist voll.'];
|
||||
}
|
||||
if ($closed) {
|
||||
return ['closed', 'Diese Premade nimmt gerade keine Bewerbungen an.'];
|
||||
}
|
||||
foreach ($mine as $row) {
|
||||
if ((int) $row['premade_id'] === $premadeId && $row['status'] === 'declined' && $row['decided_at'] !== null) {
|
||||
$until = (int) strtotime((string) $row['decided_at']) + PREMADE_APPLICATION_COOLDOWN_DAYS * 86400;
|
||||
if ($until > time()) {
|
||||
return ['cooldown', 'Nach der Absage kannst du dich hier ab dem ' . date('d.m.', $until) . ' wieder bewerben.'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$open = count(array_filter($mine, static fn (array $row): bool => $row['status'] === 'open'));
|
||||
if ($open >= PREMADE_APPLICATION_OPEN_MAX) {
|
||||
return ['limit', 'Du hast schon ' . $open . ' offene Bewerbungen – warte erst eine Antwort ab oder zieh eine zurück.'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Klasse aus der offenen Bewerbung eines Spielers (Discord-ID) bei dieser Premade - null ohne Bewerbung. */
|
||||
function premade_application_class(int $premadeId, int $discordId): ?string
|
||||
{
|
||||
try {
|
||||
$stmt = db()->prepare("SELECT class_name FROM premade_applications WHERE premade_id = ? AND discord_id = ? AND status = 'open' ORDER BY id DESC LIMIT 1");
|
||||
$stmt->execute([$premadeId, $discordId]);
|
||||
$class = (string) ($stmt->fetchColumn() ?: '');
|
||||
} catch (PDOException $e) {
|
||||
return null;
|
||||
}
|
||||
return in_array($class, AION_CLASSES, true) ? $class : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wohin das Annehmen einer Bewerbung fuehrt: true = Reserve, false = Gruppe, null = alles voll. Wer schon eingeladen
|
||||
* ist, behaelt den Platz der Einladung. Sonst gilt der Wunsch aus der Bewerbung - ist dieser Platz inzwischen belegt,
|
||||
* der andere (tauschen kann der Lead danach per Drag & Drop).
|
||||
*/
|
||||
function premade_application_target(array $premade, array $application): ?bool
|
||||
{
|
||||
$applicantId = (int) $application['discord_id'];
|
||||
if ((int) ($premade['owner_id'] ?? 0) === $applicantId) {
|
||||
return false;
|
||||
}
|
||||
foreach ($premade['members'] ?? [] as $member) {
|
||||
if ((int) ($member['user_id'] ?? 0) === $applicantId && in_array($member['status'] ?? '', ['accepted', 'pending'], true)) {
|
||||
return !empty($member['reserve']);
|
||||
}
|
||||
}
|
||||
[$groupFree, $reserveFree] = premade_free_slots($premade);
|
||||
if (!empty($application['reserve'])) {
|
||||
return $reserveFree ? true : ($groupFree ? false : null);
|
||||
}
|
||||
return $groupFree ? false : ($reserveFree ? true : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mit den Premades des Bots abgleichen (nur mit der vollstaendigen Liste aufrufen): Offene Bewerbungen bei aufgeloesten
|
||||
* Premades gelten als erledigt (status closed), ihre Einstellung faellt weg. Wer inzwischen in der Premade ist (z.B.
|
||||
* eine Einladung angenommen hat), dessen Bewerbung gilt als angenommen. Name und Lead jeder Bewerbung bleiben aktuell
|
||||
* (der Lead fuer die Zahl am Menuepunkt), und alte Entscheidungen verfallen.
|
||||
*
|
||||
* @param array<int, array<string, mixed>> $premades
|
||||
*/
|
||||
function premade_applications_sync(array $premades): void
|
||||
{
|
||||
$byId = [];
|
||||
foreach ($premades as $premade) {
|
||||
$byId[(int) ($premade['id'] ?? 0)] = $premade;
|
||||
}
|
||||
try {
|
||||
$pdo = db();
|
||||
$open = $pdo->query("SELECT id, premade_id, premade_name, discord_id, lead_discord_id FROM premade_applications WHERE status = 'open'")->fetchAll();
|
||||
$known = $pdo->query("SELECT premade_id FROM premade_applications WHERE status = 'open' UNION SELECT premade_id FROM premade_options")->fetchAll(PDO::FETCH_COLUMN);
|
||||
} catch (PDOException $e) {
|
||||
return;
|
||||
}
|
||||
foreach ($known as $premadeId) {
|
||||
if (!isset($byId[(int) $premadeId])) {
|
||||
premade_applications_dissolved((int) $premadeId);
|
||||
}
|
||||
}
|
||||
$accept = $pdo->prepare("UPDATE premade_applications SET status = 'accepted', decided_at = NOW() WHERE id = ? AND status = 'open'");
|
||||
$update = $pdo->prepare('UPDATE premade_applications SET premade_name = ?, lead_discord_id = ? WHERE id = ?');
|
||||
foreach ($open as $row) {
|
||||
$premade = $byId[(int) $row['premade_id']] ?? null;
|
||||
if ($premade === null) {
|
||||
continue;
|
||||
}
|
||||
if (premade_has_user($premade, (int) $row['discord_id'], false)) {
|
||||
$accept->execute([$row['id']]);
|
||||
continue;
|
||||
}
|
||||
$leadId = (int) ($premade['owner_id'] ?? 0) > 0 ? (string) (int) $premade['owner_id'] : null;
|
||||
$name = mb_substr((string) ($premade['name'] ?? ''), 0, 60);
|
||||
if ($name !== (string) $row['premade_name'] || $leadId !== ($row['lead_discord_id'] !== null ? (string) $row['lead_discord_id'] : null)) {
|
||||
$update->execute([$name, $leadId, $row['id']]);
|
||||
}
|
||||
}
|
||||
$pdo->prepare("DELETE FROM premade_applications WHERE status <> 'open' AND decided_at < ?")
|
||||
->execute([date('Y-m-d H:i:s', time() - PREMADE_APPLICATION_KEEP_DAYS * 86400)]);
|
||||
}
|
||||
|
||||
/** Premade aufgeloest: offene Bewerbungen sind erledigt (die Bewerber sehen es bei "Meine Bewerbungen"), die Einstellung faellt weg. */
|
||||
function premade_applications_dissolved(int $premadeId): void
|
||||
{
|
||||
try {
|
||||
db()->prepare("UPDATE premade_applications SET status = 'closed', decided_at = NOW() WHERE premade_id = ? AND status = 'open'")->execute([$premadeId]);
|
||||
db()->prepare('DELETE FROM premade_options WHERE premade_id = ?')->execute([$premadeId]);
|
||||
} catch (PDOException $e) {
|
||||
// Tabellen kommen erst mit dem naechsten Schema-Abgleich - dann gibt es auch nichts aufzuraeumen
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Offene Bewerbungen, ueber die jemand entscheidet: bei Premades, die er leitet - mit premades.manage auch bei Premades
|
||||
* ohne Lead (Zahl am Menuepunkt "Premades").
|
||||
*/
|
||||
function premade_applications_badge(?int $discordId, bool $canManage): int
|
||||
{
|
||||
$conditions = [];
|
||||
$params = [];
|
||||
if ($discordId !== null && $discordId > 0) {
|
||||
$conditions[] = 'lead_discord_id = ?';
|
||||
$params[] = $discordId;
|
||||
}
|
||||
if ($canManage) {
|
||||
$conditions[] = 'lead_discord_id IS NULL';
|
||||
}
|
||||
if (!$conditions) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
$stmt = db()->prepare("SELECT COUNT(*) FROM premade_applications WHERE status = 'open' AND (" . implode(' OR ', $conditions) . ')');
|
||||
$stmt->execute($params);
|
||||
return (int) $stmt->fetchColumn();
|
||||
} catch (PDOException $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PN ueber den Bot: 'applied' an den Lead, 'declined' an den Bewerber. Ein Bot ohne diese Schnittstelle (noch nicht
|
||||
* aktualisiert) oder ohne Verbindung aendert nichts an der Bewerbung - dann sieht man sie eben nur auf der Website.
|
||||
*/
|
||||
function premade_application_notify(int $premadeId, array $body): bool
|
||||
{
|
||||
try {
|
||||
premades_api_request('POST', '/' . $premadeId . '/applications', $body, 5);
|
||||
return true;
|
||||
} catch (Throwable $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Freitext aus dem Formular: Zeilenumbrueche bleiben (hoechstens einer am Stueck), sonst einfacher Leerraum. */
|
||||
function premade_application_text(mixed $value, int $max): string
|
||||
{
|
||||
$text = str_replace(["\r\n", "\r"], "\n", is_string($value) ? $value : '');
|
||||
$text = (string) preg_replace(['/[^\S\n]+/u', '/\n{2,}/'], [' ', "\n"], $text);
|
||||
return mb_substr(trim($text), 0, $max);
|
||||
}
|
||||
|
|
@ -599,16 +599,21 @@ function delete_premade(int $premadeId, string $reason = '', bool $byLeadership
|
|||
* $source sagt dem Bot, wem er noch Bescheid gibt: 'accept' (Einladung angenommen) bzw. 'assign'
|
||||
* (von der Leitung eingeteilt) - der Lead der Gruppe bekommt dann eine PN. $class waehlt die
|
||||
* Klasse vor (premade_default_class()); null laesst eine schon hinterlegte stehen. Der Bot vergibt
|
||||
* den Platz selbst: frei in der Gruppe, sonst die Reserve - sind beide voll, lehnt er ab.
|
||||
* den Platz selbst: frei in der Gruppe, sonst die Reserve - mit $reserve umgekehrt (Bewerbung fuer
|
||||
* die Reserve). Sind beide voll, lehnt er ab. Wer schon eingeladen ist, behaelt seinen Platz.
|
||||
*
|
||||
* @return bool|null der vergebene Platz (true = Reserve), null bei einem Bot, der ihn noch nicht meldet
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
function add_premade_member(int $premadeId, int $userId, string $status = 'accepted', bool $notify = false, ?string $source = null, ?int $actorId = null, ?string $class = null): void
|
||||
function add_premade_member(int $premadeId, int $userId, string $status = 'accepted', bool $notify = false, ?string $source = null, ?int $actorId = null, ?string $class = null, bool $reserve = false): ?bool
|
||||
{
|
||||
$body = ['user_id' => $userId, 'status' => $status, 'notify' => $notify, 'source' => $source, 'actor_id' => $actorId];
|
||||
if ($class !== null && $class !== '') {
|
||||
$body['class'] = $class;
|
||||
}
|
||||
if ($reserve) {
|
||||
$body['reserve'] = true;
|
||||
}
|
||||
if ($status === 'pending') {
|
||||
// Damit Annehmen/Ablehnen im Discord auch im Log-Kanal landet.
|
||||
try {
|
||||
|
|
@ -617,7 +622,8 @@ function add_premade_member(int $premadeId, int $userId, string $status = 'accep
|
|||
// ohne Log-Kanal geht es auch
|
||||
}
|
||||
}
|
||||
premades_api_request('POST', '/' . $premadeId . '/members', $body);
|
||||
$response = premades_api_request('POST', '/' . $premadeId . '/members', $body);
|
||||
return isset($response['reserve']) ? (bool) $response['reserve'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -783,6 +789,17 @@ function premade_is_full(array $premade): bool
|
|||
return $main >= PREMADE_MAIN_SLOTS && $reserve >= PREMADE_RESERVE_SLOTS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Welche Plaetze noch frei sind (offene Einladungen belegen ihren Platz): [Gruppe, Reserve].
|
||||
*
|
||||
* @return array{0: bool, 1: bool}
|
||||
*/
|
||||
function premade_free_slots(array $premade): array
|
||||
{
|
||||
[$main, $reserve] = premade_slot_counts($premade);
|
||||
return [$main < PREMADE_MAIN_SLOTS, $reserve < PREMADE_RESERVE_SLOTS];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $premades
|
||||
* @return array<int, array<string, mixed>> Alle Premades, bei denen der Nutzer eine offene
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
||||
const SCHEMA_VERSION = 61;
|
||||
const SCHEMA_VERSION = 62;
|
||||
|
||||
/**
|
||||
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
||||
|
|
@ -756,6 +756,45 @@ CREATE TABLE IF NOT EXISTS dues_entries (
|
|||
FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_dues_entries_user (user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
// Bewerbungen fuer Premades (includes/premade_applications.php)
|
||||
'premade_applications' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS premade_applications (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
-- ID der Premade beim Discord-Bot und ihr Name (fuer "Meine Bewerbungen", auch nach dem Aufloesen)
|
||||
premade_id INT UNSIGNED NOT NULL,
|
||||
premade_name VARCHAR(60) NOT NULL DEFAULT '',
|
||||
-- Discord-ID des Leads, der entscheidet (NULL = Gruppe ohne Lead: die Leitung) - fuer die Zahl am Menuepunkt
|
||||
lead_discord_id BIGINT UNSIGNED NULL,
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
discord_id BIGINT UNSIGNED NOT NULL,
|
||||
-- Klasse, als die der Bewerber mitspielen moechte, der gewuenschte Platz (1 = Reserve, 0 = Gruppe)
|
||||
-- und seine Nachricht an den Lead
|
||||
class_name VARCHAR(30) NULL,
|
||||
reserve TINYINT(1) NOT NULL DEFAULT 0,
|
||||
message VARCHAR(500) NULL,
|
||||
-- open = wartet, accepted = aufgenommen, declined = abgelehnt, withdrawn = zurueckgezogen, closed = Premade aufgeloest
|
||||
status ENUM('open', 'accepted', 'declined', 'withdrawn', 'closed') NOT NULL DEFAULT 'open',
|
||||
reason VARCHAR(500) NULL,
|
||||
decided_by INT UNSIGNED NULL,
|
||||
decided_at DATETIME NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (decided_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_premade_applications_premade (premade_id, status),
|
||||
INDEX idx_premade_applications_user (user_id, status),
|
||||
INDEX idx_premade_applications_lead (lead_discord_id, status)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
'premade_options' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS premade_options (
|
||||
premade_id INT UNSIGNED NOT NULL PRIMARY KEY,
|
||||
-- 0 = der Lead nimmt gerade keine Bewerbungen an
|
||||
applications_open TINYINT(1) NOT NULL DEFAULT 1,
|
||||
updated_by INT UNSIGNED NULL,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
'dues_exemptions' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS dues_exemptions (
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/raids_api.php';
|
||||
require_once __DIR__ . '/includes/premade_banner.php';
|
||||
require_once __DIR__ . '/includes/premade_applications.php';
|
||||
require_permission('premades.view');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
|
|
@ -135,6 +136,7 @@ try {
|
|||
}
|
||||
delete_premade($premadeId, $reason, $byLeadership, $discordId);
|
||||
premade_banner_remove($premadeId);
|
||||
premade_applications_dissolved($premadeId);
|
||||
$memberNames = [];
|
||||
foreach ($premade['members'] ?? [] as $m) {
|
||||
if ((int) ($m['user_id'] ?? 0) !== (int) ($premade['owner_id'] ?? 0)) {
|
||||
|
|
@ -164,9 +166,10 @@ try {
|
|||
set_flash('error', 'Die Premade ist voll (5 Plätze und die Reserve, inklusive offener Einladungen).');
|
||||
redirect('/premades.php');
|
||||
}
|
||||
// Mitglied sein kann man in mehreren Premades. Die Klasse ist die Main-Klasse laut Discord
|
||||
// vorausgewaehlt, den Platz (Gruppe, sonst Reserve) vergibt der Bot.
|
||||
$targetClass = premade_default_class($targetId);
|
||||
// Mitglied sein kann man in mehreren Premades. Die Klasse ist die aus einer offenen Bewerbung bei
|
||||
// dieser Premade, sonst die Main-Klasse laut Discord - so gilt sie auch, wenn die Einladung im
|
||||
// Discord angenommen wird. Den Platz (Gruppe, sonst Reserve) vergibt der Bot.
|
||||
$targetClass = premade_application_class($premadeId, $targetId) ?? premade_default_class($targetId);
|
||||
$toReserve = premade_slot_counts($premade)[0] >= PREMADE_MAIN_SLOTS;
|
||||
if ($canManage) {
|
||||
// Die Leitung teilt direkt ein. Der Spieler bekommt eine PN.
|
||||
|
|
@ -214,6 +217,8 @@ try {
|
|||
redirect('/premades.php');
|
||||
}
|
||||
transfer_premade_owner($premadeId, $newOwnerId, $allowMultipleLead);
|
||||
// Ueber offene Bewerbungen entscheidet ab jetzt der neue Lead (Zahl an seinem Menuepunkt)
|
||||
db()->prepare("UPDATE premade_applications SET lead_discord_id = ? WHERE premade_id = ? AND status = 'open'")->execute([$newOwnerId, $premadeId]);
|
||||
premade_admin_log($premade, $discordId, '🤝 Premade-Leitung übertragen (Leitung)', [
|
||||
'Bisher' => (int) ($premade['owner_id'] ?? 0) > 0 ? admin_log_discord($premade['owner_id'], (string) ($premade['owner_name'] ?? '')) : 'ohne Lead',
|
||||
'Neu' => admin_log_discord($newOwnerId),
|
||||
|
|
@ -390,7 +395,7 @@ try {
|
|||
|
||||
if ($action === 'accept') {
|
||||
// Mitglied sein kann man in mehreren Premades. Die Klasse nur vorauswaehlen, wenn beim
|
||||
// Einladen noch keine feststand - eine schon gewaehlte bleibt.
|
||||
// Einladen noch keine feststand - eine schon gewaehlte (auch die aus einer Bewerbung) bleibt.
|
||||
$myClass = null;
|
||||
foreach ($myPending as $invite) {
|
||||
if ((int) ($invite['id'] ?? 0) !== $premadeId) {
|
||||
|
|
@ -404,11 +409,128 @@ try {
|
|||
}
|
||||
add_premade_member($premadeId, $discordId, 'accepted', false, 'accept', $discordId,
|
||||
($myClass === null || $myClass === '') ? premade_default_class($discordId) : null);
|
||||
// Eine offene Bewerbung bei derselben Premade hat sich damit erledigt
|
||||
db()->prepare("UPDATE premade_applications SET status = 'accepted', decided_at = NOW() WHERE premade_id = ? AND user_id = ? AND status = 'open'")
|
||||
->execute([$premadeId, (int) $user['id']]);
|
||||
set_flash('success', 'Du bist der Premade beigetreten.');
|
||||
} else {
|
||||
remove_premade_member($premadeId, $discordId, 'decline', $discordId);
|
||||
set_flash('success', 'Einladung abgelehnt.');
|
||||
}
|
||||
} elseif ($action === 'apply') {
|
||||
// Bewerbung bei einer Premade (includes/premade_applications.php) - dieselben Regeln wie auf der Seite
|
||||
if (!$discordId) {
|
||||
set_flash('error', 'Verknüpfe zuerst deinen Discord-Account in „Mein Profil“ – Premades laufen über Discord.');
|
||||
redirect('/premades.php');
|
||||
}
|
||||
$premade = null;
|
||||
foreach (fetch_premades() as $candidate) {
|
||||
if ((int) ($candidate['id'] ?? 0) === $premadeId) {
|
||||
$premade = $candidate;
|
||||
}
|
||||
}
|
||||
if ($premade === null) {
|
||||
set_flash('error', 'Premade wurde nicht gefunden.');
|
||||
redirect('/premades.php');
|
||||
}
|
||||
$blocker = premade_application_blocker($premade, $discordId, premade_applications_of((int) $user['id']), isset(premade_applications_closed()[$premadeId]));
|
||||
if ($blocker !== null) {
|
||||
set_flash('error', $blocker[1]);
|
||||
redirect('/premades.php#premade-' . $premadeId);
|
||||
}
|
||||
// Der Platz, auf den man sich bewirbt: Gruppe oder Reserve - ohne Angabe der freie (die Gruppe zuerst)
|
||||
[$groupFree, $reserveFree] = premade_free_slots($premade);
|
||||
$slot = (string) ($_POST['slot'] ?? '');
|
||||
$wantsReserve = $slot === 'reserve' || ($slot !== 'group' && !$groupFree);
|
||||
if ($wantsReserve ? !$reserveFree : !$groupFree) {
|
||||
set_flash('error', $wantsReserve
|
||||
? 'Der Reserveplatz ist inzwischen belegt – bewirb dich für einen Platz in der Gruppe.'
|
||||
: 'In der Gruppe ist inzwischen kein Platz mehr frei – bewirb dich für den Reserveplatz.');
|
||||
redirect('/premades.php#premade-' . $premadeId);
|
||||
}
|
||||
$className = (string) ($_POST['class'] ?? '');
|
||||
$className = in_array($className, AION_CLASSES, true) ? $className : premade_default_class($discordId);
|
||||
$message = premade_application_text($_POST['message'] ?? '', PREMADE_APPLICATION_MESSAGE_MAX);
|
||||
$leadId = (int) ($premade['owner_id'] ?? 0);
|
||||
db()->prepare(
|
||||
'INSERT INTO premade_applications (premade_id, premade_name, lead_discord_id, user_id, discord_id, class_name, reserve, message)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
|
||||
)->execute([$premadeId, mb_substr((string) ($premade['name'] ?? ''), 0, 60), $leadId > 0 ? $leadId : null, (int) $user['id'],
|
||||
$discordId, $className, $wantsReserve ? 1 : 0, $message !== '' ? $message : null]);
|
||||
$notified = premade_application_notify($premadeId, [
|
||||
'event' => 'applied', 'user_id' => $discordId, 'class' => $className, 'reserve' => $wantsReserve,
|
||||
'message' => $message !== '' ? $message : null,
|
||||
]);
|
||||
set_flash('success', 'Deine Bewerbung ' . ($wantsReserve ? 'für den Reserveplatz ' : '') . 'bei „' . (string) ($premade['name'] ?? '') . '“ ist abgeschickt. '
|
||||
. ($leadId > 0 ? ($notified ? 'Der Lead bekommt sie per Discord-PN' : 'Der Lead sieht sie hier auf der Website') : 'Die Legionsleitung sieht sie hier auf der Website')
|
||||
. ' – die Antwort bekommst du per PN.');
|
||||
redirect('/premades.php#premade-' . $premadeId);
|
||||
} elseif ($action === 'withdraw') {
|
||||
$stmt = db()->prepare("UPDATE premade_applications SET status = 'withdrawn', decided_at = NOW() WHERE id = ? AND user_id = ? AND status = 'open'");
|
||||
$stmt->execute([(int) ($_POST['application_id'] ?? 0), (int) $user['id']]);
|
||||
set_flash($stmt->rowCount() > 0 ? 'success' : 'error', $stmt->rowCount() > 0 ? 'Bewerbung zurückgezogen.' : 'Diese Bewerbung ist nicht mehr offen.');
|
||||
} elseif ($action === 'application_accept' || $action === 'application_decline') {
|
||||
// Lead bzw. Leitung (premades.manage) entscheidet ueber eine offene Bewerbung
|
||||
$premade = require_premade_access(fetch_premades(), $premadeId, $discordId, $canManage);
|
||||
$stmt = db()->prepare(
|
||||
"SELECT a.*, u.username, u.display_name, u.discord_username
|
||||
FROM premade_applications a JOIN users u ON u.id = a.user_id
|
||||
WHERE a.id = ? AND a.premade_id = ? AND a.status = 'open'"
|
||||
);
|
||||
$stmt->execute([(int) ($_POST['application_id'] ?? 0), $premadeId]);
|
||||
$application = $stmt->fetch();
|
||||
if (!$application) {
|
||||
set_flash('error', 'Diese Bewerbung ist nicht mehr offen.');
|
||||
redirect('/premades.php#premade-' . $premadeId);
|
||||
}
|
||||
$applicantId = (int) $application['discord_id'];
|
||||
$applicantName = premade_applicant_name($application);
|
||||
$decide = db()->prepare("UPDATE premade_applications SET status = ?, reason = ?, decided_by = ?, decided_at = NOW() WHERE id = ? AND status = 'open'");
|
||||
if ($action === 'application_accept') {
|
||||
$wantsReserve = !empty($application['reserve']);
|
||||
$toReserve = premade_application_target($premade, $application);
|
||||
$note = '';
|
||||
if (!premade_has_user($premade, $applicantId, false)) {
|
||||
if ($toReserve === null) {
|
||||
set_flash('error', 'Die Premade ist voll – mach zuerst einen Platz frei (Gruppe oder Reserve).');
|
||||
redirect('/premades.php#premade-' . $premadeId);
|
||||
}
|
||||
$invited = premade_has_user($premade, $applicantId);
|
||||
// Der Bot traegt auf den gewuenschten Platz ein (ist der inzwischen belegt, auf den anderen) und schickt
|
||||
// dem Spieler eine PN - eine offene Einladung wird dabei zur Mitgliedschaft auf ihrem Platz
|
||||
$toReserve = add_premade_member($premadeId, $applicantId, 'accepted', false, 'application', $discordId,
|
||||
$application['class_name'] ?: null, $wantsReserve) ?? $toReserve;
|
||||
if (!$invited && $toReserve !== $wantsReserve) {
|
||||
$note = $toReserve ? ' In der Gruppe war kein Platz mehr frei.'
|
||||
: ' Die Reserve war schon besetzt – tauschen kannst du im Bearbeiten-Modus per Drag & Drop.';
|
||||
}
|
||||
}
|
||||
$decide->execute(['accepted', null, (int) $user['id'], (int) $application['id']]);
|
||||
premade_admin_log($premade, $discordId, '📝 Bewerbung für eine Premade angenommen (Leitung)', [
|
||||
'Spieler' => admin_log_discord($applicantId),
|
||||
'Platz' => $toReserve ? 'Reserve' : 'Gruppe',
|
||||
]);
|
||||
set_flash('success', 'Bewerbung angenommen – ' . $applicantName . ($toReserve ? ' steht jetzt auf der Reserve' : ' ist jetzt in der Gruppe')
|
||||
. ' und bekommt eine Discord-PN.' . $note);
|
||||
} else {
|
||||
$reason = premade_application_text($_POST['reason'] ?? '', PREMADE_APPLICATION_REASON_MAX);
|
||||
$decide->execute(['declined', $reason !== '' ? $reason : null, (int) $user['id'], (int) $application['id']]);
|
||||
$notified = premade_application_notify($premadeId, ['event' => 'declined', 'user_id' => $applicantId, 'reason' => $reason !== '' ? $reason : null]);
|
||||
premade_admin_log($premade, $discordId, '📝 Bewerbung für eine Premade abgelehnt (Leitung)', [
|
||||
'Spieler' => admin_log_discord($applicantId),
|
||||
'Begründung' => $reason,
|
||||
], 'warning');
|
||||
set_flash('success', 'Bewerbung abgelehnt' . ($notified ? ' – ' . $applicantName . ' bekommt eine Discord-PN.' : '.'));
|
||||
}
|
||||
redirect('/premades.php#premade-' . $premadeId);
|
||||
} elseif ($action === 'applications_toggle') {
|
||||
// Lead bzw. Leitung: Bewerbungen fuer die Gruppe erlauben oder abschalten (offene bleiben zur Entscheidung stehen)
|
||||
$premade = require_premade_access(fetch_premades(), $premadeId, $discordId, $canManage);
|
||||
$open = (string) ($_POST['open'] ?? '') === '1';
|
||||
premade_applications_set_open($premadeId, $open, (int) $user['id']);
|
||||
premade_admin_log($premade, $discordId, $open ? '📝 Bewerbungen für eine Premade wieder erlaubt (Leitung)' : '📝 Bewerbungen für eine Premade abgeschaltet (Leitung)');
|
||||
set_flash('success', $open ? 'Man kann sich wieder bei dieser Premade bewerben.' : 'Bei dieser Premade kann man sich jetzt nicht mehr bewerben. Offene Bewerbungen bleiben stehen.');
|
||||
redirect('/premades.php#premade-' . $premadeId);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
set_flash('error', 'Aktion fehlgeschlagen: ' . $e->getMessage());
|
||||
|
|
|
|||
195
premades.php
195
premades.php
|
|
@ -2,6 +2,7 @@
|
|||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/raids_api.php';
|
||||
require_once __DIR__ . '/includes/premade_banner.php';
|
||||
require_once __DIR__ . '/includes/premade_applications.php';
|
||||
require_permission('premades.view');
|
||||
|
||||
$user = current_user();
|
||||
|
|
@ -12,12 +13,17 @@ $premades = [];
|
|||
$apiError = null;
|
||||
try {
|
||||
$premades = fetch_premades();
|
||||
// Banner aufgeloester Premades aufraeumen, Namen fuer die Raid-Gruppen aktuell halten
|
||||
// Banner aufgeloester Premades aufraeumen, Namen fuer die Raid-Gruppen aktuell halten - ebenso die Bewerbungen
|
||||
premade_banners_sync($premades);
|
||||
premade_applications_sync($premades);
|
||||
} catch (Throwable $e) {
|
||||
$apiError = $e->getMessage();
|
||||
}
|
||||
$banners = premade_banners_all();
|
||||
// Bewerbungen (includes/premade_applications.php): offene je Premade fuer Lead und Leitung, die eigenen, abgeschaltete
|
||||
$openApplications = premade_applications_open();
|
||||
$myApplications = premade_applications_of((int) $user['id']);
|
||||
$closedApplications = premade_applications_closed();
|
||||
|
||||
// Klasse vorauswaehlen, wo noch keine feststeht (z.B. im Discord beigetreten): die Main-Klasse laut
|
||||
// Discord-Rollen. Das passiert einmal - danach steht sie in der Premade und laesst sich im eigenen
|
||||
|
|
@ -156,6 +162,46 @@ include __DIR__ . '/includes/header.php';
|
|||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($myApplications)): ?>
|
||||
<div class="panel">
|
||||
<h2>Meine Bewerbungen</h2>
|
||||
<?php foreach ($myApplications as $application): ?>
|
||||
<?php
|
||||
$applicationStatus = (string) $application['status'];
|
||||
$applicationState = match ($applicationStatus) {
|
||||
'open' => '⏳ Wartet auf eine Antwort',
|
||||
'accepted' => '✅ Angenommen – du bist dabei',
|
||||
'declined' => '❌ Abgelehnt' . ((string) ($application['reason'] ?? '') !== '' ? ': ' . $application['reason'] : ''),
|
||||
'withdrawn' => 'Zurückgezogen',
|
||||
default => 'Erledigt – die Premade wurde aufgelöst',
|
||||
};
|
||||
?>
|
||||
<div class="premade-invite-row">
|
||||
<div>
|
||||
Bewerbung bei
|
||||
<?php if (in_array($applicationStatus, ['open', 'accepted'], true)): ?>
|
||||
<a href="#premade-<?= (int) $application['premade_id'] ?>"><strong><?= e((string) $application['premade_name']) ?></strong></a>
|
||||
<?php else: ?>
|
||||
<strong><?= e((string) $application['premade_name']) ?></strong>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($application['class_name'])): ?><span class="text-muted">als <?= e((string) $application['class_name']) ?></span><?php endif; ?>
|
||||
<?php if (!empty($application['reserve'])): ?><span class="premade-application-reserve" title="Bewerbung für den Reserveplatz">Reserve</span><?php endif; ?>
|
||||
<span class="text-muted">· <?= e(date('d.m.', (int) strtotime((string) $application['created_at']))) ?></span>
|
||||
<div class="premade-application-state is-<?= e($applicationStatus) ?>"><?= e($applicationState) ?></div>
|
||||
</div>
|
||||
<?php if ($applicationStatus === 'open'): ?>
|
||||
<form method="post" action="/premade_action.php" class="inline-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="withdraw">
|
||||
<input type="hidden" name="application_id" value="<?= (int) $application['id'] ?>">
|
||||
<button type="submit" class="button-secondary button-small">Zurückziehen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
// Mitglieder gruenden fuer sich selbst, solange sie keine Premade leiten (mehrere nur mit
|
||||
// premades.lead_multiple). Die Leitung (premades.manage) gruendet beliebig viele Gruppen - ohne
|
||||
|
|
@ -212,8 +258,11 @@ include __DIR__ . '/includes/header.php';
|
|||
$candidateIds = $canManageThis ? premade_invite_candidates($premade, $inviteCandidates) : [];
|
||||
[$mainCount, $reserveCount] = premade_slot_counts($premade);
|
||||
$mainFree = $mainCount < PREMADE_MAIN_SLOTS;
|
||||
$reserveFree = $reserveCount < PREMADE_RESERVE_SLOTS;
|
||||
$banner = $banners[$premadeId] ?? null;
|
||||
$hasBanner = $banner !== null && $banner['url'] !== null;
|
||||
$premadeApplications = $canManageThis ? ($openApplications[$premadeId] ?? []) : [];
|
||||
$applicationsClosed = isset($closedApplications[$premadeId]);
|
||||
?>
|
||||
<div class="panel premade-panel<?= $hasBanner ? ' has-banner' : '' ?>" id="premade-<?= $premadeId ?>" data-premade-id="<?= $premadeId ?>">
|
||||
<?php if ($hasBanner): ?><div class="premade-banner" style="<?= premade_banner_style($banner) ?>"><?php endif; ?>
|
||||
|
|
@ -223,6 +272,9 @@ include __DIR__ . '/includes/header.php';
|
|||
<?php if ($canManageThis): ?>
|
||||
<button type="button" class="icon-button premade-edit-toggle" title="Premade bearbeiten" aria-pressed="false"><?= icon('edit') ?></button>
|
||||
<?php endif; ?>
|
||||
<?php if ($premadeApplications): ?>
|
||||
<a class="badge badge-pending" href="#premade-applications-<?= $premadeId ?>" title="Offene Bewerbungen – unten annehmen oder ablehnen">📝 <?= count($premadeApplications) ?> <?= count($premadeApplications) === 1 ? 'Bewerbung' : 'Bewerbungen' ?></a>
|
||||
<?php endif; ?>
|
||||
<?php if ($ownerId <= 0): ?><span class="badge" title="Diese Gruppe hat noch keinen Lead">Ohne Lead</span><?php endif; ?>
|
||||
<span class="badge"><?= $memberCount ?> <?= $memberCount === 1 ? 'Mitglied' : 'Mitglieder' ?></span>
|
||||
</div>
|
||||
|
|
@ -358,6 +410,100 @@ include __DIR__ . '/includes/header.php';
|
|||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($premadeApplications): ?>
|
||||
<?php // Offene Bewerbungen: Lead und Leitung sehen sie auch ohne Bearbeiten-Modus ?>
|
||||
<div class="premade-applications" id="premade-applications-<?= $premadeId ?>">
|
||||
<h3>📝 Bewerbungen</h3>
|
||||
<?php foreach ($premadeApplications as $application): ?>
|
||||
<?php
|
||||
$applicantId = (int) $application['discord_id'];
|
||||
$applicantName = (string) $application['name'];
|
||||
$applicantInvited = premade_has_user($premade, $applicantId);
|
||||
$applicantWantsReserve = !empty($application['reserve']);
|
||||
// Wohin "Aufnehmen" fuehrt: der gewuenschte Platz, ist der belegt der andere (null = alles voll)
|
||||
$applicantTarget = premade_application_target($premade, $application);
|
||||
$applicantBlocked = $applicantTarget === null;
|
||||
$applicantWhere = match (true) {
|
||||
$applicantTarget === true => ' kommt auf die Reserve' . (!$applicantInvited && !$applicantWantsReserve ? ' (die Gruppe ist voll)' : ''),
|
||||
$applicantTarget === false => ' kommt in die Gruppe' . (!$applicantInvited && $applicantWantsReserve ? ' (die Reserve ist schon besetzt)' : ''),
|
||||
default => '',
|
||||
};
|
||||
$applicationClass = (string) ($application['class_name'] ?? '');
|
||||
?>
|
||||
<div class="premade-application">
|
||||
<?= avatar_html(['id' => (int) $application['user_id'], 'display_name' => $applicantName, 'username' => $applicantName, 'avatar_filename' => $application['avatar_filename']], 36) ?>
|
||||
<div class="premade-application-body">
|
||||
<div class="premade-application-head">
|
||||
<strong><?= e($applicantName) ?></strong>
|
||||
<?php if ($applicationClass !== ''): ?>
|
||||
<span class="premade-slot-class">
|
||||
<?php if ($applicationClassIcon = class_icon_url($applicationClass)): ?><img class="premade-slot-class-icon" src="<?= e($applicationClassIcon) ?>" alt=""><?php endif; ?>
|
||||
<span class="text-muted"><?= e($applicationClass) ?></span>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<?php if ($applicantWantsReserve): ?>
|
||||
<span class="premade-application-reserve" title="Bewerbung für den Reserveplatz">Reserve</span>
|
||||
<?php endif; ?>
|
||||
<span class="text-muted">· <?= e(date('d.m. H:i', (int) strtotime((string) $application['created_at']))) ?></span>
|
||||
</div>
|
||||
<?php if ((string) ($application['message'] ?? '') !== ''): ?>
|
||||
<p class="premade-application-message"><?= nl2br(e((string) $application['message'])) ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="premade-application-actions">
|
||||
<form method="post" action="/premade_action.php" class="inline-form"
|
||||
data-confirm="<?= e($applicantName . $applicantWhere . ' und bekommt eine Discord-PN.') ?>"
|
||||
data-confirm-title="Bewerbung annehmen?" data-confirm-ok="Aufnehmen">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="application_accept">
|
||||
<input type="hidden" name="premade_id" value="<?= $premadeId ?>">
|
||||
<input type="hidden" name="application_id" value="<?= (int) $application['id'] ?>">
|
||||
<button type="submit" class="button-small"<?= $applicantBlocked ? ' disabled title="Die Premade ist voll – mach zuerst einen Platz frei"' : '' ?>>Aufnehmen</button>
|
||||
</form>
|
||||
<form method="post" action="/premade_action.php" class="inline-form"
|
||||
data-confirm="<?= e($applicantName . ' bekommt eine Discord-PN. Eine Begründung ist freiwillig – sie steht dann in der PN und bei „Meine Bewerbungen“.') ?>"
|
||||
data-confirm-title="Bewerbung ablehnen?" data-confirm-ok="Ablehnen" data-confirm-danger
|
||||
data-confirm-input="reason" data-confirm-placeholder="Begründung (optional)">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="application_decline">
|
||||
<input type="hidden" name="premade_id" value="<?= $premadeId ?>">
|
||||
<input type="hidden" name="application_id" value="<?= (int) $application['id'] ?>">
|
||||
<input type="hidden" name="reason" value="">
|
||||
<button type="submit" class="button-secondary button-small">Ablehnen</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php elseif (!$canManageThis && $discordId !== null && !premade_has_user($premade, $discordId)): ?>
|
||||
<?php
|
||||
// Bewerben: bei jeder Premade mit freiem Platz, solange der Lead es nicht abgeschaltet hat
|
||||
$applyBlocker = premade_application_blocker($premade, $discordId, $myApplications, $applicationsClosed);
|
||||
?>
|
||||
<div class="premade-apply">
|
||||
<?php if ($applyBlocker === null): ?>
|
||||
<?php // Gruppe oder Reserve waehlt man im Popup - nur freie Plaetze ?>
|
||||
<span class="text-muted"><?= $mainFree ? 'Du möchtest mitspielen?' : 'Die Gruppe ist voll – der Reserveplatz ist noch frei.' ?></span>
|
||||
<button type="button" class="button-secondary button-small premade-apply-btn" data-premade-id="<?= $premadeId ?>" data-premade-name="<?= e($premadeName) ?>"
|
||||
data-group-free="<?= $mainFree ? '1' : '0' ?>" data-reserve-free="<?= $reserveFree ? '1' : '0' ?>">📝 <?= $mainFree ? 'Bewerben' : 'Für die Reserve bewerben' ?></button>
|
||||
<?php elseif ($applyBlocker[0] === 'pending'): ?>
|
||||
<?php
|
||||
$myOpenApplication = array_values(array_filter($myApplications,
|
||||
static fn (array $row): bool => (int) $row['premade_id'] === $premadeId && $row['status'] === 'open'))[0];
|
||||
?>
|
||||
<span>⏳ Deine Bewerbung<?= !empty($myOpenApplication['reserve']) ? ' für den Reserveplatz' : '' ?> wartet auf eine Antwort.</span>
|
||||
<form method="post" action="/premade_action.php" class="inline-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="withdraw">
|
||||
<input type="hidden" name="application_id" value="<?= (int) $myOpenApplication['id'] ?>">
|
||||
<button type="submit" class="button-secondary button-small">Zurückziehen</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<span class="text-muted"><?= e($applyBlocker[1]) ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canManageThis): ?>
|
||||
<div class="premade-manage premade-edit-only">
|
||||
<p class="field-hint premade-drag-hint">Zieh Spieler zwischen Gruppe und Reserve hin und her (am Handy mit ⇅) - auf ein Mitglied gezogen, tauschen die beiden die Plätze. Die Reihenfolge in der Gruppe änderst du genauso oder mit den Pfeilen. Der Lead bleibt vorne.</p>
|
||||
|
|
@ -370,6 +516,17 @@ include __DIR__ . '/includes/header.php';
|
|||
<button type="submit" class="button-secondary">Umbenennen</button>
|
||||
</form>
|
||||
|
||||
<form method="post" action="/premade_action.php" class="premade-applications-toggle">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="applications_toggle">
|
||||
<input type="hidden" name="premade_id" value="<?= $premadeId ?>">
|
||||
<input type="hidden" name="open" value="<?= $applicationsClosed ? '1' : '0' ?>">
|
||||
<span class="field-hint"><?= $applicationsClosed
|
||||
? 'Bewerbungen sind abgeschaltet – gerade kann sich niemand bei dieser Premade bewerben.'
|
||||
: 'Mitglieder können sich bei dieser Premade bewerben, solange ein Platz frei ist.' ?></span>
|
||||
<button type="submit" class="button-secondary"><?= $applicationsClosed ? 'Bewerbungen erlauben' : 'Bewerbungen abschalten' ?></button>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
// Banner: eine der Landschaften oder ein eigenes Bild, dazu der Bildausschnitt
|
||||
$upload = premade_banner_upload($premadeId);
|
||||
|
|
@ -557,6 +714,42 @@ include __DIR__ . '/includes/header.php';
|
|||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Bewerbung bei einer Premade: Klasse und eine kurze Nachricht an den Lead -->
|
||||
<div id="premade-apply-modal" class="modal-overlay" hidden>
|
||||
<div class="modal">
|
||||
<button type="button" class="modal-close icon-button" title="Schließen"><?= icon('x') ?></button>
|
||||
<h2>Bei <span class="premade-apply-name"></span> bewerben</h2>
|
||||
<p class="text-muted">Der Lead bekommt deine Bewerbung per Discord-PN und nimmt sie hier an oder lehnt sie ab – die Antwort bekommst du ebenfalls per PN. Bei Gruppen ohne Lead entscheidet die Legionsleitung.</p>
|
||||
<form method="post" action="/premade_action.php" class="premade-apply-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="apply">
|
||||
<input type="hidden" name="premade_id" id="premade-apply-premade-id">
|
||||
<label for="premade-apply-class">Als Klasse</label>
|
||||
<select id="premade-apply-class" name="class">
|
||||
<?php $ownApplyClasses = user_classes(current_user()); ?>
|
||||
<?php foreach (class_options_for(current_user()) as $classOption): ?>
|
||||
<option value="<?= e($classOption) ?>"><?= e($classOption) ?><?= $classOption === ($ownApplyClasses[0] ?? null) ? ' (Main)' : '' ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php // Welche Plaetze frei sind, setzt assets/js/premades.js je Premade (belegte sind ausgegraut) ?>
|
||||
<fieldset class="premade-apply-slot">
|
||||
<legend>Platz</legend>
|
||||
<div class="premade-apply-slot-options">
|
||||
<label class="premade-apply-slot-option"><input type="radio" name="slot" value="group" checked> In der Gruppe<span class="premade-apply-slot-full"> · voll</span></label>
|
||||
<label class="premade-apply-slot-option"><input type="radio" name="slot" value="reserve"> Auf der Reserve<span class="premade-apply-slot-full"> · belegt</span></label>
|
||||
</div>
|
||||
<span class="field-hint">Die Reserve springt ein, wenn in der Gruppe jemand fehlt.</span>
|
||||
</fieldset>
|
||||
<label for="premade-apply-message">Nachricht an den Lead <span class="text-muted">(optional)</span></label>
|
||||
<textarea id="premade-apply-message" name="message" rows="3" maxlength="<?= PREMADE_APPLICATION_MESSAGE_MAX ?>" placeholder="z. B. wann du meistens spielst oder was du dir von der Gruppe wünschst"></textarea>
|
||||
<div class="actions">
|
||||
<button type="button" class="button-secondary modal-cancel">Abbrechen</button>
|
||||
<button type="submit">Bewerbung abschicken</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Gemeinsames Klassen-Popup - identisch zur Klassenauswahl bei der Raid-Anmeldung -->
|
||||
<div id="premade-class-modal" class="modal-overlay" hidden>
|
||||
<div class="modal">
|
||||
|
|
|
|||
|
|
@ -573,6 +573,43 @@ CREATE TABLE IF NOT EXISTS premade_banners (
|
|||
FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Bewerbungen fuer Premades (includes/premade_applications.php) - die Premades selbst liegen beim Discord-Bot
|
||||
CREATE TABLE IF NOT EXISTS premade_applications (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
-- ID der Premade beim Discord-Bot und ihr Name (fuer "Meine Bewerbungen", auch nach dem Aufloesen)
|
||||
premade_id INT UNSIGNED NOT NULL,
|
||||
premade_name VARCHAR(60) NOT NULL DEFAULT '',
|
||||
-- Discord-ID des Leads, der entscheidet (NULL = Gruppe ohne Lead: die Leitung) - fuer die Zahl am Menuepunkt
|
||||
lead_discord_id BIGINT UNSIGNED NULL,
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
discord_id BIGINT UNSIGNED NOT NULL,
|
||||
-- Klasse, als die der Bewerber mitspielen moechte, der gewuenschte Platz (1 = Reserve, 0 = Gruppe)
|
||||
-- und seine Nachricht an den Lead
|
||||
class_name VARCHAR(30) NULL,
|
||||
reserve TINYINT(1) NOT NULL DEFAULT 0,
|
||||
message VARCHAR(500) NULL,
|
||||
-- open = wartet, accepted = aufgenommen, declined = abgelehnt, withdrawn = zurueckgezogen, closed = Premade aufgeloest
|
||||
status ENUM('open', 'accepted', 'declined', 'withdrawn', 'closed') NOT NULL DEFAULT 'open',
|
||||
reason VARCHAR(500) NULL,
|
||||
decided_by INT UNSIGNED NULL,
|
||||
decided_at DATETIME NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (decided_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_premade_applications_premade (premade_id, status),
|
||||
INDEX idx_premade_applications_user (user_id, status),
|
||||
INDEX idx_premade_applications_lead (lead_discord_id, status)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Einstellungen der Premades, die auf der Website liegen: nimmt der Lead gerade Bewerbungen an?
|
||||
CREATE TABLE IF NOT EXISTS premade_options (
|
||||
premade_id INT UNSIGNED NOT NULL PRIMARY KEY,
|
||||
applications_open TINYINT(1) NOT NULL DEFAULT 1,
|
||||
updated_by INT UNSIGNED NULL,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Audit-Log, Tempolimits (Spam-Schutz) und Kommentare unter Galeriebildern
|
||||
CREATE TABLE IF NOT EXISTS audit_log (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
|
|
|
|||
Loading…
Reference in a new issue