prepare('UPDATE member_characters SET checklist_role = ? WHERE id = ?') ->execute([$role !== '' ? $role : null, (int) $character['id']]); set_flash('success', '„' . $character['name'] . '“: ' . CHECKLIST_ROLES[$role] . ($role === '' ? ' (Hauptcharakter = Main, sonst Twink)' : '') . '.'); redirect('/checklist.php#einstellungen'); } // Haken (JSON) $body = read_json_body(); verify_csrf_token($body['csrf_token'] ?? ''); $character = $ownCharacter((int) ($body['character_id'] ?? 0)); // Notiz (JSON) if (($body['action'] ?? '') === 'note') { $note = trim(str_replace(" ", " ", (string) ($body['note'] ?? ''))); if ($character === null) { json_response(false, 'Diesen Charakter gibt es nicht (mehr). Bitte die Seite neu laden.'); } if (mb_strlen($note) > CHECKLIST_NOTE_MAX) { json_response(false, 'Die Notiz ist zu lang (höchstens ' . CHECKLIST_NOTE_MAX . ' Zeichen).'); } checklist_set_note($userId, (int) $character['id'], $note); json_response(true, '', ['note' => $note]); } $task = checklist_task((string) ($body['task'] ?? '')); if ($character === null || $task === null || !checklist_applies($task, $character['role'])) { json_response(false, 'Diese Aufgabe gibt es für den Charakter nicht (mehr). Bitte die Seite neu laden.'); } checklist_set($userId, (int) $character['id'], $task, !empty($body['done'])); json_response(true);