1 structure Contact
:> CONTACT
=
8 val db
= C
.conn
"dbname='hcoop_hcoop'"
12 fun s
[v
] = C
.stringFromSql v
13 | s _
= raise Fail
"Bad allEmails row"
16 "SELECT v FROM Contact JOIN ContactKind ON knd = ContactKind.id AND ContactKind.name = 'Non-hcoop e-mail' ORDER BY v"
19 fun kindRow
[id
, name
, url
, urlPrefix
, urlPostfix
] =
20 {id
= C
.intFromSql id
,
21 name
= C
.stringFromSql name
,
22 url
= if C
.boolFromSql url
then
23 SOME (C
.stringFromSql urlPrefix
,
24 C
.stringFromSql urlPostfix
)
27 | kindRow _
= raise Fail
"Bad ContactKind row"
29 val kinds
= C
.map db kindRow
"SELECT id, name, url, urlPrefix, urlPostfix FROM ContactKind ORDER BY name"
31 fun doOne (kind
: {id
: int, name
: string, url
: (string * string) option
}) =
35 val name
= C
.stringFromSql name
36 val v
= C
.stringFromSql v
39 print (Web
.html name
);
42 NONE
=> print (Web
.html v
)
45 print (Web
.html (pre ^ v ^ post
));
51 | doOne _
= raise Fail
"Bad Contact row"
55 print
"</h2>\n<ol>\n";
57 C
.app db
doOne ("SELECT name, v FROM Contact JOIN WebUserActive ON usr = WebUserActive.id"
58 ^
" WHERE knd = " ^ C
.intToSql (#id kind
)
59 ^
" ORDER BY name, v");
64 print
"<html><head><title>HCoop Emergency Contact Information</title></head><body><h1>HCoop Emergency Contact Information</h1>\n";
66 print
"<h2><a href=\"mailto:";
67 print (String.concatWith
"," (allEmails ()));
68 print
"\">E-mail everyone (off-HCoop addresses)</a></h2>\n\n";
71 print
"</body></html>\n";
74 end handle C
.Sql s
=> (print ("SQL failure: " ^ s ^
"\n");