LuminaWebsite/member.php
Maaxxs ee7a3a2e8e Professions: members enter their characters' professions, a new page shows who can craft what
Asked for in Discord: profession management within the legion for a good balance. Aion 2 has five
crafting professions (Blacksmithing, Armorsmithing, Handicrafting, Alchemy, Cooking) with the stages
Beginner, Expert and Master; gathering is one shared skill for six raw materials that players
specialize in with points. Professions belong to characters, so they are entered per character.

- includes/professions.php: PROFESSIONS (German name, client name, icon, products, weapon classes),
  PROFESSION_STAGES, GATHERING_MATERIALS, loading/saving, counts per member, targets and "wanted".
  German names are not confirmed by the German client yet; only keys are stored.
- New table character_professions (stage, optional level, main profession - at most one per
  character) and member_characters.gathering (schema version 57, also in sql/schema.sql).
- Profile editor: per character a professions fieldset (stage, level, main-profession tick - a
  single profession becomes the main one) and the gathering specialization; saved with the
  character (member_action.php), invalid levels are rejected.
- Profile page shows them per character; the member list shows icons on the cards (main
  profession with a gold ring), gets a "Beruf" filter and finds professions in the search.
- New page professions.php ("Berufe" in the menu, members.view): per profession how many members
  have it as main profession and at all, characters per stage, which classes' weapons it makes and
  how many members play them, everyone with stage; below the gathering specializations.
- New permission professions.manage (initially for groups with roles.manage): targets per
  profession (professions_action.php, setting profession_targets, audit log). Professions below
  their target show as "Gerade gesucht" on the page and in the profile editor.
- Hammer icon; live updates for the new page, the member list and profile pages; the data export
  includes professions per character; privacy policy (as of 26.09.), patch notes and README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:01:11 +02:00

