Upload via GUI (93 Dateien)
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin-Seite "AeroMC Fehlerberichte": Liste, Detailansicht, Löschen.
|
||||
* Nur für Administratoren (manage_options).
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
add_action('admin_menu', function () {
|
||||
global $wpdb;
|
||||
$table = $wpdb->prefix . AEROMC_FRIENDS_REPORTS_TABLE;
|
||||
$neu = (int) $wpdb->get_var("SELECT COUNT(*) FROM $table WHERE status = 'neu'");
|
||||
$titel = 'AeroMC Fehler' . ($neu ? ' <span class="awaiting-mod">' . $neu . '</span>' : '');
|
||||
add_menu_page('AeroMC Fehlerberichte', $titel, 'manage_options', 'aeromc-reports', 'aeromc_friends_reports_page', 'dashicons-sos', 81);
|
||||
});
|
||||
|
||||
function aeromc_friends_reports_page() {
|
||||
global $wpdb;
|
||||
if (!current_user_can('manage_options')) {
|
||||
return;
|
||||
}
|
||||
$table = $wpdb->prefix . AEROMC_FRIENDS_REPORTS_TABLE;
|
||||
$basis = admin_url('admin.php?page=aeromc-reports');
|
||||
|
||||
// Löschen (einzeln oder alle erledigten)
|
||||
if (isset($_POST['aeromc_loeschen']) && check_admin_referer('aeromc_reports')) {
|
||||
$id = (int) $_POST['aeromc_loeschen'];
|
||||
$wpdb->delete($table, ['id' => $id]);
|
||||
echo '<div class="notice notice-success"><p>Bericht #' . esc_html($id) . ' gelöscht.</p></div>';
|
||||
}
|
||||
if (isset($_POST['aeromc_status'], $_POST['aeromc_id']) && check_admin_referer('aeromc_reports')) {
|
||||
$status = in_array($_POST['aeromc_status'], ['neu', 'gelesen', 'erledigt'], true) ? $_POST['aeromc_status'] : 'gelesen';
|
||||
$wpdb->update($table, ['status' => $status], ['id' => (int) $_POST['aeromc_id']]);
|
||||
}
|
||||
|
||||
echo '<div class="wrap"><h1>AeroMC Fehlerberichte</h1>';
|
||||
|
||||
// Detailansicht
|
||||
if (isset($_GET['report'])) {
|
||||
$id = (int) $_GET['report'];
|
||||
$r = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE id = %d", $id));
|
||||
if (!$r) {
|
||||
echo '<p>Bericht nicht gefunden.</p></div>';
|
||||
return;
|
||||
}
|
||||
if ($r->status === 'neu') {
|
||||
$wpdb->update($table, ['status' => 'gelesen'], ['id' => $id]);
|
||||
$r->status = 'gelesen';
|
||||
}
|
||||
echo '<p><a href="' . esc_url($basis) . '">← Zur Liste</a></p>';
|
||||
echo '<h2>Bericht #' . esc_html($r->id) . '</h2>';
|
||||
echo '<table class="widefat striped" style="max-width:900px"><tbody>';
|
||||
$zeile = function ($k, $v) {
|
||||
echo '<tr><th style="width:180px">' . esc_html($k) . '</th><td>' . esc_html($v !== null && $v !== '' ? $v : '–') . '</td></tr>';
|
||||
};
|
||||
$zeile('Eingegangen (UTC)', $r->created_at);
|
||||
$zeile('Spieler', $r->username ? $r->username . ' (' . $r->uuid . ')' : 'anonym');
|
||||
$zeile('Launcher-Version', $r->launcher_version);
|
||||
$zeile('Minecraft', $r->mc_version);
|
||||
$zeile('Loader', trim($r->loader . ' ' . $r->loader_version));
|
||||
$zeile('System', $r->system);
|
||||
$zeile('Status', $r->status);
|
||||
echo '</tbody></table>';
|
||||
|
||||
if ($r->kommentar) {
|
||||
echo '<h3>Kommentar</h3><div style="max-width:900px;padding:10px 14px;background:#fff;border:1px solid #ccd0d4;white-space:pre-wrap">' . esc_html($r->kommentar) . '</div>';
|
||||
}
|
||||
$funde = json_decode((string) $r->funde, true) ?: [];
|
||||
echo '<h3>Erkannte Ursachen (' . count($funde) . ')</h3>';
|
||||
if ($funde) {
|
||||
echo '<ul style="list-style:disc;padding-left:20px">';
|
||||
foreach ($funde as $f) {
|
||||
echo '<li><strong>' . esc_html($f['titel'] ?? '') . '</strong> – ' . esc_html($f['text'] ?? '') . '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
} else {
|
||||
echo '<p>Keine – der Assistent konnte die Ursache nicht eindeutig erkennen.</p>';
|
||||
}
|
||||
$mods = json_decode((string) $r->mods, true) ?: [];
|
||||
echo '<h3>Mods (' . count($mods) . ')</h3>';
|
||||
if ($mods) {
|
||||
echo '<table class="widefat striped" style="max-width:900px"><thead><tr><th>Datei</th><th>Name</th><th>Version</th><th>Aktiv</th></tr></thead><tbody>';
|
||||
foreach ($mods as $m) {
|
||||
echo '<tr><td>' . esc_html($m['datei'] ?? '') . '</td><td>' . esc_html($m['name'] ?? '') . '</td><td>'
|
||||
. esc_html($m['version'] ?? '') . '</td><td>' . (!empty($m['aktiv']) ? 'ja' : 'nein') . '</td></tr>';
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
}
|
||||
echo '<h3>Bericht / Protokoll</h3><textarea readonly style="width:100%;max-width:1200px;height:420px;font-family:monospace;font-size:12px">'
|
||||
. esc_textarea($r->bericht) . '</textarea>';
|
||||
|
||||
echo '<form method="post" style="margin-top:14px;display:flex;gap:8px">';
|
||||
wp_nonce_field('aeromc_reports');
|
||||
echo '<input type="hidden" name="aeromc_id" value="' . esc_attr($r->id) . '" />';
|
||||
echo '<button class="button" name="aeromc_status" value="erledigt">Als erledigt markieren</button>';
|
||||
echo '<button class="button" name="aeromc_status" value="neu">Wieder als neu markieren</button>';
|
||||
echo '<button class="button button-link-delete" name="aeromc_loeschen" value="' . esc_attr($r->id) . '" onclick="return confirm(\'Bericht wirklich löschen?\')">Löschen</button>';
|
||||
echo '</form></div>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Liste
|
||||
$rows = $wpdb->get_results("SELECT id, created_at, username, launcher_version, mc_version, loader, funde, kommentar, status FROM $table ORDER BY id DESC LIMIT 200");
|
||||
if (!$rows) {
|
||||
echo '<p>Noch keine Fehlerberichte eingegangen.</p></div>';
|
||||
return;
|
||||
}
|
||||
echo '<table class="widefat striped"><thead><tr><th>#</th><th>Eingegangen (UTC)</th><th>Spieler</th><th>Launcher</th><th>Minecraft</th><th>Erkannte Ursache</th><th>Kommentar</th><th>Status</th></tr></thead><tbody>';
|
||||
foreach ($rows as $r) {
|
||||
$funde = json_decode((string) $r->funde, true) ?: [];
|
||||
$ursache = $funde ? ($funde[0]['titel'] ?? '') . (count($funde) > 1 ? ' (+' . (count($funde) - 1) . ')' : '') : '–';
|
||||
$fett = $r->status === 'neu' ? 'font-weight:600' : '';
|
||||
echo '<tr style="' . $fett . '"><td><a href="' . esc_url(add_query_arg('report', $r->id, $basis)) . '">#' . esc_html($r->id) . '</a></td>'
|
||||
. '<td>' . esc_html($r->created_at) . '</td>'
|
||||
. '<td>' . esc_html($r->username ?: 'anonym') . '</td>'
|
||||
. '<td>' . esc_html($r->launcher_version) . '</td>'
|
||||
. '<td>' . esc_html(trim($r->mc_version . ' ' . $r->loader)) . '</td>'
|
||||
. '<td>' . esc_html($ursache) . '</td>'
|
||||
. '<td>' . esc_html(mb_strimwidth((string) $r->kommentar, 0, 60, '…')) . '</td>'
|
||||
. '<td>' . esc_html($r->status) . '</td></tr>';
|
||||
}
|
||||
echo '</tbody></table></div>';
|
||||
}
|
||||
Reference in New Issue
Block a user