diff --git a/app/classes/host.php b/app/classes/host.php index 8b394fa..706db94 100644 --- a/app/classes/host.php +++ b/app/classes/host.php @@ -96,14 +96,14 @@ class Host { // delete a host - public function deleteAgent($agent_id) { + public function deleteHost($host_id) { try { - $sql = 'DELETE FROM jilo_agents + $sql = 'DELETE FROM hosts WHERE - id = :agent_id'; + id = :host_id'; $query = $this->db->prepare($sql); - $query->bindParam(':agent_id', $agent_id); + $query->bindParam(':host_id', $host_id); $query->execute(); return true; diff --git a/app/pages/config.php b/app/pages/config.php index 3e303c3..b333ce2 100644 --- a/app/pages/config.php +++ b/app/pages/config.php @@ -2,6 +2,7 @@ $action = $_REQUEST['action'] ?? ''; $agent = $_REQUEST['agent'] ?? ''; +$host = $_REQUEST['host'] ?? ''; require '../app/classes/config.php'; require '../app/classes/host.php'; @@ -58,6 +59,15 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { ]; $platformObject->addPlatform($newPlatform); + // deleting a host + } elseif (isset($_POST['delete']) && isset($_POST['host']) && $_POST['delete'] === 'true') { + $result = $hostObject->deleteHost($host); + if ($result === true) { + $_SESSION['notice'] = "Host id \"{$_REQUEST['host']}\" deleted."; + } else { + $_SESSION['error'] = "Deleting the host failed. Error: $result"; + } + // deleting an agent } elseif (isset($_POST['delete']) && isset($_POST['agent']) && $_POST['delete'] === 'true') { $result = $agentObject->deleteAgent($agent); @@ -151,6 +161,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { } elseif (isset($action) && $action === 'edit') { include '../app/templates/config-host-edit.php'; } elseif (isset($action) && $action === 'delete') { + $hostDetails = $hostObject->getHostDetails($platform_id, $agent); include '../app/templates/config-host-delete.php'; } else { if ($userObject->hasRight($user_id, 'view config file')) { diff --git a/app/templates/config-host-delete.php b/app/templates/config-host-delete.php new file mode 100644 index 0000000..8a84230 --- /dev/null +++ b/app/templates/config-host-delete.php @@ -0,0 +1,32 @@ + + +
Jilo configuration for Jitsi platform "= htmlspecialchars($platformDetails[0]['name']) ?>"
+delete a host:
+ +