LuminaWebsite/member_edit.php
Maaxxs 809e88d028 Start page pictures are chosen by the leadership (site.homepage), not by the members
- New permission site.homepage: in the gallery every picture gets a button to put it on the start
  page or take it off again (gallery_home_action.php, logged); the filter "Startseite" shows the
  current selection. Schema v48 so the permission gets synced (administrators get it).
- Members can no longer release pictures themselves: the checkboxes and their handling in
  member_action.php are gone. Their selected pictures are marked "Startseite" in the profile
  editor, with a hint to tell the leadership if they don't want that.
- Privacy policy: legitimate interest instead of consent, objection via the leadership. Patch note,
  README, tour and comments updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 23:30:12 +02:00

291 lines
18 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 = ? AND is_background = 0 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="<?= PROFILE_MAX_LEVEL ?>" 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" 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"
data-confirm="<?= e($character['name'] . ' wirklich löschen?') ?>" data-confirm-title="Charakter löschen" data-confirm-danger data-confirm-ok="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" id="galerie">
<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 // Bilder fuer die oeffentliche Startseite (index.php) waehlt die Leitung in der Galerie aus (Recht site.homepage) ?>
<?php if ($isOwn): ?>
<p class="field-hint">
Die Legionsleitung kann einzelne Bilder für die öffentliche Startseite auswählen - dort erscheinen sie ohne deinen
Namen und ohne Bildunterschrift und sind hier mit „Startseite“ markiert. Möchtest du das für ein Bild nicht, sag der Leitung Bescheid.
</p>
<?php elseif (user_has_permission('site.homepage')): ?>
<p class="field-hint">Bilder für die Startseite wählst du in der <a href="/gallery.php?mitglied=<?= $id ?>">Galerie</a> aus.</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; ?>
<?php if (!empty($picture['show_on_home'])): ?>
<span class="gallery-home-badge" title="Die Legionsleitung zeigt dieses Bild auf der öffentlichen Startseite (ohne Namen)"><?= icon('home') ?> Startseite</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"
data-confirm="Dieses Bild löschen?" data-confirm-title="Bild löschen" data-confirm-danger data-confirm-ok="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'));
// Eigenes Bild, das nur als Hintergrund hochgeladen wurde (nicht in der Galerie)
$ownBackground = profile_background_image($id);
?>
<div class="panel" id="hintergrund">
<h2>Hintergrund der Profilseite</h2>
<p class="text-muted">Gib deiner Profilseite deine persönliche Note: eine der Landschaften, ein Bild aus deiner Galerie oder ein eigenes Bild nur für den Hintergrund.</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 if ($ownBackground): ?>
<?php $value = 'gallery:' . (int) $ownBackground['id']; $ownPending = $ownBackground['status'] === 'pending'; ?>
<label class="background-option background-own<?= $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($ownBackground['filename'])) ?>" alt="" loading="lazy">
<?php if ($ownPending): ?><span class="background-pending" title="<?= e((string) $ownBackground['moderation_note']) ?>">Wartet auf Freigabe</span><?php endif; ?>
</span>
<span class="background-name">Eigenes Hintergrundbild</span>
</label>
<?php endif; ?>
<?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>
<div class="actions"><button type="submit">Hintergrund speichern</button></div>
</form>
<div class="background-upload">
<h3><?= $ownBackground ? 'Anderes eigenes Hintergrundbild' : 'Eigenes Bild als Hintergrund' ?></h3>
<form method="post" action="/member_action.php" enctype="multipart/form-data" class="background-upload-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="background_upload">
<input type="hidden" name="user_id" value="<?= $id ?>">
<input type="file" name="background_image" accept="image/png,image/jpeg,image/gif,image/webp" required data-max-size="2560" data-paste>
<button type="submit">Hochladen &amp; als Hintergrund setzen</button>
</form>
<div class="field-hint">
Kommt nicht in deine Galerie. Am besten ein Querformat-Bild (z.B. ein Screenshot), höchstens 8 MB.
<?= $ownBackground ? 'Ersetzt dein bisheriges eigenes Hintergrundbild.' : '' ?>
</div>
<?php if ($ownBackground): ?>
<form method="post" action="/member_action.php" class="inline-form" data-confirm="Eigenes Hintergrundbild löschen?" data-confirm-title="Hintergrundbild löschen" data-confirm-danger data-confirm-ok="Löschen">
<?= csrf_field() ?>
<input type="hidden" name="action" value="background_delete">
<input type="hidden" name="user_id" value="<?= $id ?>">
<button type="submit" class="button-secondary button-small"><?= icon('trash') ?> Eigenes Hintergrundbild löschen</button>
</form>
<?php endif; ?>
</div>
</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'; ?>