summaryrefslogtreecommitdiffstats
path: root/tinydns-controller.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tinydns-controller.lua')
-rw-r--r--tinydns-controller.lua47
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