% @header[("title", ["Support"])];
val you = Init.getUserId ();
val admin = Group.inGroupName "support";
ref showNormal = true;
if $"sub" <> "" then
Support.subscribe { cat = Web.stoi ($"sub"), usr = you }
%>
Subscribed
<% elseif $"unsub" <> "" then
Support.unsubscribe { cat = Web.stoi ($"unsub"), usr = you }
%>Unsubscribed
<% elseif $"cmd" = "add" then
Group.requireGroupName "support";
val id = Support.addCategory (Web.stoi ($"grp"), $"name", $"descr")
%>Category added
<% elseif $"mod" <> "" then
Group.requireGroupName "support";
showNormal := false;
val id = Web.stoi ($"mod");
val cat = Support.lookupCategory id %>
Modify category
<% elseif $"save" <> "" then
Group.requireGroupName "support";
val id = Web.stoi ($"save");
val cat = Support.lookupCategory id;
Support.modCategory {cat with name = $"name", descr = $"descr", grp = Web.stoi ($"grp")}
%>Category saved
<% elseif $"del" <> "" then
Group.requireGroupName "support";
showNormal := false;
val id = Web.stoi ($"del");
val cat = Support.lookupCategory id;
%>Are you sure you want to delete category "<% Web.html (#name cat) %>"?
Yes, delete "<% Web.html (#name cat) %>"!
<% elseif $"del2" <> "" then
Group.requireGroupName "support";
val id = Web.stoi ($"del2");
val cat = Support.lookupCategory id;
Support.deleteCategory id;
%>"<% Web.html (#name cat) %>" deleted
<% end;
if showNormal then %>
Choose a category:
<% foreach (sub, cat) in Support.listCategoriesWithSubscriptions you do %>
<% Web.html (#name cat) %>: <% Web.html (#descr cat) %>
<% if sub then %>
[Unsubscribe]
<% else %>
[Subscribe]
<% end %>
<% if admin then %>
[Modify]
[Delete]
<% end %>
<% end %>
<% if admin then %>
Add new category
<% end %>
<% end %>
<% @footer[] %>