(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: create_contact.ml,v 1.1 2004/09/21 15:55:48 rich Exp $
+ * $Id: create_contact.ml,v 1.5 2005/11/24 14:54:11 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
if name = "" then (
error ~back_button:true ~title:"Name field missing"
- q "You must name your contact form.";
- raise CgiExit
+ dbh hostid q "You must name your contact form.";
+ return ()
);
if subject = "" then (
error ~back_button:true ~title:"Subject line missing"
- q "You must give a subject line, which appears on contact emails.";
- raise CgiExit
+ dbh hostid q
+ "You must give a subject line, which appears on contact emails.";
+ return ()
);
if emails = [] then (
error ~back_button:true ~title:"No email addresses"
- q ("There are no email addresses listed for this contact form. You " ^
- "must list at least one valid email address.");
- raise CgiExit
+ dbh hostid q
+ ("There are no email addresses listed for this contact form. You " ^
+ "must list at least one valid email address.");
+ return ()
);
(* Update the database. *)
values (?, ?, ?)" in
sth#execute [`Int hostid; `String name; `String subject];
- let contactid = sth#serial "contacts_id_seq" in
+ let contactid = Int64.to_int (sth#serial "contacts_id_seq") in
let sth = dbh#prepare_cached "insert into contact_emails (contactid, email)
values (?, ?)" in
let msg = sprintf "Contact form created. The contact id is %d. On the next page you will be given some same <html> code which you should copy and paste onto a web page to create a simple form, which can then be modified for your requirements." contactid in
- let buttons = [ { StdPages.label = " View contact form ";
- StdPages.link = "/_bin/contact_show.cmo";
- StdPages.method_ = None;
- StdPages.params = [ "id", string_of_int contactid ] } ] in
- ok ~title:"Contact form created" ~buttons q msg
+ let buttons = [ { Template.StdPages.label = " View contact form ";
+ Template.StdPages.link = "/_bin/contact_show.cmo";
+ Template.StdPages.method_ = None;
+ Template.StdPages.params =
+ [ "id", string_of_int contactid ] } ] in
+ ok ~title:"Contact form created" ~buttons dbh hostid q msg
let () =
register_script ~restrict:[CanManageContacts] run