fix: address code review feedback
- Fix toggle/load_order handlers to use page-reload (not JSON) responses - Remove dead jsonResponse helper method from WorkshopModController - Fix robocopy exit code detection using ROBOCOPY_EXIT: sentinel (not text parsing) - Fix rsync dry-run change detection using RSYNC_EXIT: sentinel - Remove agentIdFromRemote() stub; pass agentId directly to triggerSteamCmdDownload() logging - Fix 'enabled' checkbox default in profile_form to use ($profile['enabled'] ?? 1) - Add missing error_toggle_failed / error_order_failed lang strings Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/dbeebd0e-e7a5-469d-8a8c-e63193d1ebb0 Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
parent
8eff063a93
commit
fd860963d1
5 changed files with 59 additions and 46 deletions
|
|
@ -233,18 +233,25 @@ class WorkshopModController
|
|||
$enabled = !empty($_POST['enabled']);
|
||||
|
||||
if ($homeId <= 0 || $workshopId === '') {
|
||||
$this->jsonResponse(['ok' => false, 'error' => 'Missing parameters.']);
|
||||
print_failure($this->lang['error_missing_params'] ?? 'Missing parameters.');
|
||||
$this->handleIndex($userId, $isAdmin);
|
||||
return;
|
||||
}
|
||||
|
||||
$home = $this->getHome($homeId, $userId, $isAdmin);
|
||||
if ($home === null) {
|
||||
$this->jsonResponse(['ok' => false, 'error' => 'Access denied.']);
|
||||
print_failure($this->lang['error_home_not_found'] ?? 'Server not found.');
|
||||
$this->handleIndex($userId, $isAdmin);
|
||||
return;
|
||||
}
|
||||
|
||||
$ok = $this->repo->toggleMod($homeId, $workshopId, $enabled);
|
||||
$this->jsonResponse(['ok' => $ok]);
|
||||
if (!$ok) {
|
||||
print_failure($this->lang['error_toggle_failed'] ?? 'Failed to update mod status.');
|
||||
}
|
||||
|
||||
$_GET['home_id'] = $homeId;
|
||||
$this->handleModsPage($userId, $isAdmin);
|
||||
}
|
||||
|
||||
private function handleLoadOrder(int $userId, bool $isAdmin): void
|
||||
|
|
@ -254,18 +261,25 @@ class WorkshopModController
|
|||
$order = (int)($_POST['load_order'] ?? 0);
|
||||
|
||||
if ($homeId <= 0 || $workshopId === '') {
|
||||
$this->jsonResponse(['ok' => false, 'error' => 'Missing parameters.']);
|
||||
print_failure($this->lang['error_missing_params'] ?? 'Missing parameters.');
|
||||
$this->handleIndex($userId, $isAdmin);
|
||||
return;
|
||||
}
|
||||
|
||||
$home = $this->getHome($homeId, $userId, $isAdmin);
|
||||
if ($home === null) {
|
||||
$this->jsonResponse(['ok' => false, 'error' => 'Access denied.']);
|
||||
print_failure($this->lang['error_home_not_found'] ?? 'Server not found.');
|
||||
$this->handleIndex($userId, $isAdmin);
|
||||
return;
|
||||
}
|
||||
|
||||
$ok = $this->repo->updateLoadOrder($homeId, $workshopId, $order);
|
||||
$this->jsonResponse(['ok' => $ok]);
|
||||
if (!$ok) {
|
||||
print_failure($this->lang['error_order_failed'] ?? 'Failed to update load order.');
|
||||
}
|
||||
|
||||
$_GET['home_id'] = $homeId;
|
||||
$this->handleModsPage($userId, $isAdmin);
|
||||
}
|
||||
|
||||
private function handleSync(int $userId, bool $isAdmin): void
|
||||
|
|
@ -360,13 +374,6 @@ class WorkshopModController
|
|||
require __DIR__ . '/../views/' . $view . '.php';
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $data */
|
||||
private function jsonResponse(array $data): void
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
private function loadLang(): array
|
||||
{
|
||||
$file = __DIR__ . '/../lang/en_US.php';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue