summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorJannik Schönartz2017-12-28 16:28:09 +0100
committerJannik Schönartz2017-12-28 16:28:09 +0100
commit28975976602155feb5ac7a7c21307dc834681865 (patch)
tree29b59b3b524b4eae7893009ab86a88ac88b50562 /modules-available
parentMerge branch 'origin/master' into usb-lock-off (diff)
downloadslx-admin-28975976602155feb5ac7a7c21307dc834681865.tar.gz
slx-admin-28975976602155feb5ac7a7c21307dc834681865.tar.xz
slx-admin-28975976602155feb5ac7a7c21307dc834681865.zip
[usb-lock-off] Specific usb props only added if the usb device have a serial number.
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/usblockoff/api.inc.php33
1 files changed, 19 insertions, 14 deletions
diff --git a/modules-available/usblockoff/api.inc.php b/modules-available/usblockoff/api.inc.php
index 318f21a1..708303a8 100644
--- a/modules-available/usblockoff/api.inc.php
+++ b/modules-available/usblockoff/api.inc.php
@@ -64,23 +64,28 @@ function newDevice($id, $serial, $hwProps, $deviceProps)
// TODO:
addHwProps('statistic_hw_prop', $hwid, $hwProps);
- // 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));
-
- if (empty($dbquery2)) {
- Database::exec("INSERT INTO `usblockoff_hw` (hwid, serial) VALUES (:hwid, :serial)", array(
+ // Only when the device has a serial number add the specific hw props.
+ // TODO: !!! Are there data transfer devices without a serial number? !!!
+ if (!empty($serial)) {
+ // 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));
- // Add all the prop values to the usblockoff_hw_prop table.
- // PROP: serial, machineuuid, time, user, ruleInformation, Port, hash, interface-policy
- addUSBHwProps('usblockoff_hw_prop', $hwid, $serial, $deviceProps);
+ if (empty($dbquery2)) {
+ Database::exec("INSERT INTO `usblockoff_hw` (hwid, serial) VALUES (:hwid, :serial)", array(
+ 'hwid' => $hwid,
+ 'serial' => $serial
+ ));
+ }
- echo "Successfully added";
+ // Add all the prop values to the usblockoff_hw_prop table.
+ // PROP: serial, machineuuid, time, user, ruleInformation, Port, hash, interface-policy
+ addUSBHwProps('usblockoff_hw_prop', $hwid, $serial, $deviceProps);
+ echo "Successfully added";
+ } else {
+ echo "No specific props were added. Device has no serial number";
+ }
}
function addHwProps($table, $hwid, $propArray) {