From 4d46d3eb69817c559335bd3620022fbbf3d8909a Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 25 Feb 2007 22:49:39 +0000 Subject: [PATCH] Save pending/closing time stamps for misc support issues --- issue.mlt | 6 ++++++ sec.mlt | 4 +++- support.sig | 3 ++- support.sml | 30 +++++++++++++++++++----------- tables.sql | 2 ++ 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/issue.mlt b/issue.mlt index 3a6cb1b..f8a7230 100644 --- a/issue.mlt +++ b/issue.mlt @@ -260,6 +260,12 @@ switch viewingIssue of | Support.PENDING => %>Pending<% | Support.CLOSED => %>Closed<% end %> +<% switch #pstamp issue of + SOME stamp => %> Changed to pending: <% stamp %> <% + end; + switch #cstamp issue of + SOME stamp => %> Closed: <% stamp %> <% + end %> <% if admin then %> diff --git a/sec.mlt b/sec.mlt index 7afdced..5c0f4af 100644 --- a/sec.mlt +++ b/sec.mlt @@ -251,6 +251,8 @@ if showNormal then %>

Request socket permissions change

+

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.

+
@@ -338,7 +340,7 @@ end%>

You can find a description of rule formats on our wiki. Enter here the rule you want, without the initial user portion.

-

Please note that your firewall rule will be useless if you don't first request the corresponding socket privileges at the top of this page.

+

Please note that your firewall rule will be useless 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.

diff --git a/support.sig b/support.sig index 9036954..c94edc1 100644 --- a/support.sig +++ b/support.sig @@ -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 } diff --git a/support.sml b/support.sml index b8e7a80..b82175b 100644 --- a/support.sml +++ b/support.sml @@ -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)), diff --git a/tables.sql b/tables.sql index e28196a..682f44d 100644 --- a/tables.sql +++ b/tables.sql @@ -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); -- 2.20.1