From f33343df3525e01f05ecf80628cd46b6e5841001 Mon Sep 17 00:00:00 2001 From: rich Date: Fri, 24 Sep 2004 17:11:57 +0000 Subject: [PATCH] Added a "name" field to the mailing list entries. --- cocanwiki.sql | 3 ++- scripts/mailing_list_send.ml | 10 ++++++---- scripts/mailing_list_view.ml | 17 ++++++++++------- templates/mailing_list_form.html | 4 ++++ templates/mailing_list_view.html | 4 ++-- templates/mailing_list_view.txt | 2 +- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/cocanwiki.sql b/cocanwiki.sql index 212e74e..859eb4b 100644 --- a/cocanwiki.sql +++ b/cocanwiki.sql @@ -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 ); diff --git a/scripts/mailing_list_send.ml b/scripts/mailing_list_send.ml index 6fcbfcc..6fd1a19 100644 --- a/scripts/mailing_list_send.ml +++ b/scripts/mailing_list_send.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * 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 (); diff --git a/scripts/mailing_list_view.ml b/scripts/mailing_list_view.ml index 1df4b0f..e8750e1 100644 --- a/scripts/mailing_list_view.ml +++ b/scripts/mailing_list_view.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * 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; diff --git a/templates/mailing_list_form.html b/templates/mailing_list_form.html index bda294c..96241a9 100644 --- a/templates/mailing_list_form.html +++ b/templates/mailing_list_form.html @@ -20,6 +20,10 @@ Please fill in this form to join our mailing list. + Name: + + + diff --git a/templates/mailing_list_view.html b/templates/mailing_list_view.html index b29f4b0..0f08f13 100644 --- a/templates/mailing_list_view.html +++ b/templates/mailing_list_view.html @@ -10,9 +10,9 @@

View or download mailing list

- + ::table(emails):: - + ::end::
Email address Joining date
Email address Name Joining date
::email_html:: ::entry_date_html::
::email_html:: ::name_html:: ::entry_date_html::
diff --git a/templates/mailing_list_view.txt b/templates/mailing_list_view.txt index 3f6b4ea..54f1cc0 100644 --- a/templates/mailing_list_view.txt +++ b/templates/mailing_list_view.txt @@ -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 -- 1.8.3.1