Increase domain component length limit
[hcoop/zz_old/portal.git] / groups.mlt
CommitLineData
8d347a33 1<% Group.requireGroupNum 0;
2
3@header [("title", ["Group management"])];
4
5ref showNormal = true;
6
7if $"cmd" = "Create" then
8 if not (Group.validGroupName ($"name")) then %>
1fe415e0 9 <h3>Invalid group name</h3>
8d347a33 10 <% else switch Group.groupNameToId ($"name") of
11 SOME _ => %>
1fe415e0 12 <h3>Group name already in use</h3>
8d347a33 13<% | NONE =>
14 val id = Group.addGroup ($"name") %>
1fe415e0 15 <h3>Group added</h3>
8d347a33 16<% end
17 end
18elseif $"mod" <> "" then
19 showNormal := false;
20 val group = Group.lookupGroup (Web.stoi ($"mod")) %>
1fe415e0 21<h3>Modify group record</h3>
8d347a33 22
add44c00 23<form action="groups" method="post">
8d347a33 24<input type="hidden" name="id" value="<% $"mod" %>">
1fe415e0 25<table class="blanks">
26<tr> <td>Name:</td> <td><input name="name" value="<% #name group %>"></td> </tr>
8d347a33 27<tr> <td><input type="submit" name="cmd" value="Save"></td> </tr>
28</table>
29</form>
30
31<% elseif $"cmd" = "Save" then
32 val group = Group.lookupGroup (Web.stoi ($"id"));
33 Group.modGroup {group with name = $"name"} %>
1fe415e0 34 <h3>Group record saved.</h3>
8d347a33 35
36<% elseif $"del" <> "" then
37 showNormal := false;
38 val group = Group.lookupGroup (Web.stoi ($"del")) %>
1fe415e0 39 <h3>Are you sure you want to delete group <% #name group %>?</h3>
8d347a33 40 <a href="groups?del2=<% $"del" %>">Yes, delete <% #name group %>!</a>
41
42<% elseif $"del2" <> "" then
43 val group = Group.lookupGroup (Web.stoi ($"del2"));
44 Group.deleteGroup (Web.stoi ($"del2")) %>
1fe415e0 45 <h3><% #name group %> deleted!</h3>
8d347a33 46
47<% elseif $"cmd" = "Grant" then
48 Group.addToGroup {usr = Web.stoi ($"usr"), grp = Web.stoi ($"grp")} %>
1fe415e0 49 <h3>Membership granted.</h3>
8d347a33 50
51<% elseif $"revoke" <> "" then
52 Group.removeFromGroup {usr = Web.stoi ($"revoke"), grp = Web.stoi ($"grp")} %>
1fe415e0 53 <h3>Membership revoked.</h3>
8d347a33 54
55<% end %>
56
57<% if showNormal then %>
58
1fe415e0 59<h3>Create group</h3>
8d347a33 60
add44c00 61<form action="groups" method="post">
1fe415e0 62<table class="blanks">
63<tr> <td>Name:</td> <td><input name="name"></td> </tr>
8d347a33 64<tr> <td><input type="submit" name="cmd" value="Create"></td> </tr>
65</table>
66</form>
67
1fe415e0 68<h3>Grant membership</h3>
8d347a33 69
add44c00 70<form action="groups" method="post">
1fe415e0 71<table class="blanks">
72<tr> <td>Group:</td> <td><select name="grp">
8d347a33 73<% foreach group in Group.listGroups () do %>
74 <option value="<% #id group %>"><% Web.html (#name group) %></option>
75<% end %>
76</select></td> </tr>
1fe415e0 77<tr> <td>Member:</td> <td><select name="usr">
8d347a33 78<% foreach user in Init.listUsers () do %>
79 <option value="<% #id user %>"><% Web.html (#name user) %></option>
80<% end %>
81</select></td> </tr>
82<tr> <td><input type="submit" name="cmd" value="Grant"></td> </tr>
83</table>
84</form>
85
1fe415e0 86<h3>Manage current groups</h3>
8d347a33 87
88<table>
89<% foreach group in Group.listGroups () do %>
51520441 90 <tr> <td><% Web.html (#name group) %></td> <td></td> <td><a href="groups?mod=<% #id group %>">[Modify]</a> <a href="groups?del=<% #id group %>">[Delete]</a></td> </tr>
8d347a33 91<% foreach user in Group.groupMembers (#id group) do %>
92 <tr> <td></td> <td><a href="user?id=<% #id user %>"><% Web.html (#name user) %></a></td> <td><a href="groups?revoke=<% #id user %>&grp=<% #id group %>">[Revoke]</a></td> </tr>
93<% end
94end %>
95</table>
96
97<% end %>
98
99<% @footer [] %>