summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorJannik Schönartz2018-03-20 20:28:59 +0100
committerJannik Schönartz2018-03-20 20:28:59 +0100
commitaf878507421586e7d3191135238715d12412e225 (patch)
tree42bd650c669d23a86fc206a9678ae8b6039f8913 /modules-available
parentMerge branch 'usb-lock-off' into usb-lock-off (diff)
downloadslx-admin-af878507421586e7d3191135238715d12412e225.tar.gz
slx-admin-af878507421586e7d3191135238715d12412e225.tar.xz
slx-admin-af878507421586e7d3191135238715d12412e225.zip
[usb-lock-off] Some bug fixes with wrong written targts in the db.
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/usblockoff/page.inc.php35
-rw-r--r--modules-available/usblockoff/templates/usb-edit-rule.html1
2 files changed, 29 insertions, 7 deletions
diff --git a/modules-available/usblockoff/page.inc.php b/modules-available/usblockoff/page.inc.php
index 40e0ff78..ee3358c3 100644
--- a/modules-available/usblockoff/page.inc.php
+++ b/modules-available/usblockoff/page.inc.php
@@ -69,13 +69,30 @@ class Page_usblockoff extends Page
}
private function editRule() {
+ $ruleid = Request::post('ruleid', 0, 'int');
+ $attributes = json_decode(Request::post('attributes', '', 'string'), true);
- $attributes = Request::post('attributes', '', 'string');
- $attributes = json_decode($attributes);
+ if ($ruleid != 0) {
+ Database::exec("DELETE FROM `usb_rule_prop` WHERE ruleid=:ruleid", array('ruleid' => $ruleid));
+ }
- foreach ($attributes as $a) {
- // TODO: get attributes with $a['prop'] and $a['value'] and save or UPDATE it in the db.
+ // TODO: Prepare array for the insert. prop- has to be cut and vid:pid = id
+ $insert_att = 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;
}
+
+ /*
+ Database::exec("INSERT INTO `usb_rule_prop` (ruleid, prop, value) VALUES (:ruleid, :prop, :val)", array(
+ 'ruleid' => $ruleid,
+ 'prop' => $a['prop'],
+ 'val' => $a['value']
+ ));
+ */
}
private function addDevices()
@@ -84,7 +101,6 @@ class Page_usblockoff extends Page
$rules = json_decode(Request::post('rules', '', 'string'), true);
- error_log(json_encode($rules));
foreach ($rules as $rule) {
$rid = (int)$rule['id'];
if($rid == 0) {
@@ -143,14 +159,17 @@ class Page_usblockoff extends Page
array(
'option' => 'allow',
'active' => true,
+ 'value' => 'allow',
),
array(
'option' => 'block',
'active' => false,
+ 'value' => 'block',
),
array(
'option' => 'reject',
'active' => false,
+ 'value' => 'reject',
));
$setting['helptext'] = array('helptext' => Dictionary::translateFile('rule', 'abr_helptext'));
$setting['property'] = 'action';
@@ -187,7 +206,6 @@ class Page_usblockoff extends Page
'ruleid' => $ruleid
));
$idList = json_decode($this->getIDList(), true);
- $pidList = array();
while ($attribute = $query->fetch(PDO::FETCH_ASSOC)) {
$attributesHtml = '';
@@ -264,7 +282,7 @@ class Page_usblockoff extends Page
Render::addTemplate('usb-edit-rule', array(
'configid' => $configid,
'attributes' => $attributes,
- 'pidList' => array_values($pidList),
+ 'ruleid' => $ruleid,
'usbJson' => json_encode($idList),
));
}
@@ -340,14 +358,17 @@ class Page_usblockoff extends Page
$setting['select_list'] = array(array(
'option' => 'allow',
'active' => ($target == 'allow' ? true : false),
+ 'value' => 'allow',
),
array(
'option' => 'block',
'active' => ($target == 'block' ? true : false),
+ 'value' => 'block',
),
array(
'option' => 'reject',
'active' => ($target == 'reject' ? true : false),
+ 'value' => 'reject',
));
$setting['helptext'] = array('helptext' => Dictionary::translateFile('rule', 'abr_helptext'));
$setting['property'] = 'action';
diff --git a/modules-available/usblockoff/templates/usb-edit-rule.html b/modules-available/usblockoff/templates/usb-edit-rule.html
index ec14d5ab..296d3bf7 100644
--- a/modules-available/usblockoff/templates/usb-edit-rule.html
+++ b/modules-available/usblockoff/templates/usb-edit-rule.html
@@ -2,6 +2,7 @@
<input type="hidden" name="token" value="{{token}}">
<input type="hidden" name="action" value="editRule">
<input type="hidden" name="configid" value="{{configid}}" id="configid">
+ <input type="hidden" name="ruleid" value="{{ruleid}}" id="ruleid">
<input type="hidden" name="attributes" value="" id="attributes">
<div class="panel panel-default">