Save pending/closing time stamps for misc support issues
authoradamch <adamch>
Sun, 25 Feb 2007 22:49:39 +0000 (22:49 +0000)
committeradamch <adamch>
Sun, 25 Feb 2007 22:49:39 +0000 (22:49 +0000)
issue.mlt
sec.mlt
support.sig
support.sml
tables.sql

index 3a6cb1b..f8a7230 100644 (file)
--- a/issue.mlt
+++ b/issue.mlt
@@ -260,6 +260,12 @@ switch viewingIssue of
        | Support.PENDING => %>Pending<%
        | Support.CLOSED => %>Closed<%
        end %></td> </tr>
+<%     switch #pstamp issue of
+                 SOME stamp => %><tr> <td>Changed to pending:</td> <td><% stamp %></td> </tr><%
+       end;
+       switch #cstamp issue of
+                 SOME stamp => %><tr> <td>Closed:</td> <td><% stamp %></td> </tr><%
+       end %>
 </table>
 
 <% if admin then %>
diff --git a/sec.mlt b/sec.mlt
index 7afdced..5c0f4af 100644 (file)
--- a/sec.mlt
+++ b/sec.mlt
@@ -251,6 +251,8 @@ if showNormal then %>
 
 <h3>Request socket permissions change</h3>
 
+<p>Keep in mind that, if your request is granted, it will never apply to existing log-in sessions. Close them and re-connect to take advantage of your new privileges.</p>
+
 <form action="sec" method="post">
 <input type="hidden" name="node" value="<% nodeNum %>">
 <input type="hidden" name="uname" value="<% uname %>">
@@ -338,7 +340,7 @@ end%>
 
 <p>You can find a description of rule formats <a href="http://wiki.hcoop.net/wiki/FirewallRules">on our wiki</a>. Enter here the rule you want, without the initial <tt>user</tt> portion.</p>
 
-<p>Please note that <b>your firewall rule will be useless</b> if you don't first request the corresponding socket privileges at the top of this page.</p>
+<p>Please note that <b>your firewall rule will be useless</b> if you don't first request the corresponding socket privileges at the top of this page. Also, common ports like 80 (HTTP) are open to everyone with socket permissions. Verify that you can't access a port after socket permissions have been granted before requesting a special rule here.</p>
 
 <form action="sec" method="post">
 <input type="hidden" name="node" value="<% nodeNum %>">
index 9036954..c94edc1 100644 (file)
@@ -6,7 +6,8 @@ sig
           | CLOSED
 
     type category = { id : int, grp : int, name : string, descr : string }
-    type issue = { id : int, usr : int, cat : int, title : string, priv : bool, status : status, stamp : Init.C.timestamp }
+    type issue = { id : int, usr : int, cat : int, title : string, priv : bool, status : status,
+                  stamp : Init.C.timestamp, pstamp : Init.C.timestamp option, cstamp : Init.C.timestamp option }
     type post = { id : int, usr : int, iss : int, body : string, stamp : Init.C.timestamp }
     type subscription = { usr : int, cat : int }
 
index b8e7a80..b82175b 100644 (file)
@@ -9,7 +9,8 @@ datatype status =
        | CLOSED
 
 type category = { id : int, grp : int, name : string, descr : string }
-type issue = { id : int, usr : int, cat : int, title : string, priv : bool, status : status, stamp : C.timestamp }
+type issue = { id : int, usr : int, cat : int, title : string, priv : bool, status : status,
+              stamp : C.timestamp, cstamp : C.timestamp option, pstamp : C.timestamp option }
 type post = { id : int, usr : int, iss : int, body : string, stamp : C.timestamp }
 type subscription = { usr : int, cat : int }
 
@@ -79,19 +80,22 @@ fun statusFromSql v =
       | 2 => CLOSED
       | _ => raise Fail "Bad support issue status"
 
-fun mkIssueRow [id, usr, cat, title, priv, status, stamp] =
+fun mkIssueRow [id, usr, cat, title, priv, status, stamp, pstamp, cstamp] =
     {id = C.intFromSql id, usr = C.intFromSql usr, cat = C.intFromSql cat,
      title = C.stringFromSql title, priv = C.boolFromSql priv,
-     status = statusFromSql status, stamp = C.timestampFromSql stamp}
+     status = statusFromSql status, stamp = C.timestampFromSql stamp,
+     pstamp = if C.isNull pstamp then NONE else SOME (C.timestampFromSql pstamp),
+     cstamp = if C.isNull cstamp then NONE else SOME (C.timestampFromSql cstamp)}
+
   | mkIssueRow row = rowError ("issue", row)
 
 fun lookupIssue id =
