summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-10-18 19:58:50 +0000
committerTed Trask <ttrask01@yahoo.com>2013-10-18 19:58:50 +0000
commit99f69b51db21781c3775956cb03acb64b3cb7477 (patch)
treed5ce210f9a8587ecedb8663dedc021e5940d07fc
parent1d6fcde83bef7e14fd81d2d9c7425f33b39a6604 (diff)
downloadacf-asterisk-99f69b51db21781c3775956cb03acb64b3cb7477.tar.bz2
acf-asterisk-99f69b51db21781c3775956cb03acb64b3cb7477.tar.xz
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.
-rw-r--r--asterisk-controller.lua15
-rw-r--r--asterisk-model.lua16
2 files changed, 17 insertions, 14 deletions
diff --git a/asterisk-controller.lua b/asterisk-controller.lua
index 404a141..0f04d00 100644
--- a/asterisk-controller.lua
+++ b/asterisk-controller.lua
@@ -1,21 +1,22 @@
-- 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
-listfiles = function( self )
+mymodule.listfiles = function( self )
return self.model.list_files()
end
-edit = function( self )
+mymodule.edit = function( self )
return self.handle_form(self, self.model.get_file, self.model.update_file, self.clientdata, "Save", "Edit File", "File Saved")
end
+
+return mymodule
diff --git a/asterisk-model.lua b/asterisk-model.lua
index 5ce9dd4..6858e6f 100644
--- a/asterisk-model.lua
+++ b/asterisk-model.lua
@@ -1,5 +1,5 @@
-- Copyright(c) 2007 A. Brodmann - Licensed under terms of GPL2
-module (..., package.seeall)
+local mymodule = {}
-- Load libraries
modelfunctions = require("modelfunctions")
@@ -24,23 +24,23 @@ end
-- ################################################################################
-- PUBLIC FUNCTIONS
-get_status = function()
+mymodule.get_status = function()
return modelfunctions.getstatus(processname, packagename, "Asterisk Status")
end
-function get_startstop(self, clientdata)
+mymodule.get_startstop = function(self, clientdata)
return modelfunctions.get_startstop(processname)
end
-function startstop_service(self, startstop, action)
+mymodule.startstop_service = function(self, startstop, action)
return modelfunctions.startstop_service(startstop, action)
end
-get_file = function(self, clientdata)
+mymodule.get_file = function(self, clientdata)
return modelfunctions.getfiledetails(clientdata.filename, is_valid_filename)
end
-update_file = function(self, filedetails)
+mymodule.update_file = function(self, filedetails)
local ret = modelfunctions.setfiledetails(self, filedetails, is_valid_filename)
if not ret.errtxt then
posix.chmod(filedetails.value.filename.value, "rw-------")
@@ -49,7 +49,7 @@ update_file = function(self, filedetails)
return ret
end
-list_files = function()
+mymodule.list_files = function()
local retval = {}
for file in fs.find(null, baseurl) do
local details = fs.stat(file)
@@ -61,3 +61,5 @@ list_files = function()
table.sort(retval, function(a,b) return a.filename < b.filename end)
return cfe({ type="structure", value=retval, label="List of Asterisk files" })
end
+
+return mymodule