Changes done on the Mac.
[cocanwiki.git] / scripts / mailing_list_view.ml
index 1df4b0f..f0cfc38 100644 (file)
@@ -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.
- * $Id: mailing_list_view.ml,v 1.1 2004/09/24 17:07:10 rich Exp $
+ * $Id: mailing_list_view.ml,v 1.4 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
@@ -28,7 +28,7 @@ open Cocanwiki
 open Cocanwiki_template
 open Cocanwiki_date
 
-let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+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
 
@@ -40,16 +40,19 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
     else "text/html", template in
 
   (* Get the mailing list. *)
-  let sth = dbh#prepare_cached "select email, entry_date from mailing_lists
-                                 where hostid = ? and pending is null
-                                 order by 1" in
-  sth#execute [`Int hostid];
-
-  let table = sth#map (function [`String email; `Date entry_date] ->
-                        let entry_date = printable_date' entry_date in
-                        [ "email", Template.VarString email;
-                          "entry_date", Template.VarString entry_date ]
-                        | _ -> assert false) in
+  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 =
+    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;