(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: mailing_list_view.ml,v 1.3 2006/03/27 18:09:46 rich Exp $
+ * $Id: mailing_list_view.ml,v 1.5 2006/12/06 09:46:57 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
open Cocanwiki_date
let run r (q : cgi) dbh hostid _ _ =
- let template = get_template dbh hostid "mailing_list_view.html" in
- let template_csv = get_template dbh hostid "mailing_list_view.txt" in
+ let template = get_template r dbh hostid "mailing_list_view.html" in
+ let template_csv = get_template r dbh hostid "mailing_list_view.txt" in
(* CSV format? *)
let csv = q#param_true "csv" in
else "text/html", template in
(* Get the mailing list. *)
- let sth = dbh#prepare_cached "select email, name, entry_date
- from mailing_lists
- where hostid = ? and pending is null
- order by 1" in
- sth#execute [Some hostid];
+ let rows = PGSQL(dbh) "select email, name, entry_date
+ from mailing_lists
+ where hostid = $hostid and pending is null
+ order by 1" in
let table =
- sth#map (function [Some email; Some name; `Date entry_date] ->
- let entry_date = printable_date' entry_date in
- [ "email", Template.VarString email;
- "name", Template.VarString name;
- "entry_date", Template.VarString entry_date ]
- | _ -> assert false) in
+ List.map (
+ fun (email, name, entry_date) ->
+ let entry_date = printable_date' entry_date in
+ [ "email", Template.VarString email;
+ "name", Template.VarString name;
+ "entry_date", Template.VarString entry_date ]
+ ) rows in
template#table "emails" table;