git.annexia.org
/
cocanwiki.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Probably about 1/2 way through now ...
[cocanwiki.git]
/
scripts
/
contact.ml
diff --git
a/scripts/contact.ml
b/scripts/contact.ml
index
4ec8e5e
..
b64bd56
100644
(file)
--- 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 <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* 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
*
* 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
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 =
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. *)
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 =
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.";
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, _, _) ->
match user with
Anonymous -> "anonymous"
| User (userid, username, _, _) ->
- sprintf "%s (%d)" username userid in
+ sprintf "%s (%
l
d)" username userid in
template#set "ip" ip;
template#set "ua" ua;
template#set "ip" ip;
template#set "ua" ua;