From d8ce29efc9980580ec84586a003d21ad6e6c12ac Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Sun, 27 Sep 2026 00:31:08 +0200 Subject: [PATCH] Premades: the leadership sees the apply button too, others decide on its own applications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Asked for: "füge ein, dass auch admins den bewerbenknopf bei den premaids sehen". Until now the button was hidden for everyone with premades.manage, since they can put anyone into a premade directly. - premades.php: the apply row shows for everyone who is not in the premade yet (the lead is), also below the list of open applications. A manager's list and the badge on the card leave out the own application. - premade_action.php: application_accept/_decline refuse the own application - the lead decides, for premades without a lead someone else from the leadership. - premade_applications_badge(): own applications don't count at the menu item "Premades". - README. Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +++- includes/premade_applications.php | 9 +++++++-- premade_action.php | 5 +++++ premades.php | 12 +++++++++--- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e13176f..a05c3ce 100644 --- a/README.md +++ b/README.md @@ -346,7 +346,9 @@ Platz in der Gruppe, sonst die Reserve; das vergibt der Bot (`premade_members.re - 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 + Reserve) steht „Bewerben“, auch für die Leitung - über deren eigene Bewerbung entscheidet der Lead bzw. jemand + anderes aus der Leitung (sie fehlt in ihrer Liste und Zahl, `premade_action.php` lehnt es ab, selbst zu + entscheiden). 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 diff --git a/includes/premade_applications.php b/includes/premade_applications.php index c535e9c..5df2612 100644 --- a/includes/premade_applications.php +++ b/includes/premade_applications.php @@ -220,7 +220,7 @@ function premade_applications_dissolved(int $premadeId): void /** * Offene Bewerbungen, ueber die jemand entscheidet: bei Premades, die er leitet - mit premades.manage auch bei Premades - * ohne Lead (Zahl am Menuepunkt "Premades"). + * ohne Lead (Zahl am Menuepunkt "Premades"). Die eigenen zaehlen nicht, ueber die entscheiden andere. */ function premade_applications_badge(?int $discordId, bool $canManage): int { @@ -236,8 +236,13 @@ function premade_applications_badge(?int $discordId, bool $canManage): int if (!$conditions) { return 0; } + $sql = "SELECT COUNT(*) FROM premade_applications WHERE status = 'open' AND (" . implode(' OR ', $conditions) . ')'; + if ($discordId !== null && $discordId > 0) { + $sql .= ' AND discord_id <> ?'; + $params[] = $discordId; + } try { - $stmt = db()->prepare("SELECT COUNT(*) FROM premade_applications WHERE status = 'open' AND (" . implode(' OR ', $conditions) . ')'); + $stmt = db()->prepare($sql); $stmt->execute($params); return (int) $stmt->fetchColumn(); } catch (PDOException $e) { diff --git a/premade_action.php b/premade_action.php index 5b85484..df23b85 100644 --- a/premade_action.php +++ b/premade_action.php @@ -484,6 +484,11 @@ try { redirect('/premades.php#premade-' . $premadeId); } $applicantId = (int) $application['discord_id']; + if ($applicantId === (int) $discordId) { + // Bewirbt sich die Leitung selbst, entscheidet der Lead bzw. jemand anderes aus der Leitung + set_flash('error', 'Über deine eigene Bewerbung entscheidet der Lead – bei Gruppen ohne Lead jemand anderes aus der Legionsleitung.'); + redirect('/premades.php#premade-' . $premadeId); + } $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') { diff --git a/premades.php b/premades.php index 3293b59..d280c0d 100644 --- a/premades.php +++ b/premades.php @@ -261,7 +261,10 @@ include __DIR__ . '/includes/header.php'; $reserveFree = $reserveCount < PREMADE_RESERVE_SLOTS; $banner = $banners[$premadeId] ?? null; $hasBanner = $banner !== null && $banner['url'] !== null; - $premadeApplications = $canManageThis ? ($openApplications[$premadeId] ?? []) : []; + // Offene Bewerbungen zum Entscheiden - ohne die eigene (bewirbt sich die Leitung selbst, entscheidet der + // Lead bzw. jemand anderes aus der Leitung) + $premadeApplications = $canManageThis ? array_values(array_filter($openApplications[$premadeId] ?? [], + static fn (array $application): bool => (int) $application['discord_id'] !== (int) $discordId)) : []; $applicationsClosed = isset($closedApplications[$premadeId]); ?>
@@ -475,9 +478,12 @@ include __DIR__ . '/includes/header.php';
- + + +