summaryrefslogtreecommitdiffstats
path: root/freeradius3-viewpasswdfile-html.lsp
blob: b4e8ce5ecf94f98d7c1d84bf79c8b0a25bc0810c (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
<% local view, viewlibrary, page_info, session = ... 
htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>

<script type="text/javascript">
	if (typeof jQuery == 'undefined') {
		document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
	}
</script>

<script type="text/javascript">
	if (typeof $.tablesorter == 'undefined') {
		document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery.tablesorter.js"><\/script>');
	}
</script>

<script type="text/javascript">
	$(document).ready(function() {
		$("#list").tablesorter({headers: {0:{sorter: false}}, widgets: ['zebra']});
	});
</script>

<% htmlviewfunctions.displaycommandresults({"editpasswdentry"}, session) %>

<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
<% htmlviewfunctions.displayitem(view.value.filename) %>
<% if view.value.data then %>
<table id="list" class="tablesorter"><thead>
	<tr>
		<th>Action</th>
<% for i,f in ipairs(view.value.fields.value) do %>
		<th><%= html.html_escape(f) %></th>
<% end %>
	</tr>
</thead><tbody>
<% local filename = cfe({ type="hidden", value=view.value.filename.value }) %>
<% local entry = cfe({ type="hidden", value="" }) %>
<% local redir = cfe({ type="hidden", value=page_info.orig_action }) %>
<% -- This is a hack to redirect back to viewing the same file
redir.value = redir.value.."?filename="..html.url_encode(view.value.filename.value)
%>
<% for i,r in ipairs( view.value.data.value ) do %>
	<tr>
		<td>
		<% entry.value = i %>
		<% if viewlibrary.check_permission("editpasswdentry") then %>
			<% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, entry=entry, redir=redir}, label="", option="Edit", action="editpasswdentry"}), page_info, -1) %>
		<% end %>
		</td>
<% for j,f in ipairs(r) do %>
		<td><%= html.html_escape(f) %></td>
<% end %>
	</tr>
<% end %>
</tbody></table>
<% end %>
<% htmlviewfunctions.displaysectionend(header_level) %>