Fixes host editing
parent
5d715e4aac
commit
e084a04305
|
@ -65,26 +65,20 @@ class Host {
|
|||
}
|
||||
|
||||
// edit an existing host
|
||||
public function editAgent($platform_id, $updatedAgent) {
|
||||
public function editHost($platform_id, $updatedHost) {
|
||||
try {
|
||||
$sql = 'UPDATE jilo_agents SET
|
||||
agent_type_id = :agent_type_id,
|
||||
url = :url,
|
||||
secret_key = :secret_key,
|
||||
check_period = :check_period
|
||||
$sql = 'UPDATE hosts SET
|
||||
address = :address,
|
||||
port = :port,
|
||||
name = :name,
|
||||
WHERE
|
||||
id = :agent_id
|
||||
AND
|
||||
platform_id = :platform_id';
|
||||
id = :id';
|
||||
|
||||
$query = $this->db->prepare($sql);
|
||||
$query->execute([
|
||||
':agent_type_id' => $updatedAgent['agent_type_id'],
|
||||
':url' => $updatedAgent['url'],
|
||||
':secret_key' => $updatedAgent['secret_key'],
|
||||
':check_period' => $updatedAgent['check_period'],
|
||||
':agent_id' => $updatedAgent['id'],
|
||||
':platform_id' => $platform_id,
|
||||
':address' => $updatedHost['address'],
|
||||
':port' => $updatedHost['port'],
|
||||
':name' => $updatedHost['name'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -82,6 +82,21 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
$platform = $_POST['platform'];
|
||||
$platformObject->deletePlatform($platform);
|
||||
|
||||
// an update to an existing host
|
||||
} elseif (isset($_POST['host'])) {
|
||||
$updatedHost = [
|
||||
'id' => $host,
|
||||
'address' => $address,
|
||||
'port' => $port,
|
||||
'name' => $name,
|
||||
];
|
||||
$result = $hostObject->editHost($platform_id, $updatedHost);
|
||||
if ($result === true) {
|
||||
$_SESSION['notice'] = "Host id \"{$_REQUEST['host']}\" edited.";
|
||||
} else {
|
||||
$_SESSION['error'] = "Editing the host failed. Error: $result";
|
||||
}
|
||||
|
||||
// an update to an existing agent
|
||||
} elseif (isset($_POST['agent'])) {
|
||||
$updatedAgent = [
|
||||
|
|
Loading…
Reference in New Issue