LuminaWebsite/member_edit.php
Maaxxs 5dabbccbd7 Gear planner, dashboard polish, images on bug reports
Gear planner:
- Personal gear sets (18 slots) with enchant, exceed, soul imprint and manastones,
  stat totals by source and side-by-side comparison of 2-4 sets
- Sets can be shown on the own profile page (read-only for other members)
- Admin catalog: import items from aion2hub.com (Global client), compare stored
  values with the source one by one or all at once, at most one request per second
- New permissions gear.view (all with dashboard access) and gear.manage

Dashboard:
- Role badges ordered like the member list (roster_order)
- Stronger hover effect on "Rangliste & Verlauf" / "Zum Lumishop", no more blue
  hover on secondary buttons
- "Anstehende Raids" box links to the raids page, next raids link to the raid
  and to the calendar day
- Raid attendance only knows present/absent (old "excused" entries count as unset)

Bug reports:
- Up to 5 images per report, pasting copied images with Ctrl+V (also for the gallery)
- Images are only served to the reporter and bugs.manage via bug_image.php

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 09:27:09 +02:00

246 lines
14 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/member_profile.php';
require_permission('members.view');
$id = (int) ($_GET['id'] ?? current_user()['id']);
if (!profile_can_edit($id)) {
set_flash('error', 'Du darfst nur deine eigene Profilseite bearbeiten.');
redirect('/member.php?id=' . $id);
}
$stmt = db()->prepare("SELECT id, username, display_name, profile_bio, profile_background, gallery_comments_enabled, status FROM users WHERE id = ?");
$stmt->execute([$id]);
$member = $stmt->fetch();
if (!$member) {
redirect('/members.php');
}
$name = $member['display_name'] !== '' ? $member['display_name'] : $member['username'];
$isOwn = (int) current_user()['id'] === $id;
$characters = profile_characters_by_user($id)[$id] ?? [];
$galleryStmt = db()->prepare('SELECT * FROM member_gallery WHERE user_id = ? ORDER BY sort_order, id');
$galleryStmt->execute([$id]);
$gallery = $galleryStmt->fetchAll();
/** Felder eines Charakters (fuer "neu" und "bearbeiten" gleich). */
function character_fields(array $c, string $prefix): void
{
?>
<div class="character-form-grid">
<div>
<label for="<?= $prefix ?>-name">Name</label>
<input type="text" id="<?= $prefix ?>-name" name="name" maxlength="60" required value="<?= e((string) ($c['name'] ?? '')) ?>" placeholder="z.B. Damaskar">
</div>
<div>
<label for="<?= $prefix ?>-class">Klasse</label>
<select id="<?= $prefix ?>-class" name="class_name">
<option value="">– wählen –</option>
<?php foreach (AION_CLASSES as $class): ?>
<option value="<?= e($class) ?>"<?= ($c['class_name'] ?? '') === $class ? ' selected' : '' ?>><?= e($class) ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label for="<?= $prefix ?>-level">Stufe (optional)</label>
<input type="number" id="<?= $prefix ?>-level" name="level" min="1" max="999" value="<?= e((string) ($c['level'] ?? '')) ?>">
</div>
<label class="character-main-toggle">
<input type="checkbox" name="is_main" value="1"<?= !empty($c['is_main']) ? ' checked' : '' ?>> Hauptcharakter
</label>
</div>
<div>
<label for="<?= $prefix ?>-note">Kurzbeschreibung (optional)</label>
<input type="text" id="<?= $prefix ?>-note" name="note" maxlength="255" value="<?= e((string) ($c['note'] ?? '')) ?>" placeholder="z.B. Main für Raids, Twink zum Farmen">
</div>
<div class="character-form-grid">
<div>
<label for="<?= $prefix ?>-portrait">Portrait</label>
<?php if (!empty($c['portrait_filename'])): ?>
<div class="character-current-image">
<img src="<?= e(profile_image_url($c['portrait_filename'])) ?>" alt="">
<label><input type="checkbox" name="remove_portrait" value="1"> entfernen</label>
</div>
<?php endif; ?>
<input type="file" id="<?= $prefix ?>-portrait" name="portrait" accept="image/png,image/jpeg,image/gif,image/webp" data-max-size="600">
<div class="field-hint">Am besten ein quadratischer Ausschnitt des Gesichts.</div>
</div>
<div>
<label for="<?= $prefix ?>-image">Bild</label>
<?php if (!empty($c['image_filename'])): ?>
<div class="character-current-image">
<img src="<?= e(profile_image_url($c['image_filename'])) ?>" alt="">
<label><input type="checkbox" name="remove_image" value="1"> entfernen</label>
</div>
<?php endif; ?>
<input type="file" id="<?= $prefix ?>-image" name="image" accept="image/png,image/jpeg,image/gif,image/webp" data-max-size="1600">
<div class="field-hint">Z.B. ein Screenshot des ganzen Charakters in seiner Rüstung.</div>
</div>
</div>
<?php
}
$pageTitle = 'Profilseite bearbeiten';
include __DIR__ . '/includes/header.php';
?>
<div class="panel">
<div class="raid-header">
<h1><?= $isOwn ? 'Meine Profilseite' : 'Profilseite von ' . e($name) ?></h1>
<a class="button button-secondary button-small" href="/member.php?id=<?= $id ?>">Ansehen</a>
</div>
<p class="text-muted">Alles hier sehen die anderen Mitglieder der Legion auf deiner Profilseite.</p>
</div>
<form class="panel" method="post" action="/member_action.php">
<?= csrf_field() ?>
<input type="hidden" name="action" value="bio_save">
<input type="hidden" name="user_id" value="<?= $id ?>">
<h2>Über mich</h2>
<textarea name="profile_bio" rows="8" maxlength="<?= PROFILE_MAX_BIO ?>" placeholder="Erzähl etwas über dich: Wie lange spielst du schon Aion? Was machst du am liebsten im Spiel? Wann bist du meistens online?"><?= e((string) $member['profile_bio']) ?></textarea>
<div class="field-hint">Formatierung: <code>**fett**</code>, <code>*kursiv*</code>, <code>- Liste</code>, <code>## Überschrift</code>, <code>[Link](https://…)</code>.</div>
<div class="actions"><button type="submit">Speichern</button></div>
</form>
<div class="panel">
<h2>Charaktere</h2>
<?php foreach ($characters as $character): ?>
<details class="character-edit">
<summary>
<?= class_badge_html($character['class_name'], 22) ?>
<strong><?= e($character['name']) ?></strong>
<span class="text-muted"><?= e($character['class_name'] ?? '') ?><?= $character['level'] ? ' · Stufe ' . (int) $character['level'] : '' ?></span>
<?php if ($character['is_main']): ?><span class="badge badge-pending">Hauptcharakter</span><?php endif; ?>
<span class="character-edit-hint">bearbeiten ▾</span>
</summary>
<form method="post" action="/member_action.php" enctype="multipart/form-data">
<?= csrf_field() ?>
<input type="hidden" name="action" value="character_save">
<input type="hidden" name="user_id" value="<?= $id ?>">
<input type="hidden" name="character_id" value="<?= (int) $character['id'] ?>">
<?php character_fields($character, 'c' . (int) $character['id']); ?>
<div class="actions">
<button type="submit">Speichern</button>
<button type="submit" name="action" value="character_delete" class="button-danger"
onclick="return confirm('<?= e($character['name']) ?> wirklich löschen?');">Löschen</button>
</div>
</form>
</details>
<?php endforeach; ?>
<?php if (count($characters) < PROFILE_MAX_CHARACTERS): ?>
<details class="character-edit character-new"<?= empty($characters) ? ' open' : '' ?>>
<summary><strong>+ Charakter hinzufügen</strong></summary>
<form method="post" action="/member_action.php" enctype="multipart/form-data">
<?= csrf_field() ?>
<input type="hidden" name="action" value="character_save">
<input type="hidden" name="user_id" value="<?= $id ?>">
<input type="hidden" name="character_id" value="0">
<?php character_fields(['is_main' => empty($characters)], 'new'); ?>
<div class="actions"><button type="submit">Charakter anlegen</button></div>
</form>
</details>
<?php else: ?>
<p class="text-muted">Mehr als <?= PROFILE_MAX_CHARACTERS ?> Charaktere gehen nicht.</p>
<?php endif; ?>
</div>
<div class="panel">
<h2>Galerie</h2>
<form class="settings-toggle" method="post" action="/member_action.php">
<?= csrf_field() ?>
<input type="hidden" name="action" value="gallery_comments_toggle">
<input type="hidden" name="user_id" value="<?= $id ?>">
<label>
<input type="checkbox" name="enabled" value="1" <?= !empty($member['gallery_comments_enabled']) ? 'checked' : '' ?> onchange="this.form.submit()">
Andere Mitglieder dürfen meine Bilder kommentieren und mit Emojis reagieren
</label>
<noscript><button type="submit" class="button-secondary button-small">Speichern</button></noscript>
</form>
<?php if (count($gallery) < PROFILE_MAX_GALLERY): ?>
<form method="post" action="/member_action.php" enctype="multipart/form-data" class="gallery-upload">
<?= csrf_field() ?>
<input type="hidden" name="action" value="gallery_upload">
<input type="hidden" name="user_id" value="<?= $id ?>">
<input type="file" name="images[]" accept="image/png,image/jpeg,image/gif,image/webp" multiple required data-max-size="1920" data-paste>
<input type="text" name="caption" maxlength="150" placeholder="Bildunterschrift (optional)">
<button type="submit">Hochladen</button>
</form>
<div class="field-hint">Screenshots, Erinnerungen an Raids, lustige Momente … bis zu <?= PROFILE_MAX_GALLERY ?> Bilder, je höchstens 8 MB. Mehrere auf einmal auswählen geht auch.</div>
<?php else: ?>
<p class="text-muted">Die Galerie ist voll (<?= PROFILE_MAX_GALLERY ?> Bilder). Lösch ein altes Bild, um ein neues hochzuladen.</p>
<?php endif; ?>
<?php if (!empty($gallery)): ?>
<div class="gallery-grid gallery-edit-grid">
<?php foreach ($gallery as $picture): ?>
<figure class="gallery-item<?= ($picture['status'] ?? 'visible') === 'pending' ? ' is-pending' : '' ?>">
<?php if (($picture['status'] ?? 'visible') === 'pending'): ?>
<span class="pending-badge" title="<?= e((string) $picture['moderation_note']) ?>">Wartet auf Freigabe</span>
<?php endif; ?>
<img src="<?= e(profile_image_url($picture['filename'])) ?>" alt="" loading="lazy">
<form method="post" action="/member_action.php" class="gallery-item-form">
<?= csrf_field() ?>
<input type="hidden" name="user_id" value="<?= $id ?>">
<input type="hidden" name="picture_id" value="<?= (int) $picture['id'] ?>">
<input type="text" name="caption" maxlength="150" value="<?= e((string) $picture['caption']) ?>" placeholder="Bildunterschrift">
<div class="gallery-item-actions">
<button type="submit" name="action" value="gallery_update" class="button-small button-secondary">Speichern</button>
<button type="submit" name="action" value="gallery_delete" class="icon-button icon-button-danger" title="Löschen"
onclick="return confirm('Dieses Bild löschen?');"><?= icon('trash') ?></button>
</div>
</form>
</figure>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<script src="<?= e(asset_url('/assets/js/image-resize.js')) ?>"></script>
<?php
$currentBackground = (string) ($member['profile_background'] ?? '');
$backgroundPictures = array_values(array_filter($gallery, static fn (array $p): bool => ($p['status'] ?? 'visible') === 'visible'));
?>
<div class="panel" id="hintergrund">
<h2>Hintergrund der Profilseite</h2>
<p class="text-muted">Gib deiner Profilseite deine persönliche Note: eine der Landschaften oder ein Bild aus deiner Galerie.</p>
<form method="post" action="/member_action.php" class="background-picker">
<?= csrf_field() ?>
<input type="hidden" name="action" value="background_save">
<input type="hidden" name="user_id" value="<?= $id ?>">
<div class="background-grid">
<label class="background-option background-default<?= $currentBackground === '' ? ' is-selected' : '' ?>">
<input type="radio" name="background" value="" <?= $currentBackground === '' ? 'checked' : '' ?>>
<span class="background-thumb"><img src="/assets/images/Landscapes/web/thumbs/landscape9-thumb.jpg" alt="" loading="lazy"></span>
<span class="background-name">Standard</span>
</label>
<?php foreach (PROFILE_BACKGROUND_PRESETS as $index => $preset): ?>
<?php $value = 'preset:' . $preset; ?>
<label class="background-option<?= $currentBackground === $value ? ' is-selected' : '' ?>">
<input type="radio" name="background" value="<?= e($value) ?>" <?= $currentBackground === $value ? 'checked' : '' ?>>
<span class="background-thumb"><img src="/assets/images/Landscapes/web/thumbs/<?= e($preset) ?>-thumb.jpg" alt="" loading="lazy"></span>
<span class="background-name">Landschaft <?= $index + 1 ?></span>
</label>
<?php endforeach; ?>
<?php foreach ($backgroundPictures as $picture): ?>
<?php $value = 'gallery:' . (int) $picture['id']; ?>
<label class="background-option<?= $currentBackground === $value ? ' is-selected' : '' ?>">
<input type="radio" name="background" value="<?= e($value) ?>" <?= $currentBackground === $value ? 'checked' : '' ?>>
<span class="background-thumb"><img src="<?= e(profile_image_url($picture['filename'])) ?>" alt="" loading="lazy"></span>
<span class="background-name"><?= e($picture['caption'] ?: 'Eigenes Bild') ?></span>
</label>
<?php endforeach; ?>
</div>
<?php if (!$backgroundPictures): ?>
<p class="field-hint">Tipp: Lade oben ein Bild in deine Galerie hoch - dann kannst du es auch als Hintergrund nehmen.</p>
<?php endif; ?>
<div class="actions"><button type="submit">Hintergrund speichern</button></div>
</form>
</div>
<script>
// Auswahl sofort sichtbar markieren
document.querySelectorAll('.background-picker input[type="radio"]').forEach(function (radio) {
radio.addEventListener('change', function () {
document.querySelectorAll('.background-option').forEach(function (o) { o.classList.remove('is-selected'); });
radio.closest('.background-option').classList.add('is-selected');
});
});
</script>
<?php include __DIR__ . '/includes/footer.php'; ?>