233 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_once __DIR__ . '/includes/reactions.php';
require_once __DIR__ . '/includes/wiki.php'; // wiki_render() fuer den Beschreibungstext
require_once __DIR__ . '/includes/gear.php';
require_once __DIR__ . '/includes/professions.php';
require_permission('members.view');
$id = (int) ($_GET['id'] ?? 0);
$stmt = db()->prepare(
"SELECT id, username, display_name, class_name, classes, profile_bio, profile_background, gallery_comments_enabled, discord_id, discord_username, avatar_filename, status,
COALESCE(discord_joined_at, created_at) AS joined_at, discord_joined_at IS NOT NULL AS joined_discord,
COALESCE(last_seen_at, last_login) AS last_active
FROM users WHERE id = ?"
);
$stmt->execute([$id]);
$member = $stmt->fetch();
if (!$member || $member['status'] !== 'active') {
show_not_found();
}
$groupStmt = db()->prepare(
"SELECT COALESCE(NULLIF(r.display_name, ''), r.name) AS name FROM roles r
JOIN user_roles ur ON ur.role_id = r.id WHERE ur.user_id = ? ORDER BY " . ROLE_TAG_ORDER_SQL
);
$groupStmt->execute([$id]);
$groups = array_column($groupStmt->fetchAll(), 'name');
$characters = profile_characters_by_user($id)[$id] ?? [];
// Ausruestungssets aus dem Gear-Planer, die das Mitglied fuers Profil freigegeben hat
$gearSets = user_has_permission('gear.view') ? gear_profile_sets($id) : [];
// Noch nicht freigegebene Bilder sehen nur der Besitzer und die Moderation.
$seesPending = (int) current_user()['id'] === $id || moderation_can();
$galleryStmt = db()->prepare(
'SELECT * FROM member_gallery WHERE user_id = ? AND is_background = 0' . ($seesPending ? '' : " AND status = 'visible'") . ' ORDER BY sort_order, id'
);
$galleryStmt->execute([$id]);
$gallery = $galleryStmt->fetchAll();
$commentsEnabled = !empty($member['gallery_comments_enabled']);
$commentCounts = $commentsEnabled ? gallery_comment_counts(array_map('intval', array_column($gallery, 'id'))) : [];
$pictureReactions = $commentsEnabled ? reactions_for('picture', array_map('intval', array_column($gallery, 'id'))) : [];
$name = $member['display_name'] !== '' ? $member['display_name'] : $member['username'];
$canEdit = profile_can_edit($id);
$isOwn = (int) current_user()['id'] === $id;
$pageTitle = $name;
// Selbst gewaehlter Hintergrund (Landschaft oder eigenes Galeriebild)
$pageBackgroundImage = profile_background_url($member['profile_background'] ?? null, $id);
include __DIR__ . '/includes/header.php';
?>
<div class="panel member-profile-head">
<?= avatar_html($member, 96) ?>
<div class="member-profile-info">
<h1><?= e($name) ?> <?= class_badge_html($member['class_name'] ?? null, 32) ?></h1>
<div class="member-profile-meta text-muted">
<?php if (!empty($member['discord_username'])): ?>
<span class="discord-inline"><?= discord_logo(14) ?> <?= e($member['discord_username']) ?></span>
<?php endif; ?>
<span title="<?= $member['joined_discord'] ? 'Beitritt zum Discord-Server der Legion' : 'Konto auf der Website angelegt' ?>">Dabei seit <?= e(date('d.m.Y', strtotime($member['joined_at']))) ?></span>
<span class="member-last-seen<?= is_online($member['last_active']) ? ' is-online' : '' ?>" title="Zuletzt auf der Website aktiv"><span class="online-dot"></span><?= is_online($member['last_active']) ? 'Online' : 'Zuletzt aktiv ' . e(last_active_label($member['last_active'])) ?></span>
<?php if (!empty($characters)): ?><span><?= count($characters) ?> <?= count($characters) === 1 ? 'Charakter' : 'Charaktere' ?></span><?php endif; ?>
</div>
<?php $memberClasses = user_classes($member); ?>
<?php if ($memberClasses): ?>
<?php // Klassen laut Discord-Klassenrollen, die Main-Klasse zuerst ?>
<div class="member-profile-classes">
<?php foreach ($memberClasses as $index => $class): ?>
<?php $isMainClass = $index === 0 && count($memberClasses) > 1; ?>
<?php // Nur das Icon, der Klassenname steht im Tooltip ?>
<span class="member-profile-class<?= $index === 0 ? ' is-main' : '' ?>" title="<?= e($class . ($isMainClass ? ' (Main)' : '')) ?>">
<?= class_badge_html($class, 20) ?>
<?php if ($isMainClass): ?><span class="profile-class-main">Main</span><?php endif; ?>
</span>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if (!empty($groups)): ?>
<div class="member-roles">
<?php foreach ($groups as $group): ?><?= role_tag_html($group) ?><?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<div class="member-profile-actions">
<?php if ($canEdit): ?>
<a class="button" href="/member_edit.php?id=<?= $id ?>"><?= icon('edit') ?> <?= $isOwn ? 'Profilseite bearbeiten' : 'Bearbeiten (Leitung)' ?></a>
<?php endif; ?>
<a class="button button-secondary" href="/members.php">Alle Mitglieder</a>
</div>
</div>
<?php if (trim((string) $member['profile_bio']) !== ''): ?>
<div class="panel">
<h2>Über mich</h2>
<div class="wiki-content"><?= wiki_render((string) $member['profile_bio']) ?></div>
</div>
<?php elseif ($isOwn): ?>
<div class="panel member-profile-empty">
<p>Deine Profilseite ist noch leer. Erzähl etwas über dich, zeig deine Charaktere und Screenshots!</p>
<a class="button" href="/member_edit.php?id=<?= $id ?>">Profilseite gestalten</a>
</div>
<?php endif; ?>
<?php if (!empty($characters)): ?>
<div class="panel">
<h2>Charaktere</h2>
<div class="character-grid">
<?php $characterProfessions = professions_for_characters(array_column($characters, 'id')); ?>
<?php foreach ($characters as $character): ?>
<?php $portrait = profile_image_url($character['portrait_filename']); $image = profile_image_url($character['image_filename']); ?>
<article class="character-card<?= $character['is_main'] ? ' is-main' : '' ?>">
<div class="character-portrait">
<?php if ($portrait): ?>
<a href="<?= e($portrait) ?>" data-lightbox="characters" data-caption="<?= e($character['name'] . ' – Portrait') ?>"><img src="<?= e($portrait) ?>" alt="Portrait von <?= e($character['name']) ?>" loading="lazy"></a>
<?php else: ?>
<span class="character-portrait-empty"><?= class_badge_html($character['class_name'], 56) ?: e(mb_substr($character['name'], 0, 1)) ?></span>
<?php endif; ?>
</div>
<div class="character-info">
<h3><?= e($character['name']) ?> <?= class_badge_html($character['class_name'], 22) ?></h3>
<div class="text-muted">
<?= e($character['class_name'] ?? 'Klasse unbekannt') ?><?= $character['level'] ? ' · Stufe ' . (int) $character['level'] : '' ?>
</div>
<?php if ($character['is_main']): ?><span class="badge badge-pending">Hauptcharakter</span><?php endif; ?>
<?php if (!empty($character['note'])): ?><p><?= e($character['note']) ?></p><?php endif; ?>
<?php $professions = $characterProfessions[(int) $character['id']] ?? []; $gathering = gathering_parse($character['gathering'] ?? null); ?>
<?php if ($professions || $gathering): ?>
<div class="character-professions-view">
<?php foreach ($professions as $key => $entry): ?><?= profession_badge_html($key, $entry) ?><?php endforeach; ?>
<?= gathering_badges_html($gathering) ?>
</div>
<?php endif; ?>
</div>
<?php if ($image): ?>
<a class="character-image" href="<?= e($image) ?>" data-lightbox="characters" data-caption="<?= e($character['name']) ?>">
<img src="<?= e($image) ?>" alt="Bild von <?= e($character['name']) ?>" loading="lazy">
</a>
<?php endif; ?>
</article>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if (!empty($gearSets)): ?>
<div class="panel">
<h2>Ausrüstung</h2>
<div class="gear-set-cards">
<?php foreach ($gearSets as $gear): ?>
<article class="gear-set-card gear-set-card-profile">
<a class="gear-set-card-link" href="/gear.php?set=<?= (int) $gear['set']['id'] ?>">
<?php // Ausruestung als Saeule wie im Spiel (zwei Slots pro Reihe), Angaben daneben ?>
<?= gear_doll_mini_html($gear['slots'], true) ?>
<span class="gear-set-card-info">
<span class="gear-set-card-title"><?= e($gear['set']['name']) ?> <?= class_badge_html($gear['set']['class_name'], 20) ?></span>
<span class="text-muted">
<?= count(array_filter($gear['slots'], static fn (array $row): bool => !empty($row['item']))) ?>/<?= count(GEAR_SLOTS) ?> Slots
<?php if ($gear['item_level'] !== null): ?><br>Ø Stufe <?= e(number_format($gear['item_level'], 1, ',', '.')) ?><?php endif; ?>
</span>
<?php if (!empty($gear['set']['note'])): ?><span class="gear-set-card-note"><?= e($gear['set']['note']) ?></span><?php endif; ?>
<?php $gearTotals = gear_set_totals($gear['slots']); ?>
<?php if ($gearTotals): ?>
<?php // Werte-Summe wie im Gear-Planer (die wichtigsten zuerst, siehe GEAR_STAT_ORDER) ?>
<span class="gear-set-card-stats">
<?php foreach ($gearTotals as $total): ?>
<span class="gear-set-card-stat">
<span class="gear-set-card-stat-name" title="<?= e($total['name']) ?>"><?= e($total['name']) ?></span>
<span class="gear-set-card-stat-value"><?= $total['estimated'] ? '<span class="gear-estimated" title="enthält hochgerechnete Zwischenstufen">≈</span>' : '' ?><?= e(gear_format_value($total['total'], $total['unit'])) ?></span>
</span>
<?php endforeach; ?>
</span>
<?php endif; ?>
<?php if ($gear['skills']): ?>
<?php // Geplante Skills: die hoechsten Stufen zuerst ?>
<span class="gear-set-card-skills">
<span class="text-muted"><?= e(gear_skill_summary($gear['skills'])) ?></span>
<?= gear_skills_mini_html($gear['skills'], 10) ?>
</span>
<?php endif; ?>
<span class="gear-set-card-more">Details ansehen &rarr;</span>
</span>
</a>
<?php if (!empty($gear['set']['build_url']) && gear_build_host((string) $gear['set']['build_url']) !== null): ?>
<a class="gear-set-card-build" href="<?= e($gear['set']['build_url']) ?>" target="_blank" rel="noopener noreferrer nofollow">Skill- &amp; Daevanion-Plan ↗</a>
<?php endif; ?>
</article>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if (!empty($gallery)): ?>
<div class="panel">
<h2>Galerie</h2>
<div class="gallery-grid">
<?php foreach ($gallery as $picture): ?>
<?php
$url = profile_image_url($picture['filename']);
$pictureUrl = '/member_picture.php?id=' . (int) $picture['id'];
$commentCount = $commentCounts[(int) $picture['id']] ?? 0;
?>
<figure class="gallery-item<?= $picture['status'] === 'pending' ? ' is-pending' : '' ?>">
<?php if ($picture['status'] === 'pending'): ?>
<span class="pending-badge" title="<?= e((string) $picture['moderation_note']) ?>">Wartet auf Freigabe</span>
<?php endif; ?>
<a href="<?= e($url) ?>" data-lightbox="gallery" data-caption="<?= e((string) $picture['caption']) ?>"
<?php if ($commentsEnabled): ?>data-comments-url="<?= e($pictureUrl . '#kommentare') ?>" data-comments-count="<?= $commentCount ?>"<?php endif; ?>>
<img src="<?= e($url) ?>" alt="<?= e($picture['caption'] ?: 'Bild von ' . $name) ?>" loading="lazy">
</a>
<?php $reactionsHere = $pictureReactions[(int) $picture['id']] ?? []; ?>
<?php if ($reactionsHere): ?>
<?php arsort($reactionsHere); ?>
<a class="gallery-reaction-summary" href="<?= e($pictureUrl) ?>" title="Reaktionen ansehen">
<?= e(implode('', array_slice(array_keys($reactionsHere), 0, 3))) ?>
<span><?= array_sum(array_column($reactionsHere, 'count')) ?></span>
</a>
<?php endif; ?>
<?php if ($commentsEnabled): ?>
<a class="gallery-comment-badge<?= $commentCount > 0 ? ' has-comments' : '' ?>" href="<?= e($pictureUrl . '#kommentare') ?>"
title="<?= $commentCount > 0 ? $commentCount . ' ' . ($commentCount === 1 ? 'Kommentar' : 'Kommentare') . ' ansehen' : 'Kommentieren' ?>">
<?= icon('message') ?><?= $commentCount > 0 ? ' ' . $commentCount : '' ?>
</a>
<?php endif; ?>
<?php if (!empty($picture['caption'])): ?><figcaption><?= e($picture['caption']) ?></figcaption><?php endif; ?>
</figure>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<script src="<?= e(asset_url('/assets/js/lightbox.js')) ?>" defer></script>
<?php include __DIR__ . '/includes/footer.php'; ?>