summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorJannik Schönartz2018-03-27 09:36:12 +0200
committerJannik Schönartz2018-03-27 09:36:12 +0200
commit500feb1671439e3e23af0575d2986e02b9c81fe4 (patch)
tree475b244e2db9f5e06068c379ac0488cdb3fd59ab /modules-available
parent[usb-lock-off] Some bug fixes with wrong written targts in the db. (diff)
downloadslx-admin-500feb1671439e3e23af0575d2986e02b9c81fe4.tar.gz
slx-admin-500feb1671439e3e23af0575d2986e02b9c81fe4.tar.xz
slx-admin-500feb1671439e3e23af0575d2986e02b9c81fe4.zip
[usb-lock-off] Saving the edited rule is now working properly.
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/usblockoff/page.inc.php32
1 files changed, 18 insertions, 14 deletions
diff --git a/modules-available/usblockoff/page.inc.php b/modules-available/usblockoff/page.inc.php
index ee3358c3..e978eec2 100644
--- a/modules-available/usblockoff/page.inc.php
+++ b/modules-available/usblockoff/page.inc.php
@@ -76,23 +76,27 @@ class Page_usblockoff extends Page
Database::exec("DELETE FROM `usb_rule_prop` WHERE ruleid=:ruleid", array('ruleid' => $ruleid));
}
- // TODO: Prepare array for the insert. prop- has to be cut and vid:pid = id
- $insert_att = array();
+ // Prepare array for the insert. prop- has to be cut and vid:pid = id
+ $a = array();
foreach ($attributes as $att) {
- $a = array();
- // TODO: SPECIAL CASE: PID AND VID needs to put together to VID:PID = ID
- $a['prop'] = substr($att['prop'], 5);
- $a['value'] = $att['value'];
- $insert_att[] = $a;
+ // SPECIAL CASE: PID AND VID needs to put together to VID:PID = ID
+ if (substr($att['prop'], 5) === "vid") {
+ $a['id'] = $att['value'] . ':' . $a['id'];
+ } else if (substr($att['prop'], 5) === "pid") {
+ $a['id'] = $a['id'] . $att['value'];
+ } else {
+ $a[substr($att['prop'], 5)] = $att['value'];
+ }
}
- /*
- Database::exec("INSERT INTO `usb_rule_prop` (ruleid, prop, value) VALUES (:ruleid, :prop, :val)", array(
- 'ruleid' => $ruleid,
- 'prop' => $a['prop'],
- 'val' => $a['value']
- ));
- */
+ foreach ($a as $key => $value) {
+ // TODO: Better in one query?
+ Database::exec("INSERT INTO `usb_rule_prop` (ruleid, prop, value) VALUES (:ruleid, :prop, :val)", array(
+ 'ruleid' => $ruleid,
+ 'prop' => $key,
+ 'val' => $value
+ ));
+ }
}
private function addDevices()