diff options
Diffstat (limited to 'dansguardian-controller.lua')
-rw-r--r-- | dansguardian-controller.lua | 118 |
1 files changed, 6 insertions, 112 deletions
diff --git a/dansguardian-controller.lua b/dansguardian-controller.lua index 97e2849..37470bd 100644 --- a/dansguardian-controller.lua +++ b/dansguardian-controller.lua @@ -15,123 +15,17 @@ startstop = function( self ) end general = function( self ) - - local service = {} - - -- Add a cmd button to the view - service.cmdsave = cfe({ name="cmdsave", - label="Save/Apply above settings", - value="Save", - type="submit", - }) - - if self.clientdata.cmdsave then - local conf = self.clientdata - local config = { filterip = conf.filterip, filterport = conf.filterport, - proxyip = conf.proxyip, proxyport = conf.proxyport, - accessdeniedaddress = conf.accessdeniedaddress, - naughtynesslimit = conf.naughtynesslimit - } - self.model.update_general_config( config ) - service.cmdsave.descr="* Changes has been saved!" - end - - service.config, service.cfgerr = self.model.get_general_config() - - return ( cfe ({ service = service }) ) + return controllerfunctions.handle_form(self, self.model.read_general_config, self.model.update_general_config, self.clientdata, "Save", "Edit General Configuration", "General Configuration Set") end -advanced = function( self ) - - local service = {} - - local option = { script = self.conf.script, - prefix = self.conf.prefix, - controller = self.conf.controller, - action = self.conf.action, - extra = "" - } - - service.config, service.cfgerr = self.model.get_advanced_config() - - return ( cfe ({ option = option, service = service }) ) +listfiles = function( self ) + return self.model.list_files() end -expert = function( self ) - return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.updateconfigfile, self.clientdata, "Save", "Edit Config", "Configuration Set") +listconfigfiles = function( self ) + return self.model.list_config_files() end edit = function( self ) - - if not self.clientdata.name then - redirect( self ) - end - - local service = { message="", status="", config="" } - - if self.clientdata.cmd then - if self.clientdata.cmd == "save" then - self.model.update_edit_config( self.clientdata.name, self.clientdata.config ) - redirect( self, "advanced" ) - end - end - - service.config, service.cfgerr = self.model.get_edit_config( self.clientdata.name ) - service.name = self.clientdata.name - - if service.cfgerr == "Hacker" then - redirect( self ) - end - - return ( cfe ({ service = service }) ) -end - -category = function( self ) - - local service = { message="", status="", config="", cfgerr="" } - - service.config = {} - service.config.categories = cfe({ - name="categories", - label="Categories available", - value={}, - }) - - service.config.categories = self.model.get_categories() - return ( cfe ({ service = service }) ) -end - -editcategories = function( self ) - - local info = self.model.get_category(self.clientdata.category, self.clientdata.object) - if not (info) then - redirect(self, "category") - end - - -- Add a cmd button to the view - info.cmdsave = cfe({ name="cmdsave", - label="Save/Apply above settings", - value="Save", - type="submit", - disabled="yes", - errtxt="This button is not configured to work", - }) - - info.cmddelete = cfe({ name="cmddelete", - label="Permanently remove object", - value="Delete", - type="submit", - disabled="yes", - errtxt="This button is not configured to work", - }) - - local option = { script = self.conf.script, - prefix = self.conf.prefix, - controller = self.conf.controller, - action = self.conf.action, - extra = "" - } - - return ( cfe ({ option = option, info = info, mhdebug=self.clientdata }) ) + return controllerfunctions.handle_form(self, function() return self.model.get_file(self.clientdata.filename) end, self.model.update_file, self.clientdata, "Save", "Edit File", "File Saved") end - |