<% 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

Title:
Only make this issue accessible to the admins for this support category.
Description:
<% 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); val _ = Support.addPost (you, id, $"body"); if not (Support.notifyCreation id) then %>

Error sending e-mail notification

<% end; viewingIssue := SOME id end elseif $"cmd" = "list" then showNormal := false %>

All issues

<% foreach (name, issue) in Support.listCategoryIssues catId do if (iff admin then true else (iff #priv issue then (#usr issue = you) else true)) then %> <% end end %>
<% Web.html (#title issue) %> <% if #priv issue then %>(private)<% end %> <% name %> <% #stamp issue %> <% switch #status issue of Support.NEW => %>New<% | Support.PENDING => %>Pending<% | Support.CLOSED => %>Closed<% 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

Category:
Title:
checked<% end %>> Only make this issue accessible to the admins for this support category.
Status:
<% end elseif $"save" <> "" then val id = Web.stoi ($"save"); val issue = Support.lookupIssue id; val title = $"title"; val oldStatus = #status issue; 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 val status = (case status of 0 => Support.NEW | 1 => Support.PENDING | _ => Support.CLOSED); Support.modIssue {issue with cat = #id newCat, title = title, priv = ($"priv" = "on"), status = status}; if status <> oldStatus then if not (Support.notifyStatus (you, oldStatus, status, id)) then %>

Error sending e-mail notification

<% end end; 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 $"cmd" = "post" then val id = Web.stoi ($"iss"); viewingIssue := SOME id; val issue = Support.lookupIssue id; if catId <> #cat issue then %>

Inconsistent cat field

<% elseif not (Support.allowedToSee id) then %>

Authorization failure

<% else val id = Support.addPost (you, id, $"body"); if not (Support.notifyPost id) then %>

Error sending e-mail notification

<% end %>

Posted

<% end elseif $"modPost" <> "" then showNormal := false; val id = Web.stoi ($"modPost"); val post = Support.lookupPost id; val issue = Support.lookupIssue (#iss post); if catId <> #cat issue then %>

Inconsistent cat field

<% elseif not admin then %>

You aren't authorized to modify that.

<% else %>

Modify post

<% end elseif $"savePost" <> "" then val id = Web.stoi ($"savePost"); val post = Support.lookupPost id; val issue = Support.lookupIssue (#iss post); if catId <> #cat issue then %>

Inconsistent cat field

<% elseif not admin then %>

Authorization failure

<% else Support.modPost {post with body = $"body"}; viewingIssue := SOME (#iss post) %>

Post saved "" then showNormal := false; val id = Web.stoi ($"delPost"); val post = Support.lookupPost id; val issue = Support.lookupIssue (#iss post); if catId <> #cat issue then %>

Inconsistent cat field

<% elseif not admin then %>

Authorization failure

<% else %>

Are you sure you want to delete this post?

<% Web.htmlNl (#body post) %>
Yes, delete it!<% end elseif $"delPost2" <> "" then val id = Web.stoi ($"delPost2"); val post = Support.lookupPost id; val issue = Support.lookupIssue (#iss post); if catId <> #cat issue then %>

Inconsistent cat field

<% elseif not admin then %>

Authorization failure

<% else Support.deletePost id; viewingIssue := SOME (#iss post) %>

Post deleted

<% end elseif $"id" <> "" then viewingIssue := SOME (Web.stoi ($"id")) end; switch viewingIssue of SOME id => val issue = Support.lookupIssue id; val canEdit = Support.allowedToEdit id; val canView = Support.allowedToSee id; 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) %> <% switch #pstamp issue of SOME stamp => %><% end; switch #cstamp issue of SOME stamp => %><% end %>
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 %>
Changed to pending: <% stamp %>
Closed: <% stamp %>
<% if admin then %> Modify this issue
Delete this issue
<% end; foreach (name, post) in Support.listPosts id do %>


<% name %> at <% #stamp post %>: <% if admin then %> [Modify] [Delete] <% end %>

<% Web.htmlNl (#body post) %>

<% end %>


Post to this thread


<% end | NONE => if showNormal then %> New issue
List all issues (including closed issues)

Open issues

<% val issues = iff admin then Support.listOpenCategoryIssuesAdmin catId else Support.listOpenCategoryIssues (catId, you); foreach (name, issue) in issues do %> <% end %> <% end end %> <% @footer[] %>
<% Web.html (#title issue) %> <% if #priv issue then %>(private)<% end %> <% name %> <% #stamp issue %> <% switch #status issue of Support.NEW => %>New<% | Support.PENDING => %>Pending<% | Support.CLOSED => %>Closed<% end %>