1 <% val catId = Web.stoi ($"cat");
2 val cat = Support.lookupCategory catId;
3 val admin = Group.inGroupNum (#grp cat);
4 val you = Init.getUserId()
6 ref viewingIssue = NONE;
8 @header[("title", ["Support: " ^ Web.html (#name cat)])];
10 ref showNormal = true;
12 if $"cmd" = "new" then
13 showNormal := false %>
15 <h3><b>New issue</b></h3>
18 <input type="hidden" name="cat" value="<% catId %>">
19 <input type="hidden" name="cmd" value="add">
21 <tr> <td align="right"><b>Title</b>:</td> <td><input name="title"></td> </tr>
22 <tr> <td align="right"><input type="checkbox" name="priv"></td> <td>Only make this issue accessible to the admins for this support category.</td> </tr>
23 <tr> <td align="right"><b>Description</b>:</td> <td><textarea name="body" rows="10" cols="80" wrap="soft"></textarea></td> </tr>
24 <tr> <td><input type="submit" value="Add"></td> </tr>
28 <% elseif $"cmd" = "add" then
30 if not (Support.validTitle title) then
31 %><h3><b>Invalid title</b></h3><%
33 val id = Support.addIssue (you, catId, title, $"priv" = "on", Support.NEW);
34 val _ = Support.addPost (you, id, $"body");
35 if not (Support.notifyCreation id) then
36 %><h3><b>Error sending e-mail notification</b></h3><%
38 viewingIssue := SOME id
41 elseif $"mod" <> "" then
43 val id = Web.stoi ($"mod");
44 val issue = Support.lookupIssue id;
45 if catId <> #cat issue then
46 %><h3><b>Inconsistent cat field</b></h3><%
48 %><h3><b>You aren't authorized to modify that.</b></h3><%
50 <h3><b>Modify issue</b></h3>
53 <input type="hidden" name="cat" value="<% catId %>">
54 <input type="hidden" name="save" value="<% id %>">
56 <tr> <td align="right"><b>Category</b>:</td> <td><select name="newCat">
57 <% foreach cat in Support.listCategories () do %>
58 <option value="<% #id cat %>"<% if #id cat = catId then %> selected<% end %>><% Web.html (#name cat) %></option>
59 <% end %></select></td> </tr>
60 <tr> <td align="right"><b>Title</b>:</td> <td><input name="title" value="<% Web.html (#title issue) %>"></td> </tr>
61 <tr> <td align="right"><input type="checkbox" name="priv"<% if #priv issue then %> checked<% end %>></td> <td>Only make this issue accessible to the admins for this support category.</td> </tr>
62 <tr> <td align="right"><b>Status</b>:</td> <td><select name="status">
63 <option value="0"<% if #status issue = Support.NEW then %> selected<% end %>>New</option>
64 <option value="1"<% if #status issue = Support.PENDING then %> selected<% end %>>Pending</option>
65 <option value="2"<% if #status issue = Support.CLOSED then %> selected<% end %>>Closed</option>
67 <tr> <td><input type="submit" value="Save"></td> </tr>
72 elseif $"save" <> "" then
73 val id = Web.stoi ($"save");
74 val issue = Support.lookupIssue id;
76 val oldStatus = #status issue;
77 val status = Web.stoi ($"status");
78 val newCat = Support.lookupCategory (Web.stoi ($"newCat"));
80 if catId <> #cat issue then
81 %><h3><b>Inconsistent cat field</b></h3><%
82 elseif (iff admin then not (Group.inGroupNum (#grp newCat)) else false) then
83 %><h3><b>Authorization failure</b></h3><%
84 elseif not (Support.validTitle title) then
85 %><h3><b>Invalid title</b></h3><%
86 elseif (iff status < 0 then false else status > 2) then
87 %><h3><b>Invalid status</b></h3><%
89 val status = (case status of
91 | 1 => Support.PENDING
92 | _ => Support.CLOSED);
94 Support.modIssue {issue with cat = #id newCat, title = title,
95 priv = ($"priv" = "on"),
97 if status <> oldStatus then
98 if not (Support.notifyStatus (you, oldStatus, status, id)) then
99 %><h3><b>Error sending e-mail notification</b></h3><%
102 viewingIssue := SOME id
103 %><h3><b>Issue saved</b></h3<%
106 elseif $"del" <> "" then
108 val id = Web.stoi ($"del");
109 val issue = Support.lookupIssue id;
111 if catId <> #cat issue then
112 %><h3><b>Inconsistent cat field</b></h3><%
113 elseif not admin then
114 %><h3><b>Authorization failure</b></h3><%
116 %><h3><b>Are you sure you want to delete "<% Web.html (#title issue) %>"?</b></h3>
117 <a href="issue?cat=<% catId %>&del2=<% id %>">Yes, delete "<% Web.html (#title issue) %>"!</a><%
120 elseif $"del2" <> "" then
121 val id = Web.stoi ($"del2");
122 val issue = Support.lookupIssue id;
124 if catId <> #cat issue then
125 %><h3><b>Inconsistent cat field</b></h3><%
126 elseif not admin then
127 %><h3><b>Authorization failure</b></h3><%
129 Support.deleteIssue id
130 %><h3><b>Issue "<% Web.html (#title issue) %>" deleted</b></h3><%
133 elseif $"cmd" = "post" then
134 val id = Web.stoi ($"iss");
135 viewingIssue := SOME id;
136 val issue = Support.lookupIssue id;
138 if catId <> #cat issue then
139 %><h3><b>Inconsistent cat field</b></h3><%
140 elseif not (Support.allowedToSee id) then
141 %><h3><b>Authorization failure</b></h3><%
143 val id = Support.addPost (you, id, $"body");
144 if not (Support.notifyPost id) then
145 %><h3><b>Error sending e-mail notification</b></h3><%
147 %><h3><b>Posted</b></h3><%
150 elseif $"modPost" <> "" then
152 val id = Web.stoi ($"modPost");
153 val post = Support.lookupPost id;
154 val issue = Support.lookupIssue (#iss post);
155 if catId <> #cat issue then
156 %><h3><b>Inconsistent cat field</b></h3><%
157 elseif not admin then
158 %><h3><b>You aren't authorized to modify that.</b></h3><%
160 <h3><b>Modify post</b></h3>
162 <form action="issue">
163 <input type="hidden" name="cat" value="<% catId %>">
164 <input type="hidden" name="savePost" value="<% id %>">
165 <textarea name="body" rows="10" cols="80" wrap="soft"><% Web.htmlNl (#body post) %></textarea>
166 <input type="submit" value="Save">
170 elseif $"savePost" <> "" then
171 val id = Web.stoi ($"savePost");
172 val post = Support.lookupPost id;
173 val issue = Support.lookupIssue (#iss post);
175 if catId <> #cat issue then
176 %><h3><b>Inconsistent cat field</b></h3><%
177 elseif not admin then
178 %><h3><b>Authorization failure</b></h3><%
180 Support.modPost {post with body = $"body"};
181 viewingIssue := SOME (#iss post)
182 %><h3><b>Post saved</b></h3<%
185 elseif $"delPost" <> "" then
187 val id = Web.stoi ($"delPost");
188 val post = Support.lookupPost id;
189 val issue = Support.lookupIssue (#iss post);
191 if catId <> #cat issue then
192 %><h3><b>Inconsistent cat field</b></h3><%
193 elseif not admin then
194 %><h3><b>Authorization failure</b></h3><%
196 %><h3><b>Are you sure you want to delete this post?</b></h3>
197 <blockquote><% Web.htmlNl (#body post) %></blockquote>
198 <a href="issue?cat=<% catId %>&delPost2=<% id %>">Yes, delete it!</a><%
201 elseif $"delPost2" <> "" then
202 val id = Web.stoi ($"delPost2");
203 val post = Support.lookupPost id;
204 val issue = Support.lookupIssue (#iss post);
206 if catId <> #cat issue then
207 %><h3><b>Inconsistent cat field</b></h3><%
208 elseif not admin then
209 %><h3><b>Authorization failure</b></h3><%
211 Support.deletePost id;
212 viewingIssue := SOME (#iss post)
213 %><h3><b>Post deleted</b></h3><%
216 elseif $"id" <> "" then
217 viewingIssue := SOME (Web.stoi ($"id"))
220 switch viewingIssue of
222 val issue = Support.lookupIssue id;
223 val canEdit = Support.allowedToEdit id;
224 val canView = Support.allowedToSee id;
225 if catId <> #cat issue then
226 %><h3><b>Inconsistent cat field</b></h3><%
227 elseif not canView then
228 %><h3><b>You aren't authorized to view that.</b></h3><%
230 val user = Init.lookupUser (#usr issue) %>
233 <tr> <td align="right"><b>Title</b>:</td> <td><% Web.html (#title issue) %></td> </tr>
234 <tr> <td align="right"><b>Created by</b>:</td> <td><a href="user?id=<% #usr issue %>"><% #name user %></a></td> </tr>
235 <tr> <td align="right"><b>At</b>:</td> <td><% #stamp issue %></td> </tr>
236 <tr> <td align="right"><b>Private</b>:</td> <td><% if #priv issue then %>yes<% else %>no<% end %></td> </tr>
237 <tr> <td align="right"><b>Status</b>:</td> <td><% switch #status issue of
238 Support.NEW => %>New<%
239 | Support.PENDING => %>Pending<%
240 | Support.CLOSED => %>Closed<%
245 <a href="issue?cat=<% catId %>&mod=<% id %>">Modify this issue</a><br>
246 <a href="issue?cat=<% catId %>&del=<% id %>">Delete this issue</a><br>
249 foreach (name, post) in Support.listPosts id do %>
251 <a href="user?id=<% #usr post %>"><% name %></a> at <% #stamp post %>:
253 <a href="issue?cat=<% catId %>&modPost=<% #id post %>">[Modify]</a>
254 <a href="issue?cat=<% catId %>&delPost=<% #id post %>">[Delete]</a>
257 <p><% Web.htmlNl (#body post) %></p>
263 <h3><b>Post to this thread</b></h3>
265 <form action="issue">
266 <input type="hidden" name="cat" value="<% catId %>">
267 <input type="hidden" name="iss" value="<% id %>">
268 <input type="hidden" name="cmd" value="post">
269 <textarea name="body" rows="10" cols="80"></textarea><br>
270 <input type="submit" value="Post">
276 if showNormal then %>
278 <a href="issue?cat=<% catId %>&cmd=new">New issue</a>
280 <h3><b>Open issues</b></h3>
283 <% val issues = iff admin then Support.listOpenCategoryIssuesAdmin catId
284 else Support.listOpenCategoryIssues (catId, you);
286 foreach issue in issues do
287 val user = Init.lookupUser (#usr issue) %>
288 <tr> <td><a href="issue?cat=<% catId %>&id=<% #id issue %>"><% Web.html (#title issue) %></a>
289 <% if #priv issue then %><i>(private)</i><% end %>
291 <td><a href="user?id=<% #usr issue %>"><% #name user %></a></td>
292 <td><% #stamp issue %></td>
293 <td><% switch #status issue of
294 Support.NEW => %>New<%
295 | Support.PENDING => %>Pending<%
296 | Support.CLOSED => %>Closed<%