Warehouse: Kina (the game currency) can be paid in and out, shown in its own box with the in-game coin icon (Icon_Currency_Coin_GoldNonbinding from the game client via aion2.app, since the wiki has none). It is a catalog item in the new "Währung" category, kept out of the item cards and totals, and allows up to a trillion per entry; warehouse_movements.quantity becomes BIGINT for that. A leftover "Kinah" entry is merged into "Kina". Beitragspunkte are renamed to Lumipunkte in every visible text, the coin is now lumipunkt.svg, and the schema sync also updates the descriptions of existing core permissions so the new name reaches the role editor. The sidebar, login page and mobile top bar show the new Lumina Ascendens logo, cropped and with its dark background made transparent. Scripts and the stylesheet are included with a ?v=<mtime> query (asset_url()), so browsers pick up new versions after an upload instead of running stale JavaScript - the cause of raid points not being saved. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
119 lines
5.4 KiB
PHP
119 lines
5.4 KiB
PHP
<?php
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
require_once __DIR__ . '/includes/contributions.php';
|
|
require_permission('contributions.manage');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
redirect('/contributions.php');
|
|
}
|
|
verify_csrf();
|
|
|
|
$action = (string) ($_POST['action'] ?? '');
|
|
$pdo = db();
|
|
|
|
/** Zurueck ins Formular, mit Fehlermeldung und den bisherigen Eingaben. */
|
|
function contribution_fail(string $message): void
|
|
{
|
|
$_SESSION['contribution_form'] = [
|
|
'category' => (string) ($_POST['category'] ?? ''),
|
|
'raid_id' => (string) ($_POST['raid_id'] ?? ''),
|
|
'title' => (string) ($_POST['title'] ?? ''),
|
|
'awarded_at' => (string) ($_POST['awarded_at'] ?? ''),
|
|
'points' => (string) ($_POST['points'] ?? ''),
|
|
'note' => (string) ($_POST['note'] ?? ''),
|
|
'users' => array_map('intval', (array) ($_POST['users'] ?? [])),
|
|
];
|
|
set_flash('error', $message);
|
|
redirect('/contributions_award.php');
|
|
}
|
|
|
|
switch ($action) {
|
|
// ---- Punkte vergeben ----
|
|
case 'create':
|
|
$category = (string) ($_POST['category'] ?? '');
|
|
if (!array_key_exists($category, CONTRIBUTION_CATEGORIES)) {
|
|
contribution_fail('Bitte einen Anlass auswählen.');
|
|
}
|
|
$title = trim((string) ($_POST['title'] ?? ''));
|
|
if ($title === '' || mb_strlen($title) > 150) {
|
|
contribution_fail('Bitte einen Grund mit höchstens 150 Zeichen angeben.');
|
|
}
|
|
$note = trim((string) ($_POST['note'] ?? ''));
|
|
if (mb_strlen($note) > 255) {
|
|
contribution_fail('Die Bemerkung darf höchstens 255 Zeichen lang sein.');
|
|
}
|
|
$points = filter_var($_POST['points'] ?? '', FILTER_VALIDATE_INT);
|
|
if ($points === false || $points === 0 || abs($points) > CONTRIBUTION_MAX_POINTS) {
|
|
contribution_fail('Bitte eine Punktzahl zwischen 1 und ' . number_format(CONTRIBUTION_MAX_POINTS, 0, ',', '.') . ' angeben (negativ für einen Abzug).');
|
|
}
|
|
$awardedAt = contribution_parse_time((string) ($_POST['awarded_at'] ?? ''));
|
|
if ($awardedAt === null) {
|
|
contribution_fail('Bitte ein gültiges Datum angeben (nicht in der Zukunft).');
|
|
}
|
|
$raidId = $category === 'raid' ? (int) ($_POST['raid_id'] ?? 0) : 0;
|
|
|
|
// Nur aktive Konten - doppelte oder unbekannte IDs fallen hier heraus.
|
|
$userIds = array_values(array_unique(array_filter(array_map('intval', (array) ($_POST['users'] ?? [])))));
|
|
if (!empty($userIds)) {
|
|
$placeholders = implode(',', array_fill(0, count($userIds), '?'));
|
|
$stmt = $pdo->prepare("SELECT id FROM users WHERE status = 'active' AND id IN ($placeholders)");
|
|
$stmt->execute($userIds);
|
|
$userIds = array_map('intval', $stmt->fetchAll(PDO::FETCH_COLUMN));
|
|
}
|
|
if (empty($userIds)) {
|
|
contribution_fail('Bitte mindestens ein Mitglied auswählen.');
|
|
}
|
|
|
|
$pdo->beginTransaction();
|
|
$pdo->prepare(
|
|
'INSERT INTO contribution_awards (category, title, note, raid_id, awarded_at, created_by) VALUES (?, ?, ?, ?, ?, ?)'
|
|
)->execute([$category, $title, $note !== '' ? $note : null, $raidId > 0 ? $raidId : null, $awardedAt, (int) current_user()['id']]);
|
|
$awardId = (int) $pdo->lastInsertId();
|
|
|
|
$insert = $pdo->prepare('INSERT INTO contribution_entries (award_id, user_id, points) VALUES (?, ?, ?)');
|
|
foreach ($userIds as $userId) {
|
|
$insert->execute([$awardId, $userId, $points]);
|
|
}
|
|
$pdo->commit();
|
|
|
|
$count = count($userIds);
|
|
$who = $count === 1 ? '1 Mitglied' : $count . ' Mitglieder';
|
|
set_flash('success', $points > 0
|
|
? contribution_format($points) . ' Lumipunkte an ' . $who . ' vergeben.'
|
|
: contribution_format(-$points) . ' Lumipunkte bei ' . $who . ' abgezogen.');
|
|
redirect('/contributions.php');
|
|
|
|
// ---- Ganze Vergabe loeschen ----
|
|
case 'delete_award':
|
|
$stmt = $pdo->prepare('DELETE FROM contribution_awards WHERE id = ?');
|
|
$stmt->execute([(int) ($_POST['award_id'] ?? 0)]);
|
|
set_flash($stmt->rowCount() > 0 ? 'success' : 'error', $stmt->rowCount() > 0 ? 'Vergabe gelöscht.' : 'Diese Vergabe gibt es nicht mehr.');
|
|
redirect('/contributions.php#verlauf');
|
|
|
|
// ---- Ein Mitglied aus einer Vergabe entfernen ----
|
|
case 'remove_entry':
|
|
$entryId = (int) ($_POST['entry_id'] ?? 0);
|
|
$stmt = $pdo->prepare('SELECT award_id FROM contribution_entries WHERE id = ?');
|
|
$stmt->execute([$entryId]);
|
|
$awardId = (int) $stmt->fetchColumn();
|
|
if ($awardId === 0) {
|
|
set_flash('error', 'Diesen Eintrag gibt es nicht mehr.');
|
|
redirect('/contributions.php#verlauf');
|
|
}
|
|
|
|
$pdo->beginTransaction();
|
|
$pdo->prepare('DELETE FROM contribution_entries WHERE id = ?')->execute([$entryId]);
|
|
// War es das letzte Mitglied, bliebe eine leere Vergabe uebrig - die faellt mit weg.
|
|
$left = $pdo->prepare('SELECT COUNT(*) FROM contribution_entries WHERE award_id = ?');
|
|
$left->execute([$awardId]);
|
|
if ((int) $left->fetchColumn() === 0) {
|
|
$pdo->prepare('DELETE FROM contribution_awards WHERE id = ?')->execute([$awardId]);
|
|
}
|
|
$pdo->commit();
|
|
|
|
set_flash('success', 'Mitglied aus der Vergabe entfernt.');
|
|
redirect('/contributions.php#verlauf');
|
|
|
|
default:
|
|
redirect('/contributions.php');
|
|
}
|