summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2012-04-22 12:10:57 +0000
committerTed Trask <ttrask01@yahoo.com>2012-04-22 12:10:57 +0000
commita9a33b02fee4f62e1ccc885fe29cbf41fb957204 (patch)
tree77d4ad008babdf64bea13216817b6f9a8b8f5141 /app
parent733028a932feef66d0d2e93ff909ceccc63a4eb3 (diff)
downloadacf-core-a9a33b02fee4f62e1ccc885fe29cbf41fb957204.tar.bz2
acf-core-a9a33b02fee4f62e1ccc885fe29cbf41fb957204.tar.xz
Updated password and skins for latest handle_form changes
Diffstat (limited to 'app')
-rw-r--r--app/acf-util/password-controller.lua16
-rw-r--r--app/acf-util/password-model.lua4
-rw-r--r--app/acf-util/skins-controller.lua2
-rw-r--r--app/acf-util/skins-model.lua35
-rw-r--r--app/acf-util/skins-read-html.lsp2
5 files changed, 28 insertions, 31 deletions
diff --git a/app/acf-util/password-controller.lua b/app/acf-util/password-controller.lua
index 5ff8145..20248f3 100644
--- a/app/acf-util/password-controller.lua
+++ b/app/acf-util/password-controller.lua
@@ -24,7 +24,7 @@ function editme(self)
end
value.value.roles = nil
return value
- end, function(value)
+ end, function(self, value)
-- If password and password_confirm are blank, don't set them
local pw, pwc
if value.value.password.value == "" and value.value.password_confirm.value == "" then
@@ -45,7 +45,7 @@ end
function edituser(self)
return self.handle_form(self, function()
return self.model.read_user(self, self.clientdata.userid)
- end, function(value)
+ end, function(self, value)
-- If password and password_confirm are blank, don't set them
local pw, pwc
if value.value.password.value == "" and value.value.password_confirm.value == "" then
@@ -64,17 +64,9 @@ function edituser(self)
end
function newuser(self)
- return self.handle_form(self, function()
- return self.model.read_user(self)
- end, function(value)
- return self.model.create_user(self, value)
- end, self.clientdata, "Create", "Create New User", "Created user")
+ return self.handle_form(self, self.model.read_user, self.model.create_user, self.clientdata, "Create", "Create New User", "Created user")
end
function deleteuser(self)
- return self.handle_form(self, function()
- return self.model.get_delete_user(self, self.clientdata.userid)
- end, function(value)
- return self.model.delete_user(self, value)
- end, self.clientdata, "Delete", "Delete User", "Deleted user")
+ return self.handle_form(self, self.model.get_delete_user, self.model.delete_user, self.clientdata, "Delete", "Delete User", "Deleted user")
end
diff --git a/app/acf-util/password-model.lua b/app/acf-util/password-model.lua
index 2a76c99..b9cafb9 100644
--- a/app/acf-util/password-model.lua
+++ b/app/acf-util/password-model.lua
@@ -164,8 +164,8 @@ function get_users(self)
return cfe({ type="group", value=users, label="User Configs" })
end
-function get_delete_user(self, user)
- local userid = cfe({ label="User id", value=user or "" })
+function get_delete_user(self, clientdata)
+ local userid = cfe({ label="User id", value=clientdata.userid or "" })
return cfe({ type="group", value={userid=userid}, label="Delete User" })
end
diff --git a/app/acf-util/skins-controller.lua b/app/acf-util/skins-controller.lua
index 5d4d0d7..c3d08a0 100644
--- a/app/acf-util/skins-controller.lua
+++ b/app/acf-util/skins-controller.lua
@@ -9,6 +9,6 @@ read = function (self )
end
update = function (self )
- return self:redirect_to_referrer(self.model.update(self, self.clientdata.skin or ""))
+ return self.handle_form(self, self.model.get_update, self.model.update, self.clientdata, "Update", "Update Skin", "Skin updated")
end
diff --git a/app/acf-util/skins-model.lua b/app/acf-util/skins-model.lua
index eda6870..b717de6 100644
--- a/app/acf-util/skins-model.lua
+++ b/app/acf-util/skins-model.lua
@@ -1,5 +1,6 @@
module (..., package.seeall)
+require("modelfunctions")
fs = require("acf.fs")
format = require("acf.format")
@@ -11,8 +12,6 @@ local function set_skins(self, skin)
content = "\nskin="..skin..content
end
fs.write_file(self.conf.conffile, string.sub(content,2))
- local cmdoutput = "New skin selected"
- return cmdoutput, errtxt
end
local function list_skins(self)
@@ -21,30 +20,36 @@ local function list_skins(self)
for i,file in ipairs(posix.dir(self.conf.wwwdir ..skin) or {}) do
-- Ignore files that begins with a '.' and 'cgi-bin' and only list folders
if not ((string.match(file, "^%.")) or (string.match(file, "^cgi[-]bin")) or (string.match(file, "^static")) or (posix.stat(self.conf.wwwdir .. skin .. file).type ~= "directory")) then
- local entry = cfe({ value=skin..file, label="Skin name" })
- local current = conf.skin
+ local entry = cfe({ value=skin..file, label=file })
+ local current = self.conf.skin
entry.inuse = (skin..file == current)
table.insert(skinarray, entry)
end
end
end
- return cfe({ type="list", value=skinarray, label="Skins" })
+ return skinarray
end
get = function (self)
- return list_skins(self)
+ return cfe({ type="list", value=list_skins(self), label="Skins" })
+end
+
+get_update = function (self)
+ local skin = cfe({ type="select", value="", label="Skin", option=list_skins(self) })
+ if self and self.conf and self.conf.skin then
+ skin.value = self.conf.skin
+ end
+ return cfe({ type="group", value={skin=skin}, label="Update Skin" })
end
update = function (self, newskin)
- -- Make sure no one can inject code into the model.
- local availableskins = list_skins(self)
- local cmdoutput = "Failed to set skin"
- local errtxt = "Invalid selection"
- for i,skin in ipairs(availableskins.value) do
- if ( skin.value == newskin) then
- cmdoutput, errtxt = set_skins(self, newskin)
- end
+ local success = modelfunctions.validateselect(newskin.value.skin)
+ if success then
+ set_skins(self, newskin.value.skin.value)
+ self.conf.skin = newskin.value.skin.value
+ else
+ newskin.errtxt = "Failed to set skin"
end
- return cfe({ value=cmdoutput, errtxt=errtxt, label="Set skin result" })
+ return newskin
end
diff --git a/app/acf-util/skins-read-html.lsp b/app/acf-util/skins-read-html.lsp
index 2d43b49..3dc53f8 100644
--- a/app/acf-util/skins-read-html.lsp
+++ b/app/acf-util/skins-read-html.lsp
@@ -11,7 +11,7 @@
<% if (skin.inuse) then %>
<dd>in use</dd>
<% else %>
- <dd>[<a href="update?skin=<%= html.html_escape(skin.value) %>">use this skin</a>]</dd>
+ <dd>[<a href="update?skin=<%= html.html_escape(skin.value) %>&submit=true">use this skin</a>]</dd>
<% end %>
<% end %>
</DL>