(* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. * $Id: mailing_list_confirm.ml,v 1.6 2006/03/28 13:20:00 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. *) open Apache open Registry open Cgi open Printf open Cocanwiki open Cocanwiki_ok let run r (q : cgi) dbh hostid _ _ = let pending = q#param "p" in (* Get the relevant fields from the database. *) let rows = PGSQL(dbh) "select email from mailing_lists where hostid = $hostid and pending = $pending" in let email = match rows with | [email] -> email | [] -> error ~close_button:true ~title:"Email already confirmed" dbh hostid q "It looks like that email address has already been confirmed."; return () | _ -> assert false in (* Update the database. *) PGSQL(dbh) "update mailing_lists set pending = null where hostid = $hostid and pending = $pending"; PGOCaml.commit dbh; (* Confirmed. *) let buttons = [ ok_button "/" ] in ok ~buttons ~title:"Confirmed" dbh hostid q ("Your email address has been confirmed. " ^ "You are now on our mailing list.") let () = register_script ~restrict:[CanView] run