% val catId = Web.stoi ($"cat");
val cat = Support.lookupCategory catId;
val admin = Group.inGroupNum (#grp cat);
val you = Init.getUserId()
ref viewingIssue = NONE;
@header[("title", ["Support: " ^ Web.html (#name cat)])];
ref showNormal = true;
if $"cmd" = "new" then
showNormal := false %>
New issue
<% elseif $"cmd" = "add" then
val title = $"title";
if not (Support.validTitle title) then
%>Invalid title
<%
else
val id = Support.addIssue (you, catId, title, $"priv" = "on", Support.NEW);
viewingIssue := SOME id
end
elseif $"mod" <> "" then
showNormal := false;
val id = Web.stoi ($"mod");
val issue = Support.lookupIssue id;
if catId <> #cat issue then
%>Inconsistent cat field
<%
elseif not admin then
%>You aren't authorized to modify that.
<%
else %>
Modify issue
<% end
elseif $"save" <> "" then
val id = Web.stoi ($"save");
val issue = Support.lookupIssue id;
val title = $"title";
val status = Web.stoi ($"status");
val newCat = Support.lookupCategory (Web.stoi ($"newCat"));
if catId <> #cat issue then
%>Inconsistent cat field
<%
elseif (iff admin then not (Group.inGroupNum (#grp newCat)) else false) then
%>Authorization failure
<%
elseif not (Support.validTitle title) then
%>Invalid title
<%
elseif (iff status < 0 then false else status > 2) then
%>Invalid status
<%
else
Support.modIssue {issue with cat = #id newCat, title = title,
priv = ($"priv" = "on"),
status = (case status of
0 => Support.NEW
| 1 => Support.PENDING
| _ => Support.CLOSED)};
viewingIssue := SOME id
%>Issue saved
"" then
showNormal := false;
val id = Web.stoi ($"del");
val issue = Support.lookupIssue id;
if catId <> #cat issue then
%>Inconsistent cat field
<%
elseif not admin then
%>Authorization failure
<%
else
%>Are you sure you want to delete "<% Web.html (#title issue) %>"?
Yes, delete "<% Web.html (#title issue) %>"!<%
end
elseif $"del2" <> "" then
val id = Web.stoi ($"del2");
val issue = Support.lookupIssue id;
if catId <> #cat issue then
%>Inconsistent cat field
<%
elseif not admin then
%>Authorization failure
<%
else
Support.deleteIssue id
%>Issue "<% Web.html (#title issue) %>" deleted
<%
end
elseif $"id" <> "" then
viewingIssue := SOME (Web.stoi ($"id"))
end;
switch viewingIssue of
SOME id =>
val issue = Support.lookupIssue id;
val canEdit = (iff #usr issue = you then true else admin);
val canView = (iff #priv issue then canEdit else true);
if catId <> #cat issue then
%>Inconsistent cat field
<%
elseif not canView then
%>You aren't authorized to view that.
<%
else
val user = Init.lookupUser (#usr issue) %>
Title: | <% Web.html (#title issue) %> |
Created by: | <% #name user %> |
At: | <% #stamp issue %> |
Private: | <% if #priv issue then %>yes<% else %>no<% end %> |
Status: | <% switch #status issue of
Support.NEW => %>New<%
| Support.PENDING => %>Pending<%
| Support.CLOSED => %>Closed<%
end %> |
<% if admin then %>
Modify this issue
Delete this issue
<% end %>
<% end
| NONE =>
if showNormal then %>
New issue
Open issues
<% val issues = iff admin then Support.listOpenCategoryIssuesAdmin catId
else Support.listOpenCategoryIssues (catId, you);
foreach issue in issues do
val user = Init.lookupUser (#usr issue) %>
<% Web.html (#title issue) %>
<% if #priv issue then %>(private)<% end %>
|
<% #name user %> |
<% #stamp issue %> |
<% switch #status issue of
Support.NEW => %>New<%
| Support.PENDING => %>Pending<%
| Support.CLOSED => %>Closed<%
end %> |
<% end %>
<% end
end %>
<% @footer[] %>