summaryrefslogtreecommitdiffstats
path: root/app/acf-util/roles-html.lsp
blob: a5c89dc200b596435776b67bd469b91236a82c9d (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
<? local view= ... ?> 
<? --[[
	io.write(html.cfe_unpack(view))
--]] ?>

<? ---[[ ?>
<? if view.value.userid then ?>
	<H1>Roles/Permission list for <?= view.value.userid.value ?>:</H1>
<? elseif view.value.role then ?>
	<H1>Permission list for <?= view.value.role.value ?>:</H1>
<? else ?>
	<H1>Complete permission list:</H1>
<? end ?>

<? if view.value.roles then ?>
	<H2><?= view.value.userid.value ?> is valid in these roles</H2>
	<? for a,b in pairs(view.value.roles.value) do
		print("<li>",b,"</li>")
	end ?>
<? end ?>
<? --]] ?>

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