fun statusFromSql v = statusFromInt (C.intFromSql v)
fun statusToSql s = C.intToSql (statusToInt s)
-type app = { id : int, name : string, rname : string, email : string,
+type app = { id : int, name : string, rname : string, gname : string option, email : string,
forward : bool, uses : string, other : string,
- passwd : string, status : status, applied : C.timestamp,
+ passwd : string, status : status, applied : C.timestamp, ipaddr : string option,
confirmed : C.timestamp option, decided : C.timestamp option,
msg : string}
-fun mkAppRow [id, name, rname, email, forward, uses, other, passwd, status, applied, confirmed, decided, msg] =
+fun mkAppRow [id, name, rname, gname, email, forward, uses, other, passwd, status,
+ applied, ipaddr, confirmed, decided, msg] =
{ id = C.intFromSql id, name = C.stringFromSql name, rname = C.stringFromSql rname,
+ gname = (if C.isNull gname then NONE else SOME (C.stringFromSql gname)),
email = C.stringFromSql email, forward = C.boolFromSql forward,
uses = C.stringFromSql uses, other = C.stringFromSql other, passwd = C.stringFromSql passwd,
status = statusFromSql status, applied = C.timestampFromSql applied,
+ ipaddr = (if C.isNull ipaddr then NONE else SOME (C.stringFromSql ipaddr)),
confirmed = if C.isNull confirmed then NONE else SOME (C.timestampFromSql confirmed),
decided = if C.isNull decided then NONE else SOME (C.timestampFromSql decided),
msg = C.stringFromSql msg}
| mkAppRow r = rowError ("app", r)
fun lookupApp id =
- case C.oneOrNoRows (getDb ()) ($`SELECT id, name, rname, email, forward, uses, other, passwd, status, applied, confirmed, decided, msg
+ case C.oneOrNoRows (getDb ()) ($`SELECT id, name, rname, gname, email, forward, uses, other, passwd, status, applied, ipaddr, confirmed, decided, msg
FROM MemberApp
WHERE id = ^(C.intToSql id)`) of
SOME row => mkAppRow row
| NONE => raise Fail "Membership application not found"
fun listApps status =
- C.map (getDb ()) mkAppRow ($`SELECT id, name, rname, email, forward, uses, other, passwd, status, applied, confirmed, decided, msg
+ C.map (getDb ()) mkAppRow ($`SELECT id, name, rname, gname, email, forward, uses, other, passwd, status, applied, ipaddr, confirmed, decided, msg
FROM MemberApp
WHERE status = ^(statusToSql status)
ORDER BY applied`)
fun votes id = C.map (getDb ()) mkVoteRow ($`SELECT usr, name
FROM AppVote JOIN WebUser ON usr = id
- WHERE app = ^(C.intToSql id)
+ WHERE AppVote.app = ^(C.intToSql id)
ORDER BY name`)
fun vote (usr, app) = ignore (C.dml (getDb ()) ($`INSERT INTO AppVote (app, usr)
val mail = Mail.mopen ()
in
- Mail.mwrite (mail, "From: Hcoop Application System <join@hcoop.net>\nTo: ");
+ Mail.mwrite (mail, "From: Hcoop Application System <join");
+ Mail.mwrite (mail, emailSuffix);
+ Mail.mwrite (mail, ">\nTo: ");
Mail.mwrite (mail, #email entry);
Mail.mwrite (mail, "\nCc: ");
Mail.mwrite (mail, boardEmail);
val mail = Mail.mopen ()
in
- Mail.mwrite (mail, "From: Hcoop Application System <join@hcoop.net>\nTo: ");
+ Mail.mwrite (mail, "To: ");
Mail.mwrite (mail, #email entry);
- Mail.mwrite (mail, "\nCc: ");
- Mail.mwrite (mail, boardEmail);
- Mail.mwrite (mail, "\nSubject: Application approved\n\nYour application for membership has been approved! Welcome to hcoop!\n\n");
+ Mail.mwrite (mail, "\n");
+ Mail.mwrite (mail, Util.readFile "/home/hcoop/portal/welcome.txt");
Mail.mwrite (mail, msg);
OS.Process.isSuccess (Mail.mclose mail)
end
SET status = 2
WHERE id = ^(C.intToSql app)`))
-end
\ No newline at end of file
+fun readFile fname =
+ let
+ val inf = TextIO.openIn fname
+
+ fun readLines lines =
+ case TextIO.inputLine inf of
+ NONE => String.concat (List.rev lines)
+ | SOME line => readLines (line :: lines)
+ in
+ readLines []
+ before TextIO.closeIn inf
+ end
+
+fun readTosBody () = readFile "/home/hcoop/public_html/tos.body.html"
+fun readTosAgree () = readFile "/home/hcoop/public_html/tos.agree.html"
+fun readTosMinorAgree () = readFile "/home/hcoop/public_html/tos.agree.minor.html"
+
+end