X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Fcontact.ml;h=b64bd56d04f9d9bd4b892addd687d4a4da2d9052;hb=bfa88724ee152ba00c2b2fca881dd78a6599820a;hp=4ec8e5e23cf9197a114bf101e9b79e33a050119a;hpb=d303f75eed3a09bbe2516d9a2a9a4aa9b862ceb3;p=cocanwiki.git diff --git a/scripts/contact.ml b/scripts/contact.ml index 4ec8e5e..b64bd56 100644 --- a/scripts/contact.ml +++ b/scripts/contact.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: contact.ml,v 1.9 2005/11/24 14:54:11 rich Exp $ + * $Id: contact.ml,v 1.10 2006/03/27 18:09:46 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ open Cocanwiki open Cocanwiki_template open Cocanwiki_ok -let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = +let run r (q : cgi) dbh hostid {hostname = hostname} user = let template = get_template dbh hostid "contact.txt" in let fail msg = @@ -47,24 +47,18 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = fail "The 'name' field is missing in that form." in (* Get the contacts / emails from the database. *) - let sth = dbh#prepare_cached "select id, subject from contacts - where hostid = ? and name = ?" in - sth#execute [`Int hostid; `String name]; + let rows = PGSQL(dbh) + "select id, subject from contacts + where hostid = $hostid and name = $name" in let id, subject = - try - (match sth#fetch1 () with - [ `Int id; `String subject ] -> id, subject - | _ -> assert false - ) - with Not_found -> fail "There is no such contact form in the database." in + match rows with + | [row] -> row + | [] -> fail "There is no such contact form in the database." + | _ -> assert false in - let sth = dbh#prepare_cached "select email from contact_emails - where contactid = ?" in - sth#execute [`Int id]; - - let emails = sth#map (function [`String email] -> email - | _ -> assert false) in + let emails = + PGSQL(dbh) "select email from contact_emails where contactid = $id" in if emails = [] then fail "There are no email addresses associated with that contact id."; @@ -118,7 +112,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = match user with Anonymous -> "anonymous" | User (userid, username, _, _) -> - sprintf "%s (%d)" username userid in + sprintf "%s (%ld)" username userid in template#set "ip" ip; template#set "ua" ua;