X-Git-Url: https://git.hcoop.net/hcoop/zz_old/portal.git/blobdiff_plain/369e1577bf72be99dcbb142fe605e5b4e6548102..57215bc36b90e2395e31240faea44cb84f93ae39:/contact.sml diff --git a/contact.sml b/contact.sml index 345ab51..3c3698d 100644 --- a/contact.sml +++ b/contact.sml @@ -103,7 +103,7 @@ fun lookupContact id = let val c = getDb () in - (case C.oneOrNoRows c ($`SELECT id, usr, knd, v, priv Contact WHERE id = ^(C.intToSql id)`) of + (case C.oneOrNoRows c ($`SELECT id, usr, knd, v, priv FROM Contact WHERE id = ^(C.intToSql id)`) of NONE => raise Fail "Contact not found" | SOME r => mkContactRow r) end @@ -134,6 +134,18 @@ fun listUserContacts (usr, priv) = AND priv <= ^(privToSql priv) ORDER BY name, v`) +fun mkKindContactRow r = + case r of + name :: rest => (C.stringFromSql name, mkContactRow rest) + | _ => Init.rowError ("name/contact", r) + +fun listContactsByKind (knd, priv) = + C.map (getDb ()) mkKindContactRow ($`SELECT name, Contact.id, usr, knd, v, priv + FROM Contact JOIN WebUser ON WebUser.id = usr + WHERE knd = ^(C.intToSql knd) + AND priv <= ^(privToSql priv) + ORDER BY name`) + fun format (kind : kind, cont : contact) = case #makeUrl kind of SOME (pre, post) => String.concat ["", Web.html (#v cont), ""]