Commit 5f9f108e authored by Ted Trask's avatar Ted Trask

Remove all calls to 'module' in preparation for move to Lua 5.2

Use mymodule parameter for module definition.
This was also helpful in revealing places where the code relied on the global environment.
parent bdabdb5e
-- the squid controller
local mymodule = {}
module (..., package.seeall)
mymodule.default_action = "status"
default_action = "status"
status = function( self )
mymodule.status = function( self )
return self.model.get_status()
end
startstop = function( self )
mymodule.startstop = function( self )
return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata)
end
general = function( self )
mymodule.general = function( self )
return self.handle_form(self, self.model.read_general_config, self.model.update_general_config, self.clientdata, "Save", "Edit General Configuration", "General Configuration Set")
end
listfiles = function( self )
mymodule.listfiles = function( self )
return self.model.list_files()
end
listconfigfiles = function( self )
mymodule.listconfigfiles = function( self )
return self.model.list_config_files()
end
edit = function( self )
mymodule.edit = function( self )
return self.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
return mymodule
-- Copyright(c) 2007 A. Brodmann - Licensed under terms of GPL2
module (..., package.seeall)
local mymodule = {}
-- Load libraries
modelfunctions = require("modelfunctions")
......@@ -78,19 +78,19 @@ end
-- ################################################################################
-- PUBLIC FUNCTIONS
get_status = function()
mymodule.get_status = function()
return modelfunctions.getstatus(processname, packagename, "Dans Guardian Status")
end
function get_startstop(self, clientdata)
function mymodule.get_startstop(self, clientdata)
return modelfunctions.get_startstop(processname)
end
function startstop_service(self, startstop, action)
function mymodule.startstop_service(self, startstop, action)
return modelfunctions.startstop_service(startstop, action)
end
read_general_config = function()
mymodule.read_general_config = function()
local retval = { filterip = cfe({ label="Filter IP", descr="Leave blank to listen on all IPs" }),
filterport = cfe({ label="Filter Port" }),
proxyip = cfe({ label="Proxy IP" }),
......@@ -116,7 +116,7 @@ read_general_config = function()
return cfe({ type="group", value=retval, label="Dansguardian General Config" })
end
update_general_config = function(self, config)
mymodule.update_general_config = function(self, config)
local success, config = validate_general_config(config)
if success then
......@@ -139,15 +139,15 @@ update_general_config = function(self, config)
return config
end
get_file = function(filename)
mymodule.get_file = function(filename)
return modelfunctions.getfiledetails(filename, is_valid_filename)
end
update_file = function(self, filedetails)
mymodule.update_file = function(self, filedetails)
return modelfunctions.setfiledetails(self, filedetails, is_valid_filename)
end
list_files = function()
mymodule.list_files = function()
local retval = {}
for file in fs.find(null, baseurl) do
local details = fs.stat(file)
......@@ -160,7 +160,7 @@ list_files = function()
return cfe({ type="structure", value=retval, label="List of Dansguardian files" })
end
list_config_files = function()
mymodule.list_config_files = function()
local list = {}
local details = fs.stat(dansguardiancfg) or {}
list[1] = { filename=dansguardiancfg, size = details.size or 0, mtime = details.mtime or "---" }
......@@ -260,3 +260,5 @@ get_category = function(category, object)
return retval
end
--]]
return mymodule
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment