diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-04-28 14:58:24 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-04-28 14:58:24 +0000 |
commit | cbac09f609f1cf9ddd85084576ace1dfe7f3690e (patch) | |
tree | e810e6368627ef9b1857e0b980cee9eff861d19d /tinydns-controller.lua | |
parent | 4d2325161be2448fb521b1aacc02965e9dfaba64 (diff) | |
download | acf-tinydns-cbac09f609f1cf9ddd85084576ace1dfe7f3690e.tar.bz2 acf-tinydns-cbac09f609f1cf9ddd85084576ace1dfe7f3690e.tar.xz |
Now you can delete config-files that you no longer want.
Validation is done so you can't remove wrong files (but you can remove any file within /etc/tinydns/)
git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@1050 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'tinydns-controller.lua')
-rw-r--r-- | tinydns-controller.lua | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/tinydns-controller.lua b/tinydns-controller.lua index e13f001..2dd6af4 100644 --- a/tinydns-controller.lua +++ b/tinydns-controller.lua @@ -265,6 +265,7 @@ function expert(self) end if (#create.name.errtxt == 0) then create.cmdnew.descr = "* File was created" + redirect(self, "edit?name=" .. (self.clientdata.name or "")) end end @@ -338,7 +339,7 @@ function edit(self) }) if (self.clientdata.cmddelete) then - redirect(self, "confirmaction") + redirect(self, "confirmaction?action=delete&name=" .. (self.clientdata.name or "")) end if (modifications) then @@ -361,4 +362,48 @@ function edit(self) end function confirmaction(self) + if (self.clientdata.cancel) then + redirect(self, "expert") + end + + -- See to that only allowed files are modified + local fileexists, fileerrros = self.model:get_filedetails(self.clientdata.name) + if not (fileexists) then + redirect(self) + end + + local output = {} + output.cancel = cfe({ + name="cancel", + value="Cancel", + type="submit", + }) + output.cmddelete = cfe({ + name="cmddelete", + label="Are you sure you want to delete?", + value="Delete", + type="submit", + }) + output.name = cfe({ + name="name", + value=self.clientdata.name, + type="hidden", + }) + + output.mhdebug = cfe({ + name="mhdebug", + value=fileexists, + descr=self.clientdata, + errtxt=fileerrros, + }) + if (self.clientdata.cmddelete) then + local removesuccess, removeerrors = self.model:remove_file(self.clientdata.name) + if (removesuccess) then + redirect(self, "expert") + elseif (#removeerrors > 0) then + output.cmddelete.errtxt = removeerrors + end + end + + return output end |