summaryrefslogtreecommitdiffstats
path: root/app/acf-util/roles-read-html.lsp
blob: 32000af8b2fe21b8ca5d07f0bf1142d6ba93b598 (plain)
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
<% local view= ... %> 

<% if view.value.userid then %>
	<H1>Roles/Permission list for <%= html.html_escape(view.value.userid.value) %>:</H1>
<% elseif view.value.role then %>
	<H1>Permission list for <%= html.html_escape(view.value.role.value) %>:</H1>
<% else %>
	<H1>Complete permission list:</H1>
<% end %>

<% if view.value.roles then %>
	<H2><%= html.html_escape(view.value.userid.value) %> is valid in these roles</H2>
	<DL>
	<% for a,b in pairs(view.value.roles.value) do
		print("<dt>",html.html_escape(b),"</dt><dd>&nbsp;</dd>")
	end %>
	</DL>
<% end %>

<% if view.value.permissions then %>
	<% if view.value.userid then %>
		<H2><%= html.html_escape(view.value.userid.value) %>'s full permissions are</H2>
	<% elseif view.value.role then %>
		<H2><%= html.html_escape(view.value.role.value) %>'s full permissions are</H2>
	<% end %>
	<DL>
	<TABLE>
		<TR><TD CLASS='header'>Controller</TD><TD CLASS='header'>Action(s)</TD></TR>
		<% local prefixes = {}
		-- It's nice to have it in alphabetical order
		for pref in pairs(view.value.permissions.value) do
			prefixes[#prefixes + 1] = pref
		end
		table.sort(prefixes)
		for w,pref in ipairs(prefixes) do
			local controllers = {}
			-- Again, alphabetical order
			for cont in pairs(view.value.permissions.value[pref]) do
				controllers[#controllers + 1] = cont
			end
			table.sort(controllers)
			for x,cont in ipairs(controllers) do
				print("<TR><TD STYLE='font-weight:bold;'>",html.html_escape(pref..cont),"</TD><TD>")
				-- Again, alphabetical order
				local actions = {}
				for act in pairs(view.value.permissions.value[pref][cont]) do
					actions[#actions + 1] = act
				end
				table.sort(actions)
				for y,act in pairs(actions) do
					print((html.html_escape(act)))
				end
				io.write("<TD></TR>")
			end
		end
		%>
	</TABLE>
	</DL>
<% end %>