-    mkIssueRow (C.oneRow (getDb ()) ($`SELECT id, usr, cat, title, priv, status, stamp
+    mkIssueRow (C.oneRow (getDb ()) ($`SELECT id, usr, cat, title, priv, status, stamp, pstamp, cstamp
                                       FROM SupIssue
                                       WHERE id = ^(C.intToSql id)`))
 
 fun listIssues () =
-    C.map (getDb ()) mkIssueRow ($`SELECT id, usr, cat, title, priv, status, stamp
+    C.map (getDb ()) mkIssueRow ($`SELECT id, usr, cat, title, priv, status, stamp, pstamp, cstamp
                                   FROM SupIssue
                                   ORDER BY stamp DESC`)
 
@@ -99,7 +103,7 @@ 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
+    C.map (getDb ()) mkIssueRow' ($`SELECT WebUser.name, SupIssue.id, SupIssue.usr, SupIssue.cat, title, priv, status, stamp, pstamp, cstamp
                                    FROM SupIssue JOIN SupCategory ON cat = SupCategory.id
                                       JOIN WebUser ON WebUser.id = SupIssue.usr
                                    WHERE status < 2
@@ -113,14 +117,14 @@ fun listOpenIssues usr =
                                    ORDER BY stamp DESC`)
 
 fun listCategoryIssues cat =
-    C.map (getDb ()) mkIssueRow' ($`SELECT WebUser.name, SupIssue.id, usr, cat, title, priv, status, stamp
+    C.map (getDb ()) mkIssueRow' ($`SELECT WebUser.name, SupIssue.id, usr, cat, title, priv, status, stamp, pstamp, cstamp
                                    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 name, SupIssue.id, usr, cat, title, priv, status, stamp
+    C.map (getDb ()) mkIssueRow' ($`SELECT name, SupIssue.id, usr, cat, title, priv, status, stamp, pstamp, cstamp
                                    FROM SupIssue
                                       JOIN WebUser ON WebUser.id = usr
                                    WHERE cat = ^(C.intToSql cat)
@@ -129,7 +133,7 @@ fun listOpenCategoryIssues (cat, usr) =
                                    ORDER BY stamp DESC`)
 
 fun listOpenCategoryIssuesAdmin cat =
-    C.map (getDb ()) mkIssueRow' ($`SELECT name, SupIssue.id, usr, cat, title, priv, status, stamp
+    C.map (getDb ()) mkIssueRow' ($`SELECT name, SupIssue.id, usr, cat, title, priv, status, stamp, pstamp, cstamp
                                    FROM SupIssue
                                       JOIN WebUser ON WebUser.id = usr
                                    WHERE cat = ^(C.intToSql cat)
@@ -141,10 +145,10 @@ fun addIssue (usr, cat, title, priv, status) =
        val db = getDb ()
        val id = nextSeq (db, "SupIssueSeq")
     in
-       C.dml db ($`INSERT INTO SupIssue (id, usr, cat, title, priv, status, stamp)
+       C.dml db ($`INSERT INTO SupIssue (id, usr, cat, title, priv, status, stamp, pstamp, cstamp)
                    VALUES (^(C.intToSql id), ^(C.intToSql usr), ^(C.intToSql cat),
                            ^(C.stringToSql title), ^(C.boolToSql priv),
-                           ^(statusToSql status), CURRENT_TIMESTAMP)`);
+                           ^(statusToSql status), CURRENT_TIMESTAMP, NULL, NULL)`);
        id
     end
 
@@ -152,6 +156,10 @@ fun modIssue (iss : issue) =
     let
        val db = getDb ()
     in
+       case #status iss of
+           PENDING => ignore (C.dml db ($`UPDATE SupIssue SET pstamp = CURRENT_TIMESTAMP`))
+         | CLOSED => ignore (C.dml db ($`UPDATE SupIssue SET cstamp = CURRENT_TIMESTAMP`))
+         | _ => ();
        ignore (C.dml db ($`UPDATE SupIssue SET
                            usr = ^(C.intToSql (#usr iss)), cat = ^(C.intToSql (#cat iss)),
                               title = ^(C.stringToSql (#title iss)), priv = ^(C.boolToSql (#priv iss)),
index e28196a..682f44d 100644 (file)
@@ -181,6 +181,8 @@ CREATE TABLE SupIssue(
        priv BOOLEAN NOT NULL,
        status INTEGER NOT NULL,
        stamp TIMESTAMP NOT NULL,
+       pstamp TIMESTAMP,
+       cstamp TIMESTAMP,
        FOREIGN KEY (usr) REFERENCES WebUser(id) ON DELETE CASCADE,
        FOREIGN KEY (cat) REFERENCES SupCategory(id) ON DELETE CASCADE);