Commit | Line | Data |
---|---|---|
1cb3df3f AC |
1 | <% val catId = Web.stoi ($"cat"); |
2 | val cat = Support.lookupCategory catId; | |
3 | val admin = Group.inGroupNum (#grp cat); | |
4 | val you = Init.getUserId() | |
5 | ||
6 | ref viewingIssue = NONE; | |
7 | ||
8 | @header[("title", ["Support: " ^ Web.html (#name cat)])]; | |
9 | ||
10 | ref showNormal = true; | |
11 | ||
12 | if $"cmd" = "new" then | |
13 | showNormal := false %> | |
14 | ||
15 | <h3><b>New issue</b></h3> | |
16 | ||
17 | <form action="issue"> | |
18 | <input type="hidden" name="cat" value="<% catId %>"> | |
19 | <input type="hidden" name="cmd" value="add"> | |
20 | <table> | |
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> | |
edeb626e | 23 | <tr> <td align="right"><b>Description</b>:</td> <td><textarea name="body" rows="10" cols="80" wrap="soft"></textarea></td> </tr> |
1cb3df3f AC |
24 | <tr> <td><input type="submit" value="Add"></td> </tr> |
25 | </table> | |
26 | </form> | |
27 | ||
28 | <% elseif $"cmd" = "add" then | |
29 | val title = $"title"; | |
30 | if not (Support.validTitle title) then | |
31 | %><h3><b>Invalid title</b></h3><% | |
32 | else | |
33 | val id = Support.addIssue (you, catId, title, $"priv" = "on", Support.NEW); | |
edeb626e AC |
34 | val _ = Support.addPost (you, id, $"body"); |
35 | if not (Support.notifyCreation id) then | |
36 | %><h3><b>Error sending e-mail notification</b></h3><% | |
37 | end; | |
1cb3df3f AC |
38 | viewingIssue := SOME id |
39 | end | |
40 | ||
5d851d7c AC |
41 | elseif $"cmd" = "list" then |
42 | showNormal := false %> | |
43 | <h3><b>All issues</b></h3> | |
44 | ||
45 | <table> | |
46 | <% foreach (name, issue) in Support.listCategoryIssues catId do | |
47 | if (iff admin then true else (iff #priv issue then (#usr issue = you) else true)) then %> | |
48 | <tr> <td><a href="issue?cat=<% catId %>&id=<% #id issue %>"><% Web.html (#title issue) %></a> | |
49 | <% if #priv issue then %><i>(private)</i><% end %> | |
50 | </td> | |
51 | <td><a href="user?id=<% #usr issue %>"><% name %></a></td> | |
52 | <td><% #stamp issue %></td> | |
53 | <td><% switch #status issue of | |
54 | Support.NEW => %>New<% | |
55 | | Support.PENDING => %>Pending<% | |
56 | | Support.CLOSED => %>Closed<% | |
57 | end %></td> </tr> | |
58 | <% end | |
59 | end %> | |
60 | </table> | |
61 | ||
62 | <% elseif $"mod" <> "" then | |
1cb3df3f AC |
63 | showNormal := false; |
64 | val id = Web.stoi ($"mod"); | |
65 | val issue = Support.lookupIssue id; | |
66 | if catId <> #cat issue then | |
67 | %><h3><b>Inconsistent cat field</b></h3><% | |
68 | elseif not admin then | |
69 | %><h3><b>You aren't authorized to modify that.</b></h3><% | |
70 | else %> | |
71 | <h3><b>Modify issue</b></h3> | |
72 | ||
73 | <form action="issue"> | |
74 | <input type="hidden" name="cat" value="<% catId %>"> | |
75 | <input type="hidden" name="save" value="<% id %>"> | |
76 | <table> | |
77 | <tr> <td align="right"><b>Category</b>:</td> <td><select name="newCat"> | |
78 | <% foreach cat in Support.listCategories () do %> | |
79 | <option value="<% #id cat %>"<% if #id cat = catId then %> selected<% end %>><% Web.html (#name cat) %></option> | |
80 | <% end %></select></td> </tr> | |
81 | <tr> <td align="right"><b>Title</b>:</td> <td><input name="title" value="<% Web.html (#title issue) %>"></td> </tr> | |
82 | <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> | |
83 | <tr> <td align="right"><b>Status</b>:</td> <td><select name="status"> | |
84 | <option value="0"<% if #status issue = Support.NEW then %> selected<% end %>>New</option> | |
85 | <option value="1"<% if #status issue = Support.PENDING then %> selected<% end %>>Pending</option> | |
86 | <option value="2"<% if #status issue = Support.CLOSED then %> selected<% end %>>Closed</option> | |
87 | </select></td> </tr> | |
edeb626e | 88 | <tr> <td><input type="submit" value="Save"></td> </tr> |
1cb3df3f AC |
89 | </table> |
90 | </form> | |
91 | <% end | |
92 | ||
93 | elseif $"save" <> "" then | |
94 | val id = Web.stoi ($"save"); | |
95 | val issue = Support.lookupIssue id; | |
96 | val title = $"title"; | |
edeb626e | 97 | val oldStatus = #status issue; |
1cb3df3f AC |
98 | val status = Web.stoi ($"status"); |
99 | val newCat = Support.lookupCategory (Web.stoi ($"newCat")); | |
100 | ||
101 | if catId <> #cat issue then | |
102 | %><h3><b>Inconsistent cat field</b></h3><% | |
103 | elseif (iff admin then not (Group.inGroupNum (#grp newCat)) else false) then | |
104 | %><h3><b>Authorization failure</b></h3><% | |
105 | elseif not (Support.validTitle title) then | |
106 | %><h3><b>Invalid title</b></h3><% | |
107 | elseif (iff status < 0 then false else status > 2) then | |
108 | %><h3><b>Invalid status</b></h3><% | |
109 | else | |
edeb626e AC |
110 | val status = (case status of |
111 | 0 => Support.NEW | |
112 | | 1 => Support.PENDING | |
113 | | _ => Support.CLOSED); | |
114 | ||
1cb3df3f AC |
115 | Support.modIssue {issue with cat = #id newCat, title = title, |
116 | priv = ($"priv" = "on"), | |
edeb626e AC |
117 | status = status}; |
118 | if status <> oldStatus then | |
119 | if not (Support.notifyStatus (you, oldStatus, status, id)) then | |
120 | %><h3><b>Error sending e-mail notification</b></h3><% | |
121 | end | |
122 | end; | |
1cb3df3f AC |
123 | viewingIssue := SOME id |
124 | %><h3><b>Issue saved</b></h3<% | |
125 | end | |
126 | ||
127 | elseif $"del" <> "" then | |
128 | showNormal := false; | |
129 | val id = Web.stoi ($"del"); | |
130 | val issue = Support.lookupIssue id; | |
131 | ||
132 | if catId <> #cat issue then | |
133 | %><h3><b>Inconsistent cat field</b></h3><% | |
134 | elseif not admin then | |
135 | %><h3><b>Authorization failure</b></h3><% | |
136 | else | |
137 | %><h3><b>Are you sure you want to delete "<% Web.html (#title issue) %>"?</b></h3> | |
138 | <a href="issue?cat=<% catId %>&del2=<% id %>">Yes, delete "<% Web.html (#title issue) %>"!</a><% | |
139 | end | |
140 | ||
141 | elseif $"del2" <> "" then | |
142 | val id = Web.stoi ($"del2"); | |
143 | val issue = Support.lookupIssue id; | |
144 | ||
145 | if catId <> #cat issue then | |
146 | %><h3><b>Inconsistent cat field</b></h3><% | |
147 | elseif not admin then | |
148 | %><h3><b>Authorization failure</b></h3><% | |
149 | else | |
150 | Support.deleteIssue id | |
151 | %><h3><b>Issue "<% Web.html (#title issue) %>" deleted</b></h3><% | |
152 | end | |
153 | ||
edeb626e AC |
154 | elseif $"cmd" = "post" then |
155 | val id = Web.stoi ($"iss"); | |
156 | viewingIssue := SOME id; | |
157 | val issue = Support.lookupIssue id; | |
158 | ||
159 | if catId <> #cat issue then | |
160 | %><h3><b>Inconsistent cat field</b></h3><% | |
161 | elseif not (Support.allowedToSee id) then | |
162 | %><h3><b>Authorization failure</b></h3><% | |
163 | else | |
164 | val id = Support.addPost (you, id, $"body"); | |
165 | if not (Support.notifyPost id) then | |
166 | %><h3><b>Error sending e-mail notification</b></h3><% | |
167 | end | |
168 | %><h3><b>Posted</b></h3><% | |
169 | end | |
170 | ||
171 | elseif $"modPost" <> "" then | |
172 | showNormal := false; | |
173 | val id = Web.stoi ($"modPost"); | |
174 | val post = Support.lookupPost id; | |
175 | val issue = Support.lookupIssue (#iss post); | |
176 | if catId <> #cat issue then | |
177 | %><h3><b>Inconsistent cat field</b></h3><% | |
178 | elseif not admin then | |
179 | %><h3><b>You aren't authorized to modify that.</b></h3><% | |
180 | else %> | |
181 | <h3><b>Modify post</b></h3> | |
182 | ||
183 | <form action="issue"> | |
184 | <input type="hidden" name="cat" value="<% catId %>"> | |
185 | <input type="hidden" name="savePost" value="<% id %>"> | |
186 | <textarea name="body" rows="10" cols="80" wrap="soft"><% Web.htmlNl (#body post) %></textarea> | |
187 | <input type="submit" value="Save"> | |
188 | </form> | |
189 | <% end | |
190 | ||
191 | elseif $"savePost" <> "" then | |
192 | val id = Web.stoi ($"savePost"); | |
193 | val post = Support.lookupPost id; | |
194 | val issue = Support.lookupIssue (#iss post); | |
195 | ||
196 | if catId <> #cat issue then | |
197 | %><h3><b>Inconsistent cat field</b></h3><% | |
198 | elseif not admin then | |
199 | %><h3><b>Authorization failure</b></h3><% | |
200 | else | |
201 | Support.modPost {post with body = $"body"}; | |
202 | viewingIssue := SOME (#iss post) | |
203 | %><h3><b>Post saved</b></h3<% | |
204 | end | |
205 | ||
206 | elseif $"delPost" <> "" then | |
207 | showNormal := false; | |
208 | val id = Web.stoi ($"delPost"); | |
209 | val post = Support.lookupPost id; | |
210 | val issue = Support.lookupIssue (#iss post); | |
211 | ||
212 | if catId <> #cat issue then | |
213 | %><h3><b>Inconsistent cat field</b></h3><% | |
214 | elseif not admin then | |
215 | %><h3><b>Authorization failure</b></h3><% | |
216 | else | |
217 | %><h3><b>Are you sure you want to delete this post?</b></h3> | |
218 | <blockquote><% Web.htmlNl (#body post) %></blockquote> | |
219 | <a href="issue?cat=<% catId %>&delPost2=<% id %>">Yes, delete it!</a><% | |
220 | end | |
221 | ||
222 | elseif $"delPost2" <> "" then | |
223 | val id = Web.stoi ($"delPost2"); | |
224 | val post = Support.lookupPost id; | |
225 | val issue = Support.lookupIssue (#iss post); | |
226 | ||
227 | if catId <> #cat issue then | |
228 | %><h3><b>Inconsistent cat field</b></h3><% | |
229 | elseif not admin then | |
230 | %><h3><b>Authorization failure</b></h3><% | |
231 | else | |
232 | Support.deletePost id; | |
233 | viewingIssue := SOME (#iss post) | |
234 | %><h3><b>Post deleted</b></h3><% | |
235 | end | |
236 | ||
1cb3df3f AC |
237 | elseif $"id" <> "" then |
238 | viewingIssue := SOME (Web.stoi ($"id")) | |
239 | end; | |
240 | ||
241 | switch viewingIssue of | |
242 | SOME id => | |
243 | val issue = Support.lookupIssue id; | |
edeb626e AC |
244 | val canEdit = Support.allowedToEdit id; |
245 | val canView = Support.allowedToSee id; | |
1cb3df3f AC |
246 | if catId <> #cat issue then |
247 | %><h3><b>Inconsistent cat field</b></h3><% | |
248 | elseif not canView then | |
249 | %><h3><b>You aren't authorized to view that.</b></h3><% | |
250 | else | |
251 | val user = Init.lookupUser (#usr issue) %> | |
252 | ||
253 | <table> | |
254 | <tr> <td align="right"><b>Title</b>:</td> <td><% Web.html (#title issue) %></td> </tr> | |
255 | <tr> <td align="right"><b>Created by</b>:</td> <td><a href="user?id=<% #usr issue %>"><% #name user %></a></td> </tr> | |
256 | <tr> <td align="right"><b>At</b>:</td> <td><% #stamp issue %></td> </tr> | |
257 | <tr> <td align="right"><b>Private</b>:</td> <td><% if #priv issue then %>yes<% else %>no<% end %></td> </tr> | |
258 | <tr> <td align="right"><b>Status</b>:</td> <td><% switch #status issue of | |
259 | Support.NEW => %>New<% | |
260 | | Support.PENDING => %>Pending<% | |
261 | | Support.CLOSED => %>Closed<% | |
262 | end %></td> </tr> | |
263 | </table> | |
264 | ||
265 | <% if admin then %> | |
266 | <a href="issue?cat=<% catId %>&mod=<% id %>">Modify this issue</a><br> | |
267 | <a href="issue?cat=<% catId %>&del=<% id %>">Delete this issue</a><br> | |
edeb626e AC |
268 | <% end; |
269 | ||
270 | foreach (name, post) in Support.listPosts id do %> | |
271 | <br><hr><br> | |
272 | <a href="user?id=<% #usr post %>"><% name %></a> at <% #stamp post %>: | |
273 | <% if admin then %> | |
274 | <a href="issue?cat=<% catId %>&modPost=<% #id post %>">[Modify]</a> | |
275 | <a href="issue?cat=<% catId %>&delPost=<% #id post %>">[Delete]</a> | |
276 | <% end %> | |
277 | ||
278 | <p><% Web.htmlNl (#body post) %></p> | |
279 | ||
1cb3df3f AC |
280 | <% end %> |
281 | ||
edeb626e AC |
282 | <br><hr><br> |
283 | ||
284 | <h3><b>Post to this thread</b></h3> | |
285 | ||
286 | <form action="issue"> | |
287 | <input type="hidden" name="cat" value="<% catId %>"> | |
288 | <input type="hidden" name="iss" value="<% id %>"> | |
289 | <input type="hidden" name="cmd" value="post"> | |
290 | <textarea name="body" rows="10" cols="80"></textarea><br> | |
291 | <input type="submit" value="Post"> | |
292 | </form> | |
293 | ||
294 | <% end | |
1cb3df3f AC |
295 | |
296 | | NONE => | |
297 | if showNormal then %> | |
298 | ||
5d851d7c AC |
299 | <a href="issue?cat=<% catId %>&cmd=new">New issue</a><br> |
300 | <a href="issue?cat=<% catId %>&cmd=list">List all issues</a> | |
1cb3df3f AC |
301 | |
302 | <h3><b>Open issues</b></h3> | |
303 | ||
304 | <table> | |
305 | <% val issues = iff admin then Support.listOpenCategoryIssuesAdmin catId | |
306 | else Support.listOpenCategoryIssues (catId, you); | |
307 | ||
5d851d7c | 308 | foreach (name, issue) in issues do %> |
1cb3df3f AC |
309 | <tr> <td><a href="issue?cat=<% catId %>&id=<% #id issue %>"><% Web.html (#title issue) %></a> |
310 | <% if #priv issue then %><i>(private)</i><% end %> | |
311 | </td> | |
5d851d7c | 312 | <td><a href="user?id=<% #usr issue %>"><% name %></a></td> |
1cb3df3f AC |
313 | <td><% #stamp issue %></td> |
314 | <td><% switch #status issue of | |
315 | Support.NEW => %>New<% | |
316 | | Support.PENDING => %>Pending<% | |
317 | | Support.CLOSED => %>Closed<% | |
318 | end %></td> </tr> | |
319 | <% end %> | |
320 | ||
321 | <% end | |
322 | end %> | |
323 | ||
324 | <% @footer[] %> |