1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
module(..., package.seeall)
default_action = "editme"
function status(self)
return self.model.get_users(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
-- Update userinfo
local output = self.model.update_user(self, self.clientdata, false)
-- Don't allow changing of roles for yourself
output.value.roles = nil
output.label = "Edit My Settings"
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
-- FIXME this is because multi selects don't work in haserl
if self.clientdata.roles then
local newroles = {}
for x,role in pairs(self.clientdata.roles) do
newroles[#newroles + 1] = role
end
self.clientdata.roles = newroles
end
-- Update userinfo
local output = self.model.update_user(self, self.clientdata, false)
-- result
if output.descr and output.errtxt == nil then
redirect(self, "status")
end
output.label = "Edit User Settings"
return output
end
function newuser(self)
-- FIXME this is because multi selects don't work in haserl
if self.clientdata.roles then
local newroles = {}
for x,role in pairs(self.clientdata.roles) do
newroles[#newroles + 1] = role
end
self.clientdata.roles = newroles
end
-- Update userinfo
local output = self.model.update_user(self, self.clientdata, true)
-- result
if output.descr and output.errtxt == nil then
redirect(self, "status")
end
output.label = "New User Settings"
return output
end
function deleteuser(self)
self.model.delete_user(self, self.clientdata.userid)
redirect(self, "status")
end
|