Some more support integration
authorAdam Chlipala <adamc@hcoop.net>
Mon, 18 Apr 2005 01:29:38 +0000 (01:29 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Mon, 18 Apr 2005 01:29:38 +0000 (01:29 +0000)
TODO
issue.mlt
portal.mlt
support.sig
support.sml

diff --git a/TODO b/TODO
index d6a985c..4baccbe 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,12 +1,6 @@
 Member data
        - Summarize these with publicly accessible static pages
 
-Generic support requests
-       - Admin categories of requests, where each has an optional group of responsible parties
-       - Allow subscription to categories to receive e-mail notices
-       - Actual postings to request threads
-       - Maintaining status information
-
 Specific requests
        - Join, with display of pending applications for all members to read
        - apt install requests
index 5e116f8..fdfface 100644 (file)
--- a/issue.mlt
+++ b/issue.mlt
@@ -38,7 +38,28 @@ if $"cmd" = "new" then
                viewingIssue := SOME id
        end
 
-elseif $"mod" <> "" then
+elseif $"cmd" = "list" then
+       showNormal := false %>
+       <h3><b>All issues</b></h3>
+
+<table>
+<% foreach (name, issue) in Support.listCategoryIssues catId do
+       if (iff admin then true else (iff #priv issue then (#usr issue = you) else true)) then %>
+       <tr> <td><a href="issue?cat=<% catId %>&id=<% #id issue %>"><% Web.html (#title issue) %></a>
+<% if #priv issue then %><i>(private)</i><% end %>
+       </td>
+       <td><a href="user?id=<% #usr issue %>"><% name %></a></td>
+       <td><% #stamp issue %></td>
+       <td><% switch #status issue of
+                         Support.NEW => %>New<%
+                       | Support.PENDING => %>Pending<%
+                       | Support.CLOSED => %>Closed<%
+               end %></td> </tr>
+<% end
+end %>
+</table>
+
+<% elseif $"mod" <> "" then
        showNormal := false;
        val id = Web.stoi ($"mod");
        val issue = Support.lookupIssue id;
@@ -275,7 +296,8 @@ foreach (name, post) in Support.listPosts id do %>
        | NONE =>
 if showNormal then %>
 
-<a href="issue?cat=<% catId %>&cmd=new">New issue</a>
+<a href="issue?cat=<% catId %>&cmd=new">New issue</a><br>
+<a href="issue?cat=<% catId %>&cmd=list">List all issues</a>
 
 <h3><b>Open issues</b></h3>
 
@@ -283,12 +305,11 @@ if showNormal then %>
 <% val issues = iff admin then Support.listOpenCategoryIssuesAdmin catId
                        else Support.listOpenCategoryIssues (catId, you);
 
-foreach issue in issues do
-       val user = Init.lookupUser (#usr issue) %>
+foreach (name, issue) in issues do %>
        <tr> <td><a href="issue?cat=<% catId %>&id=<% #id issue %>"><% Web.html (#title issue) %></a>
 <% if #priv issue then %><i>(private)</i><% end %>
        </td>
-       <td><a href="user?id=<% #usr issue %>"><% #name user %></a></td>
+       <td><a href="user?id=<% #usr issue %>"><% name %></a></td>
        <td><% #stamp issue %></td>
        <td><% switch #status issue of
                          Support.NEW => %>New<%
index 0b4f014..a4cc617 100644 (file)
@@ -20,4 +20,16 @@ val bal = Balance.lookupBalance (#bal you);
 (<% Web.html (#starts pol) %> to <% Web.html (#ends pol) %>)</li>
 <% end %>
 
+<h3><b><a href="support">Open support issues</a></b></h3>
+
+<% foreach (name, issue) in Support.listOpenIssues (#id you) do %>
+<a href="user?id=<% #usr issue %>"><% name %></a>: <a href="issue?cat=<% #cat issue %>&id=<% #id issue %>"><% Web.html (#title issue) %></a>
+<% switch #status issue of
+         Support.NEW => %>(New)<%
+       | Support.PENDING => %>(Pending)<%
+       | Support.CLOSED => %>(Closed)<%
+end %>
+<br>
+<% end %>
+
 <% @footer [] %>
\ No newline at end of file
index e67494f..9036954 100644 (file)
@@ -19,9 +19,10 @@ sig
 
     val lookupIssue : int -> issue
     val listIssues : unit -> issue list
-    val listCategoryIssues : int -> issue list
-    val listOpenCategoryIssues : int * int -> issue list
-    val listOpenCategoryIssuesAdmin : int -> issue list
+    val listOpenIssues : int -> (string * issue) list
+    val listCategoryIssues : int -> (string * issue) list
+    val listOpenCategoryIssues : int * int -> (string * issue) list
+    val listOpenCategoryIssuesAdmin : int -> (string * issue) list
     val addIssue : int * int * string * bool * status -> int
     val modIssue : issue -> unit
     val deleteIssue : int -> unit
index 7aed0ea..701737b 100644 (file)
@@ -95,26 +95,46 @@ fun listIssues () =
                                   FROM SupIssue
                                   ORDER BY stamp DESC`)
 
+fun mkIssueRow' (name :: rest) = (C.stringFromSql name, mkIssueRow rest)
+  | mkIssueRow' r = Init.rowError ("issue'", r)
+
+fun listOpenIssues usr =
+    C.map (getDb ()) mkIssueRow' ($`SELECT WebUser.name, SupIssue.id, SupIssue.usr, SupIssue.cat, title, priv, status, stamp
+                                   FROM SupIssue JOIN SupCategory ON cat = SupCategory.id
+                                      JOIN WebUser ON WebUser.id = SupIssue.usr
+                                   WHERE status < 2
+                                      AND (usr = ^(C.intToSql usr)
+                                        OR ((SELECT COUNT( * ) FROM SupSubscription
+                                             WHERE SupSubscription.usr = ^(C.intToSql usr)
+                                                AND SupSubscription.cat = SupIssue.cat) > 0
+                                            AND (not priv OR (SELECT COUNT( * ) FROM Membership
+                                                              WHERE Membership.usr = ^(C.intToSql usr)
+                                                                 AND Membership.grp = SupCategory.grp) > 0)))
+                                   ORDER BY stamp DESC`)
+
 fun listCategoryIssues cat =
-    C.map (getDb ()) mkIssueRow ($`SELECT id, usr, cat, title, priv, status, stamp
-                                  FROM SupIssue
-                                  WHERE cat = ^(C.intToSql cat)
-                                  ORDER BY stamp DESC`)
+    C.map (getDb ()) mkIssueRow' ($`SELECT WebUser.name, SupIssue.id, usr, cat, title, priv, status, stamp
+                                   FROM SupIssue
+                                      JOIN WebUser ON WebUser.id = usr
+                                   WHERE cat = ^(C.intToSql cat)
+                                   ORDER BY stamp DESC`)
 
 fun listOpenCategoryIssues (cat, usr) =
-    C.map (getDb ()) mkIssueRow ($`SELECT id, usr, cat, title, priv, status, stamp
-                                  FROM SupIssue
-                                  WHERE cat = ^(C.intToSql cat)
-                                     AND status < 2
-                                     AND (NOT priv OR usr = ^(C.intToSql usr))
-                                  ORDER BY stamp DESC`)
+    C.map (getDb ()) mkIssueRow' ($`SELECT name, SupIssue.id, usr, cat, title, priv, status, stamp
+                                   FROM SupIssue
+                                      JOIN WebUser ON WebUser.id = usr
+                                   WHERE cat = ^(C.intToSql cat)
+                                      AND status < 2
+                                      AND (NOT priv OR usr = ^(C.intToSql usr))
+                                   ORDER BY stamp DESC`)
 
 fun listOpenCategoryIssuesAdmin cat =
-    C.map (getDb ()) mkIssueRow ($`SELECT id, usr, cat, title, priv, status, stamp
-                                  FROM SupIssue
-                                  WHERE cat = ^(C.intToSql cat)
-                                     AND status < 2
-                                  ORDER BY stamp DESC`)
+    C.map (getDb ()) mkIssueRow' ($`SELECT name, SupIssue.id, usr, cat, title, priv, status, stamp
+                                   FROM SupIssue
+                                      JOIN WebUser ON WebUser.id = usr
+                                   WHERE cat = ^(C.intToSql cat)
+                                      AND status < 2
+                                   ORDER BY stamp DESC`)
 
 fun addIssue (usr, cat, title, priv, status) =
     let
@@ -233,7 +253,7 @@ fun allowedToEdit iss =
        Group.inGroupNum (#grp cat) orelse (Init.getUserId () = #usr iss)
     end
 
-fun writeRecipients (mail, iss : issue, cat : category) =
+fun writeRecipients (mail, iss : issue, cat : category, noName) =
     let
        val query =
            if #priv iss then
@@ -243,8 +263,16 @@ fun writeRecipients (mail, iss : issue, cat : category) =
                $`SELECT name
                  FROM WebUser JOIN SupSubscription ON (usr = id AND cat = ^(C.intToSql (#id cat)))`
 
-       fun doOne [name] = (Mail.mwrite (mail, C.stringFromSql name);
-                           Mail.mwrite (mail, ","))
+       fun doOne [name] =
+           let
+               val name = C.stringFromSql name
+           in
+               if name = noName then
+                   ()
+               else
+                   (Mail.mwrite (mail, name);
+                    Mail.mwrite (mail, ","))
+           end
     in
        Mail.mwrite (mail, "Bcc: ");
        C.app (getDb ()) doOne query;
@@ -262,7 +290,7 @@ fun notify (prefix, f) iss =
        Mail.mwrite (mail, "From: Hcoop Support System <support@hcoop.net>\nTo: ");
        Mail.mwrite (mail, #name user);
        Mail.mwrite (mail, "@hcoop.net\n");
-       writeRecipients (mail, iss, cat);
+       writeRecipients (mail, iss, cat, #name user);
        Mail.mwrite (mail, "Subject: ");
        Mail.mwrite (mail, prefix);
        Mail.mwrite (mail, #title iss);