From 6d07744ab78f837368e76b110f271d2098804fb2 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Sun, 22 Sep 2024 12:26:19 +0300 Subject: [PATCH] Fixes agent config --- app/pages/agents.php | 30 +++++++++++++++--------------- app/pages/config.php | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/app/pages/agents.php b/app/pages/agents.php index ca6bf68..1649c15 100644 --- a/app/pages/agents.php +++ b/app/pages/agents.php @@ -33,21 +33,21 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { // } // an update to an existing agent - } else { - $updatedAgent = [ - 'id' => $agent, - 'type_id' => 1, - 'url' => $_POST['url'], - 'secret_key' => $_POST['secret_key'], - ]; - $result = $agentObject->editAgent($platform_id, $updatedAgent); - if ($result === true) { - $_SESSION['notice'] = "Agent id \"{$_REQUEST['agent']}\" edited."; - } else { - $_SESSION['error'] = "Editing the agent failed. Error: $result"; - } - - } +// } else { +// $updatedAgent = [ +// 'id' => $agent, +// 'type_id' => 1, +// 'url' => $_POST['url'], +// 'secret_key' => $_POST['secret_key'], +// ]; +// $result = $agentObject->editAgent($platform_id, $updatedAgent); +// if ($result === true) { +// $_SESSION['notice'] = "Agent id \"{$_REQUEST['agent']}\" edited."; +// } else { +// $_SESSION['error'] = "Editing the agent failed. Error: $result"; +// } +// +// } header("Location: $app_root?platform=$platform_id&page=agents"); exit(); diff --git a/app/pages/config.php b/app/pages/config.php index e4f61ea..e6c6dac 100644 --- a/app/pages/config.php +++ b/app/pages/config.php @@ -54,6 +54,21 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $platform = $_POST['platform']; $platformObject->deletePlatform($platform); + // an update to an existing agent + } elseif (isset($_POST['agent'])) { + $updatedAgent = [ + 'id' => $agent, + 'agent_type_id' => 1, + 'url' => $_POST['url'], + 'secret_key' => $_POST['secret_key'], + ]; + $result = $agentObject->editAgent($platform_id, $updatedAgent); + if ($result === true) { + $_SESSION['notice'] = "Agent id \"{$_REQUEST['agent']}\" edited."; + } else { + $_SESSION['error'] = "Editing the agent failed. Error: $result"; + } + // an update to an existing platform } else { $platform = $_POST['platform'];