t('acp.rep.status_reported'), 1 => t('acp.rep.status_todo'), 2 => t('acp.rep.status_confirmed'), 3 => t('acp.rep.status_invalid'), 4 => t('acp.rep.status_rejected'), 5 => t('acp.rep.status_fixed'), ]; $statusTone = [ 0 => 'purple', 1 => 'blue', 2 => 'red', 3 => 'grey', 4 => 'grey', 5 => 'green', ]; // Statuses that may carry a public changelog entry. $statusChangeLog = [0, 5]; // Statuses whose section starts collapsed. $collapsedStatus = [3, 4, 5]; // --------------------------------------------------------------------------- // Update a report // --------------------------------------------------------------------------- if ($_SERVER['REQUEST_METHOD'] === 'POST') { $playerName = trim((string)($_POST['playerName'] ?? '')); $status = intv($_POST['status'] ?? 0); $reportId = intv($_POST['id'] ?? 0); $price = intv($_POST['price'] ?? 0) + intv($_POST['customPoints'] ?? 0); if ($price > 0 && !is_admin($user_data ?? null)) { $price = 0; acp_log('access.action_denied', 'reports.reward', ['roles' => admin_roles($user_data ?? null)]); acp_flash_error('Only an owner can grant reward points. The report status was still processed.'); } if ($reportId <= 0 || !isset($statusTypes[$status])) { acp_flash_error(t('acp.rep.invalid')); acp_redirect('reports'); } db()->execute(" UPDATE `znote_player_reports` SET `status` = ? WHERE `id` = ? LIMIT 1; ", [$status, $reportId]); acp_log('reports.status', '#' . $reportId, ['status' => $statusTypes[$status]]); acp_flash_success(t('acp.rep.set_to', ['id' => $reportId, 'status' => '' . h($statusTypes[$status]) . ''])); // ------------------------------------------------------ Changelog entry $changelogReportId = intv($_POST['changelogReportId'] ?? 0); $changelogValue = (string)($_POST['changelogValue'] ?? '1'); $changelogText = trim((string)($_POST['changelogText'] ?? '')); if ($changelogReportId > 0 && $changelogValue === '2' && $changelogText !== '') { $now = time(); $existing = db()->fetchOne(" SELECT `id` FROM `znote_changelog` WHERE `report_id` = ? LIMIT 1; ", [$changelogReportId]); if (is_array($existing)) { db()->execute(" UPDATE `znote_changelog` SET `text` = ?, `time` = ? WHERE `id` = ? LIMIT 1; ", [$changelogText, $now, (int)$existing['id']]); acp_log('reports.changelog_update', '#' . $changelogReportId, ['changelog_id' => (int)$existing['id']]); acp_flash_info(t('acp.rep.changelog_updated')); } else { db()->execute(" INSERT INTO `znote_changelog` (`text`, `time`, `report_id`, `status`) VALUES (?, ?, ?, ?); ", [$changelogText, $now, $changelogReportId, $status]); acp_log('reports.changelog_create', '#' . $changelogReportId); acp_flash_info(t('acp.rep.changelog_created')); } $cache = new Cache('engine/cache/changelog'); $cache->setContent(db()->fetchAll(" SELECT `id`, `text`, `time`, `report_id`, `status` FROM `znote_changelog` ORDER BY `id` DESC; ") ?: []); $cache->save(); } // ------------------------------------------------------- Reward points if ($price > 0 && $playerName !== '') { $account = db()->fetchOne(" SELECT `a`.`id`, `a`.`email` FROM `accounts` `a` INNER JOIN `players` `p` ON `p`.`account_id` = `a`.`id` WHERE `p`.`name` = ? LIMIT 1; ", [$playerName]); if (is_array($account)) { $accountId = (int)$account['id']; $rewarded = db()->transaction(function ($db) use ($reportId, $accountId, $price, $account, $user_data) { $balance = $db->fetchOne( "SELECT `points` FROM `znote_accounts` WHERE `account_id` = ? LIMIT 1 FOR UPDATE;", [$accountId] ); if (!is_array($balance)) { return false; } $db->execute( "INSERT INTO `znote_paypal` VALUES ('', ?, ?, ?, 0, ?);", [ $reportId, 'report@admin' . (string)($user_data['name'] ?? '') . ' to ' . (string)$account['email'], $accountId, $price, ] ); $newPoints = ((int)$balance['points']) + $price; $db->execute( "UPDATE `znote_accounts` SET `points` = ? WHERE `account_id` = ?;", [$newPoints, $accountId] ); return true; }); if ($rewarded) { acp_log('reports.reward', $playerName, ['points' => $price, 'report_id' => $reportId]); acp_flash_success(t('acp.rep.points_received', ['name' => h($playerName), 'price' => (int)$price])); } else { acp_flash_error(t('acp.rep.no_account_row')); } } else { acp_flash_error(t('acp.rep.no_account_found', ['name' => '' . h($playerName) . ''])); } } acp_redirect('reports'); } // --------------------------------------------------------------------------- // Load and group // --------------------------------------------------------------------------- $rows = db()->fetchAll(" SELECT `id`, `name`, `posx`, `posy`, `posz`, `report_description`, `date`, `status` FROM `znote_player_reports` ORDER BY `id` DESC; "); $reports = []; $total = 0; if (is_array($rows)) { foreach ($rows as $r) { $reports[(int)$r['status']][(int)$r['id']] = $r; $total++; } } ksort($reports); // Report being edited $editing = null; if (($_GET['action'] ?? '') === 'edit') { $editId = intv($_GET['id'] ?? 0); foreach ($reports as $group) { if (isset($group[$editId])) { $editing = $group[$editId]; break; } } if ($editing === null) { acp_flash_error(t('acp.rep.not_found')); acp_redirect('reports'); } } ?>
(int)$editing['id']]) ?>

/pos , ,


$group): ?>
>

count($group)]) ?>

#  
,,