diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-01-22 14:34:18 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-01-22 14:34:18 +0000 |
commit | 3928babbc55caa5c8b3914fa0a4c26a916c0dbbb (patch) | |
tree | 68a15a0f87652886fbc504ceafd6c4ee728bea45 /lbu-controller.lua | |
parent | 7cf8d1ac44d78983252fc0279b955463c6dd68e6 (diff) | |
download | acf-alpine-conf-3928babbc55caa5c8b3914fa0a4c26a916c0dbbb.tar.bz2 acf-alpine-conf-3928babbc55caa5c8b3914fa0a4c26a916c0dbbb.tar.xz |
Now you can modify the configurations.
Committing and SimulatingCommit also works (still work in progress) Needs checks when creating encrypted archives.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@626 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lbu-controller.lua')
-rw-r--r-- | lbu-controller.lua | 104 |
1 files changed, 20 insertions, 84 deletions
diff --git a/lbu-controller.lua b/lbu-controller.lua index e6fa4f4..bd08d1d 100644 --- a/lbu-controller.lua +++ b/lbu-controller.lua @@ -25,6 +25,7 @@ status = function (self) end config = function (self) + local cmdresult if (self.clientdata.cmd_delete_excluded) and (self.clientdata.lbu_excluded) then cmdresult = self.model:lbuincexcl("exclude", self.clientdata.lbu_excluded, "remove") end @@ -32,7 +33,15 @@ config = function (self) cmdresult = self.model:lbuincexcl("include", self.clientdata.lbu_included, "remove") end if (self.clientdata.config_submit) then - cmdresult = self.model:editconfig(self.clientdata) + local variables="LBU_MEDIA DEFAULT_CIPHER PASSWORD" + cmdresult = {} + for var in string.gmatch(variables, "%S+") do + cmdresult[var] = self.model:editconfig(var, self.clientdata[var], "change_value") + end + local variables="ENCRYPTION" + for var in string.gmatch(variables, "%S+") do + cmdresult[var] = self.model:editconfig(var, self.clientdata[var], "change_state") + end end if (self.clientdata.cmd_add_include) and (self.clientdata.item_add_include) then cmdresult = self.model:lbuincexcl("include", self.clientdata.item_add_include, "add") @@ -51,91 +60,18 @@ config = function (self) url = url, } ) end --- ################################################################################ --- OLD FUNCTIONS - ---[[ function commit(self) - local ret = { - script=ENV["SCRIPT_NAME"], - prefix=self.conf.prefix, - controller = self.conf.controller, - action="commit", - data={}, - title="LBU", - text={}, - } - if self.clientdata.commit then - local result, report = self.model:commit() - local label = result and "Report" or "Error" - ret.text[#ret.text + 1] = { label=label, content=report } - else - for i,v in ipairs(self.model:list(nil)) do - ret.data[#ret.data + 1] = { - status = v.status, - name = v.name, - } + local cmdresult + local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller + if (self.clientdata.lbusimulate) then + cmdresult = self.model:getsimulate() end - end - ret.note=getNotes(self) - return ret -end ---]] - ---[[ -local function getNotes(self) - ret = {} - for k,v in pairs(cfgfile.model:list(nil)) do - if v.status then - ret[#ret + 1] = { - content = "There are some configuration changes. Please do not forget to save." - } - break + if (self.clientdata.lbucommit) then + cmdresult = self.model:getcommit() end - end - return ret -end ---]] ---[[ -xxxstatus = function(self) - return { - list=cfgfile.model:list(function(x) return x.app == "lbu" end), - script=ENV["SCRIPT_NAME"], - prefix=self.conf.prefix, - controller=self.conf.controller, - action="update", - note=getNotes(self), - } + return ( {status = self.model:getstatus(), + cmdresult = cmdresult, + clientdata = self.clientdata, + url = url, } ) end ---]] - ---[[ -update = function(self) - local id = tonumber(self.clientdata.id) or -1 - local result - local data - - result, data = cfgfile.model:get(id) - if not result then return list_redir(self) end - - if self.clientdata.cmd then - for k,v in pairs (data) do - if self.clientdata[k] then - data[k].value = self.clientdata[k] - end - end - result, data = cfgfile.model:set(id, data) - if result then return list_redir(self) end - end - - data.cmd = cfe { type="action", value="save", label="action" } - return cfe{ type="form", - option={ script=ENV["SCRIPT_NAME"], - prefix=self.conf.prefix, - controller = self.conf.controller, - action = "update", - extra = ""}, - value = data} -end ---]] |