% Group.requireGroupNum 0;
@header [("title", ["Member management"])];
ref showNormal = true;
if $"cmd" = "Create" then
if not (Init.validUsername ($"name")) then %>
Invalid username
<% else switch Init.userNameToId ($"name") of
SOME _ => %>
Username already in use
<% | NONE =>
val ap = Web.stoi ($"app");
val bal =
(case $"bal" of
"" => Balance.addBalance ($"name")
| s => Web.stoi s);
val id = Init.addUser ($"name", $"rname", bal, ap, 1);
Group.addToGroups (id, map Web.stoi (Web.getMultiParam "grp"));
if $"amount" <> "" then
val amount = Web.stor ($"amount");
val trn = Money.addTransaction ($"descr", amount, Init.dateString ());
Money.addCharge {trn = trn, usr = id, amount = amount};
Money.applyCharges trn
end;
if $"subscribe" = "on" then
if not (Pref.subscribe ("hcoop-announce", $"name" ^ Init.emailSuffix)) then
%>Error subscribing to hcoop-announce
<%
end
end;
if $"nomail" = "" then
App.welcome ap
end
%>Member added
<% end
end
elseif $"mod" <> "" then
showNormal := false;
val user = Init.lookupUser (Web.stoi ($"mod")) %>
Modify member record
<% elseif $"cmd" = "Save" then
val user = Init.lookupUser (Web.stoi ($"id"));
Init.modUser {user with name = $"name", bal = Web.stoi ($"bal")} %>
Member record saved.
<% elseif $"del" <> "" then
showNormal := false;
val user = Init.lookupUser (Web.stoi ($"del")) %>
Are you sure you want to delete member <% #name user %>?
">Yes, delete <% #name user %>!
<% elseif $"del2" <> "" then
val user = Init.lookupUser (Web.stoi ($"del2"));
Init.deleteUser (Web.stoi ($"del2")) %>
<% #name user %> deleted!
<% elseif $"cmd" = "grandfather" then
Init.grandfatherUsers()
%>Grandfathered
<% elseif $"cmd" = "addform" then
showNormal := false %>
New member
<% elseif $"cmd" = "unmigrated" then
showNormal := false;
ref negative = 0;
val users = Init.unmigratedUsers () %>
Unmigrated members (<% length users %>)
<% foreach user in users do %>
<% Web.html (#name user) %> |
<% val bal = Balance.lookupBalance (#bal user);
if Balance.isNegative bal then
negative := negative + 1
end %>
<% #amount bal %> |
<%if #name bal <> #name user then %>
<% Web.html (#name bal) %>
<% end %>
|
<% end %>
<% negative %> have negative balances.
<% elseif $"cmd" = "diff" then
showNormal := false;
val against = (case $"against" of
"" => Init.usersInAfs ()
| x => String.tokens Char.isSpace x);
val diff = Init.usersDiff (Init.listUsernames (), against) %>
User diff
Only on the portal:
Only in AFS:
<% foreach user in #onlyInSecond diff do %>
- <% Web.html user %>
<% end %>
<% end %>
<% if showNormal then %>
Add a user manually
Manage current members
<% foreach user in Init.listUsers () do %>
<% Web.html (#name user) %> |
<% val bal = Balance.lookupBalance (#bal user);
if #name bal <> #name user then %>
<% Web.html (#name bal) %>
<% end %>
| [Modify] [Delete] |
<% end %>
Grandfather old users to have applications
Who hasn't migrated yet?
How does the set of users in AFS compare with the set of active portal users?
<% end %>
<% @footer [] %>