summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorJannik Schönartz2017-12-28 17:47:56 +0100
committerJannik Schönartz2017-12-28 17:47:56 +0100
commitdd711a1bb4f92cc8e8ab9ca192f43917ae4883d5 (patch)
tree1c6e021b1bd692d60adead8af7cdf974a580dae7 /modules-available
parent[usb-lock-off] Specific usb props only added if the usb device have a serial ... (diff)
downloadslx-admin-dd711a1bb4f92cc8e8ab9ca192f43917ae4883d5.tar.gz
slx-admin-dd711a1bb4f92cc8e8ab9ca192f43917ae4883d5.tar.xz
slx-admin-dd711a1bb4f92cc8e8ab9ca192f43917ae4883d5.zip
[usb-lock-off] API device delete function now works with the new db struct.
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/usblockoff/api.inc.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/modules-available/usblockoff/api.inc.php b/modules-available/usblockoff/api.inc.php
index 708303a8..9467d67b 100644
--- a/modules-available/usblockoff/api.inc.php
+++ b/modules-available/usblockoff/api.inc.php
@@ -38,8 +38,9 @@ function HandleParameters()
);
newDevice($id, $serial, $hwProps, $deviceProps);
} elseif ($getAction == "deletedevice") {
+ $id = Request::get('id', '', 'string');
$serial = Request::get('serial', '', 'string');
- deleteDevice($serial);
+ deleteDevice($id, $serial);
}
}
@@ -70,7 +71,8 @@ function newDevice($id, $serial, $hwProps, $deviceProps)
// Add the hwid -> serial in the usblockoff_hw table if not already existent.
$dbquery2 = Database::queryFirst("Select * FROM `usblockoff_hw` WHERE hwid=:hwid AND serial=:serial", array(
'hwid' => $hwid,
- 'serial' => $serial));
+ 'serial' => $serial
+ ));
if (empty($dbquery2)) {
Database::exec("INSERT INTO `usblockoff_hw` (hwid, serial) VALUES (:hwid, :serial)", array(
@@ -163,8 +165,19 @@ function newDevice($id, $serial, $name, $ip, $ruleInformation)
*
* @param string $serial USB-Device serial number.
*/
-// TODO: Edit for the new db struct.
-function deleteDevice($serial)
+function deleteDevice($id, $serial)
{
- $dbquery = Database::exec("DELETE FROM `usb_devices` WHERE serial=:serial", array('serial' => $serial));
+ // For the Old db struct
+ //Database::exec("DELETE FROM `usb_devices` WHERE serial=:serial", array('serial' => $serial));
+
+ $hw = Database::queryFirst("SELECT * FROM `statistic_hw` WHERE hwname=:id", array('id' => $id));
+ if($hw['hwtype'] === DeviceType::USB) {
+ Database::exec("DELETE FROM `usblockoff_hw` WHERE hwid=:hwid AND serial=:serial", array(
+ 'hwid' => $hw['hwid'],
+ 'serial' => $serial));
+ echo "Successfully deleted.";
+ } else {
+ echo "Type is not a USB device";
+ }
+
}