From 1c0109264a6faf05e87afd837f6329fd7cee37ce Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Sun, 27 Sep 2026 00:25:13 +0200 Subject: [PATCH] Premades: apply for a place in the group or on the reserve, leads accept or decline on the website MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- README.md | 19 +++ assets/css/style.css | 50 ++++++ assets/js/premades.js | 25 +++ datenschutz.php | 9 +- includes/account_deletion.php | 1 + includes/data_export.php | 5 + includes/data_reset.php | 8 + includes/header.php | 4 +- includes/legal.php | 2 +- includes/live_updates.php | 10 ++ includes/patchnotes.php | 10 ++ includes/premade_applications.php | 268 ++++++++++++++++++++++++++++++ includes/raids_api.php | 23 ++- includes/schema.php | 41 ++++- premade_action.php | 130 ++++++++++++++- premades.php | 195 +++++++++++++++++++++- sql/schema.sql | 37 +++++ 17 files changed, 822 insertions(+), 15 deletions(-) create mode 100644 includes/premade_applications.php diff --git a/README.md b/README.md index cb4ec1c..e13176f 100644 --- a/README.md +++ b/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 diff --git a/assets/css/style.css b/assets/css/style.css index 2def7f9..910ee05 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -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; diff --git a/assets/js/premades.js b/assets/js/premades.js index f4ce2d4..9046394 100644 --- a/assets/js/premades.js +++ b/assets/js/premades.js @@ -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'); diff --git a/datenschutz.php b/datenschutz.php index c6d5bcb..7a8da5c 100644 --- a/datenschutz.php +++ b/datenschutz.php @@ -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';