diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-05-15 20:15:32 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-05-15 20:15:32 +0000 |
commit | 846a69204d0d2e54638f8e08a3052b2316827cab (patch) | |
tree | f1e567623b6be1e62f91ba1cfe9383308790bcc9 /app/acf-util/password-controller.lua | |
parent | c1c2252c53ffcb14b98443f8ee2c6da40551f160 (diff) | |
download | acf-core-846a69204d0d2e54638f8e08a3052b2316827cab.tar.bz2 acf-core-846a69204d0d2e54638f8e08a3052b2316827cab.tar.xz |
For cfe.type='form', use cfe.option as the command to save the form data i.e. can be used as button name. Modified pages that use 'form' to also use 'option'.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1122 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'app/acf-util/password-controller.lua')
-rwxr-xr-x | app/acf-util/password-controller.lua | 69 |
1 files changed, 47 insertions, 22 deletions
diff --git a/app/acf-util/password-controller.lua b/app/acf-util/password-controller.lua index 809e766..4493e4a 100755 --- a/app/acf-util/password-controller.lua +++ b/app/acf-util/password-controller.lua @@ -7,50 +7,75 @@ function status(self) end function editme(self) - -- just to make sure can't modify any other user from this action - self.clientdata.userid = sessiondata.userinfo.userid - self.clientdata.roles = nil - -- if password is blank, don't update it or require it - if self.clientdata.password == "" then self.clientdata.password = nil end - if self.clientdata.password_confirm == "" then self.clientdata.password_confirm = nil end + local output + if clientdata.Save then + -- just to make sure can't modify any other user from this action + self.clientdata.userid = self.sessiondata.userinfo.userid + self.clientdata.roles = nil + -- if password is blank, don't update it or require it + if self.clientdata.password == "" then self.clientdata.password = nil end + if self.clientdata.password_confirm == "" then self.clientdata.password_confirm = nil end - -- Update userinfo - local output = self.model.update_user(self, self.clientdata, false) + -- Update userinfo + output = self.model.update_user(self, self.clientdata) + + if not output.errtxt then + output.descr = "Saved user" + end + else + output = self.model.read_user(self, self.sessiondata.userinfo.userid) + end -- Don't allow changing of roles for yourself output.value.roles = nil + output.type = "form" output.label = "Edit My Settings" + output.option = "Save" return output end function edituser(self) - -- if password is blank, don't update it or require it - if self.clientdata.password == "" then self.clientdata.password = nil end - if self.clientdata.password_confirm == "" then self.clientdata.password_confirm = nil end + local output + if self.clientdata.Save then + -- if password is blank, don't update it or require it + if self.clientdata.password == "" then self.clientdata.password = nil end + if self.clientdata.password_confirm == "" then self.clientdata.password_confirm = nil end - -- Update userinfo - local output = self.model.update_user(self, self.clientdata, false) + -- Update userinfo + output = self.model.update_user(self, self.clientdata) - -- result - if output.descr and output.errtxt == nil then - redirect(self, "status") + -- result + if not output.errtxt then + redirect(self, "status") + end + else + output = self.model.read_user(self, self.clientdata.userid) end + output.type = "form" output.label = "Edit User Settings" + output.option = "Save" return output end function newuser(self) - -- Update userinfo - local output = self.model.update_user(self, self.clientdata, true) - - -- result - if output.descr and output.errtxt == nil then - redirect(self, "status") + local output + if self.clientdata.Save then + -- Update userinfo + output = self.model.create_user(self, self.clientdata) + + -- result + if not output.errtxt then + redirect(self, "status") + end + else + output = self.model.read_user(self) end + output.type = "form" output.label = "New User Settings" + output.option = "Save" return output end |