<table>
<tr> <td align="right"><b>Title</b>:</td> <td><input name="title"></td> </tr>
<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>
+<tr> <td align="right"><b>Description</b>:</td> <td><textarea name="body" rows="10" cols="80" wrap="soft"></textarea></td> </tr>
<tr> <td><input type="submit" value="Add"></td> </tr>
</table>
</form>
%><h3><b>Invalid title</b></h3><%
else
val id = Support.addIssue (you, catId, title, $"priv" = "on", Support.NEW);
+ val _ = Support.addPost (you, id, $"body");
+ if not (Support.notifyCreation id) then
+ %><h3><b>Error sending e-mail notification</b></h3><%
+ end;
viewingIssue := SOME id
end
<option value="1"<% if #status issue = Support.PENDING then %> selected<% end %>>Pending</option>
<option value="2"<% if #status issue = Support.CLOSED then %> selected<% end %>>Closed</option>
</select></td> </tr>
-<tr> <td><input type="submit" value="Add"></td> </tr>
+<tr> <td><input type="submit" value="Save"></td> </tr>
</table>
</form>
<% end
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"));
elseif (iff status < 0 then false else status > 2) then
%><h3><b>Invalid status</b></h3><%
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 = (case status of
- 0 => Support.NEW
- | 1 => Support.PENDING
- | _ => Support.CLOSED)};
+ status = status};
+ if status <> oldStatus then
+ if not (Support.notifyStatus (you, oldStatus, status, id)) then
+ %><h3><b>Error sending e-mail notification</b></h3><%
+ end
+ end;
viewingIssue := SOME id
%><h3><b>Issue saved</b></h3<%
end
%><h3><b>Issue "<% Web.html (#title issue) %>" deleted</b></h3><%
end
+elseif $"cmd" = "post" then
+ val id = Web.stoi ($"iss");
+ viewingIssue := SOME id;
+ val issue = Support.lookupIssue id;
+
+ if catId <> #cat issue then
+ %><h3><b>Inconsistent cat field</b></h3><%
+ elseif not (Support.allowedToSee id) then
+ %><h3><b>Authorization failure</b></h3><%
+ else
+ val id = Support.addPost (you, id, $"body");
+ if not (Support.notifyPost id) then
+ %><h3><b>Error sending e-mail notification</b></h3><%
+ end
+ %><h3><b>Posted</b></h3><%
+ 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
+ %><h3><b>Inconsistent cat field</b></h3><%
+ elseif not admin then
+ %><h3><b>You aren't authorized to modify that.</b></h3><%
+ else %>
+<h3><b>Modify post</b></h3>
+
+<form action="issue">
+<input type="hidden" name="cat" value="<% catId %>">
+<input type="hidden" name="savePost" value="<% id %>">
+<textarea name="body" rows="10" cols="80" wrap="soft"><% Web.htmlNl (#body post) %></textarea>
+<input type="submit" value="Save">
+</form>
+<% 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
+ %><h3><b>Inconsistent cat field</b></h3><%
+ elseif not admin then
+ %><h3><b>Authorization failure</b></h3><%
+ else
+ Support.modPost {post with body = $"body"};
+ viewingIssue := SOME (#iss post)
+ %><h3><b>Post saved</b></h3<%
+ end
+
+elseif $"delPost" <> "" then
+ showNormal := false;
+ val id = Web.stoi ($"delPost");
+ val post = Support.lookupPost id;
+ val issue = Support.lookupIssue (#iss post);
+
+ if catId <> #cat issue then
+ %><h3><b>Inconsistent cat field</b></h3><%
+ elseif not admin then
+ %><h3><b>Authorization failure</b></h3><%
+ else
+ %><h3><b>Are you sure you want to delete this post?</b></h3>
+ <blockquote><% Web.htmlNl (#body post) %></blockquote>
+ <a href="issue?cat=<% catId %>&delPost2=<% id %>">Yes, delete it!</a><%
+ 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
+ %><h3><b>Inconsistent cat field</b></h3><%
+ elseif not admin then
+ %><h3><b>Authorization failure</b></h3><%
+ else
+ Support.deletePost id;
+ viewingIssue := SOME (#iss post)
+ %><h3><b>Post deleted</b></h3><%
+ 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);
+ val canEdit = Support.allowedToEdit id;
+ val canView = Support.allowedToSee id;
if catId <> #cat issue then
%><h3><b>Inconsistent cat field</b></h3><%
elseif not canView then
<% if admin then %>
<a href="issue?cat=<% catId %>&mod=<% id %>">Modify this issue</a><br>
<a href="issue?cat=<% catId %>&del=<% id %>">Delete this issue</a><br>
+<% end;
+
+foreach (name, post) in Support.listPosts id do %>
+<br><hr><br>
+<a href="user?id=<% #usr post %>"><% name %></a> at <% #stamp post %>:
+<% if admin then %>
+<a href="issue?cat=<% catId %>&modPost=<% #id post %>">[Modify]</a>
+<a href="issue?cat=<% catId %>&delPost=<% #id post %>">[Delete]</a>
+<% end %>
+
+<p><% Web.htmlNl (#body post) %></p>
+
<% end %>
-<% end
+<br><hr><br>
+
+<h3><b>Post to this thread</b></h3>
+
+<form action="issue">
+<input type="hidden" name="cat" value="<% catId %>">
+<input type="hidden" name="iss" value="<% id %>">
+<input type="hidden" name="cmd" value="post">
+<textarea name="body" rows="10" cols="80"></textarea><br>
+<input type="submit" value="Post">
+</form>
+
+<% end
| NONE =>
if showNormal then %>