summaryrefslogtreecommitdiffstats
path: root/app/acf-util
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-02-18 19:52:34 +0000
committerMika Havela <mika.havela@gmail.com>2008-02-18 19:52:34 +0000
commit3d45676a1116e285018c0072ebd23f2095523bff (patch)
treee3d69cf464855f83afe3458893a78a6751deac6c /app/acf-util
parent39e870458e8aaf810cab762e4d0d5882ac1505d2 (diff)
downloadacf-core-3d45676a1116e285018c0072ebd23f2095523bff.tar.bz2
acf-core-3d45676a1116e285018c0072ebd23f2095523bff.tar.xz
Moved password-manager to core
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@750 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'app/acf-util')
-rwxr-xr-xapp/acf-util/password-controller.lua47
-rwxr-xr-xapp/acf-util/password-edit-html.lsp72
-rwxr-xr-xapp/acf-util/password-read-html.lsp2
-rwxr-xr-xapp/acf-util/password-status-html.lsp82
-rwxr-xr-xapp/acf-util/password.menu3
5 files changed, 206 insertions, 0 deletions
diff --git a/app/acf-util/password-controller.lua b/app/acf-util/password-controller.lua
new file mode 100755
index 0000000..c19d6b4
--- /dev/null
+++ b/app/acf-util/password-controller.lua
@@ -0,0 +1,47 @@
+module(..., package.seeall)
+
+local list_redir = function (self)
+ self.conf.action = "status"
+ self.conf.type = "redir"
+ error (self.conf)
+end
+
+mvc = {}
+mvc.on_load = function(self, parent)
+ if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then
+ self.worker[self.conf.action] = list_redir(self)
+ end
+end
+
+function status(self)
+ local status=self.model.getstatus(self)
+ status.cmdnew = cfe ({
+ name="cmdnew",
+ type="submit",
+ label="Create new account",
+ value="Create",
+ disabled="yes",
+ })
+ return { status=status }
+end
+
+function edit(self)
+ local config=self.model.getsettings(self.clientdata.userid)
+ config.cmdsave = cfe ({
+ name="cmdsave",
+ type="submit",
+ label="Save changes",
+ value="Save",
+ disabled="yes",
+ })
+ config.cmddelete = cfe ({
+ name="cmddelete",
+ type="submit",
+ label="Delete this account",
+ value="Delete",
+ disabled="yes",
+ })
+
+ return { config=config, clientdata=self.clientdata }
+end
+
diff --git a/app/acf-util/password-edit-html.lsp b/app/acf-util/password-edit-html.lsp
new file mode 100755
index 0000000..8b295b5
--- /dev/null
+++ b/app/acf-util/password-edit-html.lsp
@@ -0,0 +1,72 @@
+<? local form = ... ?>
+<?
+--[[ DEBUG INFORMATION
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
+--]]
+?>
+<?
+function displayinfo(myform,tags,viewonly)
+ io.write("\n<DL>")
+ for k,v in pairs(tags) do
+ if (myform[v]) and (myform[v]["value"]) then
+ local val = myform[v]
+ io.write("\n\t<DT")
+ if (#val.errtxt > 0) then
+ val.class = "error"
+ io.write(" class='error'")
+ end
+ io.write(">" .. val.label .. "</DT>\n")
+ if (viewonly) then
+ io.write("\t\t<DD>" .. val.value .. "\n")
+ else
+ io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
+ end
+ if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+ end
+ end
+ io.write("</DL>")
+end
+?>
+
+<H1>CONFIG</H1>
+<H2>Settings</H2>
+<?
+local myform = form.config
+local tags = { "userid", }
+displayinfo(myform,tags,"viewonly")
+local tags = { "descr", }
+displayinfo(myform,tags)
+?>
+
+<?
+-- The following code is a bit special because I want to display checkboxes for available roles.
+local myform = form.config.roles
+io.write("\n<DL>")
+io.write("\n\t<DT")
+if (#myform.errtxt > 0) then
+ myform.class = "error"
+ io.write(" class='error'")
+end
+io.write(">" .. myform.label .. "</DT>")
+io.write("\n\t\t<DD>")
+for k,v in pairs(myform.option) do
+ local checked = ""
+ if (form.config.userid.roles[v]) then checked = "checked='yes'" end
+ io.write("\n\t\t\t" ..v .. ":<input class='checkbox' type='checkbox' name='roles' value='' " .. checked .. "> ")
+end
+if (#myform.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(myform.errtxt, "\n", "<BR>") .. "</P>\n") end
+io.write("\n\t\t</DD>\n")
+io.write("</DL>")
+?>
+
+<H2>Actions</H2>
+<?
+local myform = form.config
+local tags = { "cmdsave", "cmddelete", }
+displayinfo(myform,tags)
+
+?>
+
diff --git a/app/acf-util/password-read-html.lsp b/app/acf-util/password-read-html.lsp
new file mode 100755
index 0000000..9ab91bf
--- /dev/null
+++ b/app/acf-util/password-read-html.lsp
@@ -0,0 +1,2 @@
+<? local view = ... ?>
+<p>The local root password is <?= view.password.value ?></p>
diff --git a/app/acf-util/password-status-html.lsp b/app/acf-util/password-status-html.lsp
new file mode 100755
index 0000000..45bed4f
--- /dev/null
+++ b/app/acf-util/password-status-html.lsp
@@ -0,0 +1,82 @@
+<? local form = ... ?>
+<?
+--[[ DEBUG INFORMATION
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
+--]]
+?>
+
+<?
+function displayinfo(myform,tags,viewonly)
+ io.write("<DL>")
+ for k,v in pairs(tags) do
+ if (myform[v]) and (myform[v]["value"]) then
+ local val = myform[v]
+ io.write("\t<DT")
+ if (#val.errtxt > 0) then
+ val.class = "error"
+ io.write(" class='error'")
+ end
+ io.write(">" .. val.label .. "</DT>\n")
+ if (viewonly) then
+ io.write("\t\t<DD>" .. val.value .. "\n")
+ else
+ io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
+ end
+ if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end
+ if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+ end
+ end
+ io.write("</DL>")
+end
+?>
+
+<H1>USER ACCOUNTS</H1>
+<H2>Create new account</H2>
+<?
+local myform = form.status
+local tags = { "cmdnew", }
+displayinfo(myform,tags)
+?>
+
+<H2>Existing account</H2>
+<?
+--function displayinfo(myform,tags,viewonly)
+local myform = form.status.users
+
+io.write("<DL>")
+if (type(myform) == "table") then
+ for k,v in pairs(myform) do
+ local myform = myform[k]
+ io.write("\t<DT")
+ if (#myform.errtxt > 0) then
+ myform.class = "error"
+ io.write(" class='error'")
+ end
+ io.write("><IMG SRC='/static/tango/16x16/apps/system-users.png' HEIGHT='16' WIDTH='16'> " .. myform.label .. "</DT>\n")
+ io.write("\t\t<DD>\n\t\t<TABLE>")
+ io.write("\n\t\t\t<TR>\n\t\t\t\t<TD><B>Account name:</B></TD>\n\t\t\t\t<TD WIDTH='90%'>" .. myform.value .. "</TD>\n\t\t\t</TR>")
+ io.write("\n\t\t\t<TR>\n\t\t\t\t<TD><B>Description:</B></TD>\n\t\t\t\t<TD>" .. (myform.descr or "") .. "</TD>\n\t\t\t</TR>")
+ io.write("\n\t\t\t<TR>\n\t\t\t\t<TD><B>Roles:</B></TD>\n\t\t\t\t<TD>")
+ io.write(tostring(myform.roles))
+ io.write("</TD>\n\t\t\t</TR>")
+ io.write("\n\t\t\t<TR>\n\t\t\t\t<TD><B>Options:</B></TD>\n\t\t\t\t<TD>[<A HREF='edit?userid=".. myform.value .. "'>Edit this account</A>]</TD>\n\t\t\t</TR>")
+ io.write("\n\t\t</TABLE>\n")
+ if (#myform.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(myform.errtxt, "\n", "<BR>") .. "</P>\n") end
+ io.write("\t\t</DD>\n")
+ end
+end
+io.write("</DL>")
+?>
+
+
+<?
+--[[ DEBUG INFORMATION
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(form))
+io.write("</span>")
+--]]
+?>
+
diff --git a/app/acf-util/password.menu b/app/acf-util/password.menu
new file mode 100755
index 0000000..3965745
--- /dev/null
+++ b/app/acf-util/password.menu
@@ -0,0 +1,3 @@
+#CAT GROUP/DESC TAB ACTION
+System 01Password Status status
+