diff options
Diffstat (limited to 'modules-available/usblockoff/page.inc.php')
-rw-r--r-- | modules-available/usblockoff/page.inc.php | 83 |
1 files changed, 24 insertions, 59 deletions
diff --git a/modules-available/usblockoff/page.inc.php b/modules-available/usblockoff/page.inc.php index 9e5664fc..c02fadba 100644 --- a/modules-available/usblockoff/page.inc.php +++ b/modules-available/usblockoff/page.inc.php @@ -136,12 +136,18 @@ class Page_usblockoff extends Page } elseif ($action === 'loadConfig') { $id = Request::any('id', 0, 'int'); $this->ajaxConfig($id); + } elseif ($action === 'loadDaemonConfig') { + $id = Request::any('id', 0, 'int'); + $this->ajaxDaemonConfig($id); + } elseif ($action === 'loadRulesConfig') { + $id = Request::any('id', 0, 'int'); + $this->ajaxRulesConfig($id); } elseif ($action === 'genericRuleBuilder') { $this->ajaxGenericRuleBuilder(); } } - private function ajaxConfig($id) + private function ajaxDaemonConfig($id) { $form = array(); $rulesConf = null; @@ -149,12 +155,10 @@ class Page_usblockoff extends Page if ($id == 0) { $currentdir = getcwd(); - $rulesConf = file_get_contents($currentdir . '/modules/usblockoff/inc/default-configs/rules.conf'); $daemonConf = file($currentdir . '/modules/usblockoff/inc/default-configs/usbguard-daemon.conf'); } else { $dbquery = Database::queryFirst("SELECT * FROM `usb_configs` WHERE configid=:id", array('id' => $id)); $daemonConf = explode("\r\n", $dbquery['daemonconfig']); - $rulesConf = $dbquery['rulesconfig']; } $element = array(); @@ -178,8 +182,24 @@ class Page_usblockoff extends Page } } - echo Render::parse('usb-configuration', array( + echo Render::parse('usb-daemon-config', array( 'list' => array_values($form), + )); + } + + private function ajaxRulesConfig($id) { + $rulesConf = null; + + if ($id == 0) { + $currentdir = getcwd(); + + $rulesConf = file_get_contents($currentdir . '/modules/usblockoff/inc/default-configs/rules.conf'); + } else { + $dbquery = Database::queryFirst("SELECT * FROM `usb_configs` WHERE configid=:id", array('id' => $id)); + $rulesConf = $dbquery['rulesconfig']; + } + + echo Render::parse('usb-rules-config', array( 'rules' => $rulesConf, )); } @@ -208,63 +228,8 @@ class Page_usblockoff extends Page $setting['settingHtml'] = Render::parse('server-prop-dropdown', (array)$setting); $settings[] = $setting; - /* - $setting = array(); - $setting['title'] = "Operator"; - $setting['select_list'] = array( - array( - 'option' => 'all-of', - 'active' => true, - ), - array( - 'option' => 'one-of', - 'active' => false, - ), - array( - 'option' => 'none-of', - 'active' => false, - ), - array( - 'option' => 'equals', - 'active' => false, - ), - array( - 'option' => 'equals-ordered', - 'active' => false, - ) - ); - $setting['helptext'] = array('helptext' => Dictionary::translateFile('rule', 'operator_helptext')); - $setting['property'] = 'action'; - $setting['settingHtml'] = Render::parse('server-prop-dropdown', (array)$setting); - $settings[] = $setting; - */ - - /* THIS IS DONE in HTML code because server-prop-dropdown doens't have a value option for a selected - $casualMode = array(); - $setting = array(); - // $setting['helptext'] = array('helptext' => Dictionary::translateFile('rule', '')) - $setting['title'] = 'Device Class'; - $setting['select_list'] = array( - array( - 'option' => 'USB-Sticks', - 'active' => true, - ), - array( - 'option' => 'HID-Devices', - 'active' => false, - ), - array( - 'option' => 'All', - 'active' => false, - ) - ); - $setting['property'] = 'action'; - $setting['settingHtml'] = Render::parse('server-prop-dropdown', (array)$setting); - $casualMode[] = $setting;*/ - echo Render::parse('usb-add-generic-rule', array( 'settings' => array_values($settings), - /*'casual' => array_values($casualMode)*/ )); } |