payment: note that Stripe has instituted an additional 1% fee for non-US cards
[hcoop/portal.git] / groups.mlt
CommitLineData
208e2cbc
AC
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 %>
b6dd1aaf 9 <h3>Invalid group name</h3>
208e2cbc
AC
10 <% else switch Group.groupNameToId ($"name") of
11 SOME _ => %>
b6dd1aaf 12 <h3>Group name already in use</h3>
208e2cbc
AC
13<% | NONE =>
14 val id = Group.addGroup ($"name") %>
b6dd1aaf 15 <h3>Group added</h3>
208e2cbc
AC
16<% end
17 end
18elseif $"mod" <> "" then
19 showNormal := false;
20 val group = Group.lookupGroup (Web.stoi ($"mod")) %>
b6dd1aaf 21<h3>Modify group record</h3>
208e2cbc 22
a4ccdb5e 23<form action="groups" method="post">
208e2cbc 24<input type="hidden" name="id" value="<% $"mod" %>">
b6dd1aaf
AC
25<table class="blanks">
26<tr> <td>Name:</td> <td><input name="name" value="<% #name group %>"></td> </tr>
208e2cbc
AC
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"} %>
b6dd1aaf 34 <h3>Group record saved.</h3>
208e2cbc
AC
35
36<% elseif $"del" <> "" then
37 showNormal := false;
38 val group = Group.lookupGroup (Web.stoi ($"del")) %>
b6dd1aaf 39 <h3>Are you sure you want to delete group <% #name group %>?</h3>
208e2cbc
AC
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")) %>
b6dd1aaf 45 <h3><% #name group %> deleted!</h3>
208e2cbc
AC
46
47<% elseif $"cmd" = "Grant" then
48 Group.addToGroup {usr = Web.stoi ($"usr"), grp = Web.stoi ($"grp")} %>
b6dd1aaf 49 <h3>Membership granted.</h3>
208e2cbc
AC
50
51<% elseif $"revoke" <> "" then
52 Group.removeFromGroup {usr = Web.stoi ($"revoke"), grp = Web.stoi ($"grp")} %>
b6dd1aaf 53 <h3>Membership revoked.</h3>
208e2cbc
AC
54
55<% end %>
56
57<% if showNormal then %>
58
b6dd1aaf 59<h3>Create group</h3>
208e2cbc 60
a4ccdb5e 61<form action="groups" method="post">
b6dd1aaf
AC
62<table class="blanks">
63<tr> <td>Name:</td> <td><input name="name"></td> </tr>
208e2cbc
AC
64<tr> <td><input type="submit" name="cmd" value="Create"></td> </tr>
65</table>
66</form>
67
b6dd1aaf 68<h3>Grant membership</h3>
208e2cbc 69
a4ccdb5e 70<form action="groups" method="post">
b6dd1aaf
AC
71<table class="blanks">
72<tr> <td>Group:</td> <td><select name="grp">
208e2cbc
AC
73<% foreach group in Group.listGroups () do %>
74 <option value="<% #id group %>"><% Web.html (#name group) %></option>
75<% end %>
76</select></td> </tr>
b6dd1aaf 77<tr> <td>Member:</td> <td><select name="usr">
208e2cbc
AC
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
b6dd1aaf 86<h3>Manage current groups</h3>
208e2cbc
AC
87
88<table>
89<% foreach group in Group.listGroups () do %>
b340786b 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>
208e2cbc
AC
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 [] %>