Fix up the device delete so it removes all sub data

This commit is contained in:
Mark Crane
2014-05-22 06:20:30 +00:00
parent 3e5c77bb12
commit 1e2ae8076a

View File

@@ -40,24 +40,48 @@ else {
}
//get the id
if (count($_GET)>0) {
if (count($_GET) > 0) {
$id = check_str($_GET["id"]);
}
//delete the data
if (strlen($id)>0) {
$sql = "delete from v_devices ";
$sql .= "where device_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
//delete the data and subdata
if (strlen($id) > 0) {
//delete device_lines
$sql = "delete from v_device_lines ";
$sql .= "where device_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
//delete device_keys
$sql = "delete from v_device_keys ";
$sql .= "where device_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
//delete device_settings
$sql = "delete from v_device_settings ";
$sql .= "where device_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
//delete the device
$sql = "delete from v_devices ";
$sql .= "where device_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
}
//write the provision files
require_once "app/provision/provision_write.php";
$_SESSION["message"] = $text['message-delete'];
header("Location: devices.php");
return;
//set the message and redirect the user
$_SESSION["message"] = $text['message-delete'];
header("Location: devices.php");
return;
?>