diff options
Diffstat (limited to 'modules-available/usblockoff/page.inc.php')
-rw-r--r-- | modules-available/usblockoff/page.inc.php | 94 |
1 files changed, 92 insertions, 2 deletions
diff --git a/modules-available/usblockoff/page.inc.php b/modules-available/usblockoff/page.inc.php index d33765f0..9e5664fc 100644 --- a/modules-available/usblockoff/page.inc.php +++ b/modules-available/usblockoff/page.inc.php @@ -56,11 +56,13 @@ class Page_usblockoff extends Page Database::exec("DELETE FROM `usb_configs` WHERE configid=:configid", array('configid' => $configID)); } + Message::addSuccess('config-deleted'); Util::redirect('?do=usblockoff'); } protected function updateConfig() { + $result['saveAsNewConfig'] = Request::post('saveAsNewConfig', false, 'bool'); // Add new settings in usbguard-daemon.conf here: $result['RuleFile'] = Request::post('RuleFile', '', 'string'); $result['ImplicitPolicyTarget'] = Request::post('ImplicitPolicyTarget', '', 'string'); @@ -104,7 +106,7 @@ class Page_usblockoff extends Page } // INSERT IN DB - if ($id == '0') { + if ($id == '0' || $result['saveAsNewConfig']) { $dbquery = Database::exec("INSERT INTO `usb_configs` (configname, rulesconfig, daemonconfig) VALUES (:configname, :rulesconfig, :daemonconfig)", array('configname' => $configname, 'rulesconfig' => $result['rules'], @@ -116,6 +118,7 @@ class Page_usblockoff extends Page 'rulesconfig' => $result['rules'], 'daemonconfig' => implode($newDaemonConf))); } + Message::addSuccess('config-saved'); } /** @@ -133,12 +136,13 @@ class Page_usblockoff extends Page } elseif ($action === 'loadConfig') { $id = Request::any('id', 0, 'int'); $this->ajaxConfig($id); + } elseif ($action === 'genericRuleBuilder') { + $this->ajaxGenericRuleBuilder(); } } private function ajaxConfig($id) { - $form = array(); $rulesConf = null; @@ -180,10 +184,96 @@ class Page_usblockoff extends Page )); } + private function ajaxGenericRuleBuilder() { + $settings = array(); + + // TODO: Translate Operator Action etc.. + + $setting = array(); + $setting['title'] = "Action"; + $setting['select_list'] = array(array( + 'option' => 'allow', + 'active' => true, + ), + array( + 'option' => 'block', + 'active' => false, + ), + array( + 'option' => 'reject', + 'active' => false, + )); + $setting['helptext'] = array('helptext' => Dictionary::translateFile('rule', 'abr_helptext')); + $setting['property'] = 'action'; + $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)*/ + )); + } + private function ajaxDeviceList() { $usbdevices = $this->getUsbDeviceList(); + // TODO: Translate Operator Action etc.. + $settings = array(); $setting = array(); $setting['title'] = "Action"; |