LuminaWebsite/professions_action.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

30 lines
1.1 KiB
PHP

<?php
/** Zielzahlen je Beruf speichern (professions.php, Recht professions.manage) - Einstellung profession_targets. */
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/professions.php';
require_permission('professions.manage');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
redirect('/professions.php');
}
verify_csrf();
if (($_POST['action'] ?? '') === 'targets') {
$input = is_array($_POST['target'] ?? null) ? $_POST['target'] : [];
$old = profession_targets();
$new = [];
$changes = [];
foreach (PROFESSIONS as $key => $profession) {
$raw = is_string($input[$key] ?? null) ? trim($input[$key]) : '0';
$new[$key] = max(0, min(PROFESSION_TARGET_MAX, (int) $raw));
if ($new[$key] !== $old[$key]) {
$changes[$profession['label']] = admin_log_change($old[$key] ?: 'kein Ziel', $new[$key] ?: 'kein Ziel');
}
}
setting_set('profession_targets', (string) json_encode($new));
if ($changes) {
admin_log('🛠️ Zielzahlen der Berufe geändert', $changes);
}
set_flash('success', 'Zielzahlen gespeichert.');
}
redirect('/professions.php#ziele');