Added a "name" field to the mailing list entries.
authorrich <rich>
Fri, 24 Sep 2004 17:11:57 +0000 (17:11 +0000)
committerrich <rich>
Fri, 24 Sep 2004 17:11:57 +0000 (17:11 +0000)
cocanwiki.sql
scripts/mailing_list_send.ml
scripts/mailing_list_view.ml
templates/mailing_list_form.html
templates/mailing_list_view.html
templates/mailing_list_view.txt

index 212e74e..859eb4b 100644 (file)
@@ -499,7 +499,8 @@ CREATE TABLE mailing_lists (
     email text NOT NULL,
     entry_date date DEFAULT ('now'::text)::date NOT NULL,
     pending text,
-    opt_out text NOT NULL
+    opt_out text NOT NULL,
+    name text NOT NULL
 );
 
 
index 6fcbfcc..6fd1a19 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_send.ml,v 1.2 2004/09/24 16:45:02 rich Exp $
+ * $Id: mailing_list_send.ml,v 1.3 2004/09/24 17:11: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
@@ -33,6 +33,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ =
   let template = get_template dbh hostid "mailing_list_send.txt" in
 
   let email = trim (q#param "email") in
+  let name = trim (q#param "name") in
 
   if email = "" then (
     error ~title:"No email address" ~back_button:true
@@ -72,9 +73,10 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ =
   let opt_out = random_sessionid () in
 
   (* Insert into the database. *)
-  let sth = dbh#prepare_cached "insert into mailing_lists (hostid, email,
-                                  pending, opt_out) values (?, ?, ?, ?)" in
-  sth#execute [`Int hostid; `String email; `String pending; `String opt_out];
+  let sth = dbh#prepare_cached "insert into mailing_lists (hostid, email, name,
+                                  pending, opt_out) values (?, ?, ?, ?, ?)" in
+  sth#execute [`Int hostid; `String email; `String name;
+              `String pending; `String opt_out];
 
   dbh#commit ();
 
index 1df4b0f..e8750e1 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.2 2004/09/24 17:11: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
@@ -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
+  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 [`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 table =
+    sth#map (function [`String email; `String 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
 
   template#table "emails" table;
 
index bda294c..96241a9 100644 (file)
@@ -20,6 +20,10 @@ Please fill in this form to join our mailing list.
 <td> <input name="email" value="" size="50" /> </td>
 </tr>
 <tr>
+<th> Name: </th>
+<td> <input name="name" value="" size="50" /> </td>
+</tr>
+<tr>
 <td></td>
 <td> <input type="submit" value="   Send   " /> </td>
 </tr>
index b29f4b0..0f08f13 100644 (file)
@@ -10,9 +10,9 @@
 <h1>View or download mailing list</h1>
 
 <table class="top_table">
-<tr><th> Email address </th> <th> Joining date </th></tr>
+<tr><th> Email address </th> <th> Name </th> <th> Joining date </th></tr>
 ::table(emails)::
-<tr><td> ::email_html:: </td> <td> ::entry_date_html:: </td> </tr>
+<tr><td> ::email_html:: </td> <td> ::name_html:: </td> <td> ::entry_date_html:: </td> </tr>
 ::end::
 </table>
 
index 3f6b4ea..54f1cc0 100644 (file)
@@ -1,3 +1,3 @@
 "Email address","Joining date"
-::table(emails)::"::email::","::entry_date::"
+::table(emails)::"::email::","::name::","::entry_date::"
 ::end::
\ No newline at end of file