diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-07-25 19:00:03 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-07-25 19:00:03 +0000 |
commit | 4bf00bc98b36c0233e1ea833571acffefe2ec73b (patch) | |
tree | 13379b4d21cedc5a3137a508db94e3e243d3d6de | |
parent | 0b933c7c8b5daf0fd62d9f9dfef973b8383250f1 (diff) | |
download | acf-core-4bf00bc98b36c0233e1ea833571acffefe2ec73b.tar.bz2 acf-core-4bf00bc98b36c0233e1ea833571acffefe2ec73b.tar.xz |
Modified authenticator to allow reading/writing role-based options. Modified viewfunctions to display multi values that are not in options.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1320 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | lib/authenticator-plaintext.lua | 10 | ||||
-rw-r--r-- | lib/authenticator.lua | 41 | ||||
-rw-r--r-- | lib/viewfunctions.lua | 18 |
3 files changed, 64 insertions, 5 deletions
diff --git a/lib/authenticator-plaintext.lua b/lib/authenticator-plaintext.lua index c72b7c5..aa3e2e3 100644 --- a/lib/authenticator-plaintext.lua +++ b/lib/authenticator-plaintext.lua @@ -16,7 +16,7 @@ read_field = function(self, tabl, field) local row = {} -- open our password file - local passwd_path = self.conf.confdir .. tabl .. field + local passwd_path = self.conf.confdir .. field .. tabl local f = io.open(passwd_path) if f then local m = (f:read("*all") or "" ).. "\n" @@ -37,7 +37,7 @@ delete_field = function(self, tabl, field) if not tabl or tabl == "" or not field then return false end - local passwd_path = self.conf.confdir .. tabl .. field + local passwd_path = self.conf.confdir .. field .. tabl os.remove(passwd_path) return true end @@ -49,7 +49,7 @@ write_entry = function(self, tabl, field, id, entry) delete_entry(self, tabl, field, id) -- Set path to passwordfile - local passwd_path = self.conf.confdir .. tabl .. field + local passwd_path = self.conf.confdir .. field .. tabl -- Write the newline into the file if fs.is_file(passwd_path) == false then fs.create_file(passwd_path) end if fs.is_file(passwd_path) == false then return false end @@ -62,7 +62,7 @@ read_entry = function(self, tabl, field, id) return nil end -- Set path to passwordfile - local passwd_path = self.conf.confdir .. tabl .. field + local passwd_path = self.conf.confdir .. field .. tabl local passwdfilecontent = fs.read_file_as_array(passwd_path) or {} local entry for k,v in pairs(passwdfilecontent) do @@ -79,7 +79,7 @@ delete_entry = function (self, tabl, field, id) end local result = false - local passwd_path = self.conf.confdir .. tabl .. field + local passwd_path = self.conf.confdir .. field .. tabl local passwdfilecontent = fs.read_file_as_array(passwd_path) or {} local output = {} for k,v in pairs(passwdfilecontent) do diff --git a/lib/authenticator.lua b/lib/authenticator.lua index 3438c19..4af5e45 100644 --- a/lib/authenticator.lua +++ b/lib/authenticator.lua @@ -19,6 +19,7 @@ local availablefields = { ['roles']=true, } local passwdtable = "passwd" +local roletable = "roles" local load_auth = function(self) -- For now, just loads the plaintext version @@ -289,3 +290,43 @@ delete_userentry = function (self, name, userid) end return false end + +read_rolefield = function(self, name) + load_auth(self) + if auth then + return auth.read_field(self, roletable, name) + end + return nil +end + +delete_rolefield = function(self, name) + load_auth(self) + if auth then + return auth.delete_field(self, roletable, name) + end + return false +end + +write_roleentry = function(self, name, role, entry) + load_auth(self) + if auth then + return auth.write_entry(self, roletable, name, role, entry) + end + return false +end + +read_roleentry = function(self, name, role) + load_auth(self) + if auth then + return auth.read_entry(self, roletable, name, role) + end + return nil +end + +delete_roleentry = function (self, name, role) + load_auth(self) + if auth then + return auth.delete_entry(self, roletable, name, role) + end + return false +end diff --git a/lib/viewfunctions.lua b/lib/viewfunctions.lua index 62a87c6..19911a0 100644 --- a/lib/viewfunctions.lua +++ b/lib/viewfunctions.lua @@ -116,18 +116,36 @@ function displayformitem(myitem, name, viewtype) -- FIXME multiple select doesn't work in haserl, so use series of checkboxes --myitem.type = "select" --myitem.multiple = "true" + myitem.class = nil local tempname = myitem.name local tempval = myitem.value or {} local reverseval = {} for x,val in ipairs(tempval) do reverseval[val] = x end + local reverseopt = {} for x,val in ipairs(myitem.option) do + reverseopt[val] = x myitem.value = val myitem.checked = reverseval[val] myitem.name = tempname .. "." .. x io.write(html.form.checkbox(myitem) .. val .. "<br>\n") end + -- Check for values not in options + if myitem.errtxt then + myitem.class = "error" + io.write('<p class="error">\n') + end + for x,val in ipairs(tempval) do + if not reverseopt[val] then + myitem.value = val + myitem.checked = true + io.write(html.form.checkbox(myitem) .. val .. "<br>\n") + end + end + if myitem.errtxt then + io.write('</p>\n') + end myitem.name = tempname myitem.value = tempval elseif myitem.type == "boolean" then |