Display contacts. Updated deps.
authorrich <rich>
Fri, 17 Sep 2004 16:03:34 +0000 (16:03 +0000)
committerrich <rich>
Fri, 17 Sep 2004 16:03:34 +0000 (16:03 +0000)
scripts/.depend
scripts/Makefile
scripts/contact_show.ml [new file with mode: 0644]
scripts/contacts.ml [new file with mode: 0644]
templates/contact_show.html [new file with mode: 0644]
templates/contacts.html [new file with mode: 0644]

index 335073e..39ea508 100644 (file)
@@ -18,6 +18,10 @@ cocanwiki_template.cmx: cocanwiki_files.cmx cocanwiki_version.cmx \
     cocanwiki_template.cmi 
 contact.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmi 
 contact.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx 
+contact_show.cmo: cocanwiki.cmo cocanwiki_template.cmi 
+contact_show.cmx: cocanwiki.cmx cocanwiki_template.cmx 
+contacts.cmo: cocanwiki.cmo cocanwiki_template.cmi 
+contacts.cmx: cocanwiki.cmx cocanwiki_template.cmx 
 create.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo \
     wikilib.cmi 
 create.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx \
index ec9ebb5..2ac30f9 100644 (file)
@@ -1,5 +1,5 @@
 # Makefile for COCANWIKI.
-# $Id: Makefile,v 1.11 2004/09/17 12:35:38 rich Exp $
+# $Id: Makefile,v 1.12 2004/09/17 16:03:34 rich Exp $
 
 include ../Makefile.config
 
@@ -23,6 +23,8 @@ LIB_OBJS := \
 
 OBJS := 00-TEMPLATE.cmo \
        contact.cmo \
+       contact_show.cmo \
+       contacts.cmo \
        create.cmo \
        create_form.cmo \
        delete_file.cmo \
diff --git a/scripts/contact_show.ml b/scripts/contact_show.ml
new file mode 100644 (file)
index 0000000..d65c99c
--- /dev/null
@@ -0,0 +1,65 @@
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: contact_show.ml,v 1.1 2004/09/17 16:03:34 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_template
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+  let template = get_template dbh hostid "contact_show.html" in
+
+  let id = int_of_string (q#param "id") in
+  template#set "id" (string_of_int id);
+
+  (* Pull out all the details out of the database. *)
+  let sth = dbh#prepare_cached
+             "select name, subject
+                 from contacts where hostid = ? and id = ?" in
+  sth#execute [`Int hostid; `Int id];
+
+  let name, subject =
+    match sth#fetch1 () with
+       [ `String name; `String subject ] -> name, subject
+      | _ -> assert false in
+
+  template#set "name" name;
+  template#set "subject" subject;
+
+  (* Get the emails. *)
+  let sth = dbh#prepare_cached
+             "select email from contact_emails where contactid = ?
+                order by 1" in
+  sth#execute [`Int id];
+
+  let table = sth#map (function [`String email] ->
+                        [ "email", Template.VarString email ]
+                        | _ -> assert false) in
+
+  template#table "emails" table;
+
+  q#template template
+
+let () =
+  register_script ~restrict:[CanManageContacts] run
diff --git a/scripts/contacts.ml b/scripts/contacts.ml
new file mode 100644 (file)
index 0000000..22adc38
--- /dev/null
@@ -0,0 +1,58 @@
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: contacts.ml,v 1.1 2004/09/17 16:03:34 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_template
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+  let template = get_template dbh hostid "contacts.html" in
+
+  (* Pull out all the contacts from the database. *)
+  let sth = dbh#prepare_cached
+             "select c.id, c.name, c.subject,
+                      (select count(*) from contact_emails
+                        where contactid = c.id)
+                 from contacts c
+                where c.hostid = ?
+                order by c.name, c.id" in
+  sth#execute [`Int hostid];
+
+  let table =
+    sth#map
+      (function
+          [`Int id; `String name; `String subject; `Int count] ->
+            [ "id", Template.VarString (string_of_int id);
+              "name", Template.VarString name;
+              "subject", Template.VarString subject;
+              "count", Template.VarString (string_of_int count) ]
+        | _ -> assert false) in
+
+  template#table "contacts" table;
+
+  q#template template
+
+let () =
+  register_script ~restrict:[CanManageContacts] run
diff --git a/templates/contact_show.html b/templates/contact_show.html
new file mode 100644 (file)
index 0000000..3381b83
--- /dev/null
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<title>Contact form: ::name_html::</title>
+<meta name="robots" content="noindex,nofollow"/>
+<meta name="author" content="http://www.merjis.com/" />
+<link rel="stylesheet" href="::theme_css_html_tag::" type="text/css" title="Standard"/>
+</head><body>
+
+<h1>Contact form: ::name_html::</h1>
+
+<table class="left_table">
+<tr>
+<th> Contact ID: </th>
+<td> ::id_html:: </td>
+</tr>
+
+<tr>
+<th> Name: </th>
+<td> ::name_html:: </td>
+</tr>
+
+<tr>
+<th> Subject line for email: </th>
+<td> ::subject_html:: </td>
+</tr>
+
+<tr>
+<th> Emails: </th>
+<td>
+::table(emails)::
+::email_html:: <br/>
+::end::
+</td>
+</tr>
+
+<tr>
+<th> Actions: </th>
+<td>
+<ul class="menu">
+<li class="first"><a href="/_bin/edit_contact_form.cmo?id=::id::">Edit</a></li>
+<li><a href="/_bin/delete_contact_form.cmo?delete=::id::">Delete</a></li>
+</ul>
+</td>
+</tr>
+
+<tr>
+<th> HTML snippet: </th>
+<td>
+<p>
+Copy and paste this example snippet into
+your page to enable the form.
+</p>
+
+<pre>
+&lt;html&gt;
+&lt;form method="post" action="/_contact"&gt;
+&lt;input type="hidden" name="id" value="::id::"/&gt;
+&lt;table class="left_table"&gt;
+&lt;tr&gt; &lt;th&gt; Name: &lt;/th&gt;
+     &lt;td&gt; &lt;input name="Name" size="50" /&gt; &lt;/td&gt; &lt;/tr&gt;
+&lt;tr&gt; &lt;th&gt; Tel.: &lt;/th&gt;
+     &lt;td&gt; &lt;input name="Phone" size="50" /&gt; &lt;/td&gt; &lt;/tr&gt;
+&lt;tr&gt; &lt;th&gt; Notes: &lt;/th&gt;
+     &lt;td&gt; &lt;textarea name="Notes" rows="5" cols="60"&gt;&lt;/textarea&gt; &lt;/td&gt; &lt;/tr&gt;
+&lt;tr&gt; &lt;th&gt;&lt;/th&gt;
+     &lt;td&gt; &lt;input type="submit" value="Send form"/&gt; &lt;/td&gt; &lt;/tr&gt;
+&lt;/table&gt;
+&lt;/form&gt;
+&lt;/html&gt;
+</pre>
+
+</td>
+</tr>
+
+</table>
+
+<ul id="topmenu" class="menu">
+<li class="first"> <a href="/">Home&nbsp;page</a> </li>
+<li> <a href="/_sitemap">Sitemap</a> </li>
+<li> <a href="/_recent">Recent&nbsp;changes</a> </li>
+</ul>
+
+<ul id="bottommenu" class="menu">
+<li class="first"> <a href="/">Home&nbsp;page</a> </li>
+::table(sitemenu)::<li> <a href="/::url_html_tag::">::label_html::</a> </li>
+::end::
+<li> <a href="/_sitemap">Sitemap</a> </li>
+</ul>
+
+<hr/>
+
+<ul id="footer" class="menu">
+<li class="first"> <a href="/copyright">Copyright &copy; ::year::</a> </li>
+<li> Powered by <a href="http://sandbox.merjis.com/">::cocanwiki_package_html:: ::cocanwiki_version_html::</a> </li>
+</ul>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/templates/contacts.html b/templates/contacts.html
new file mode 100644 (file)
index 0000000..5aafbe2
--- /dev/null
@@ -0,0 +1,63 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<title>Contact forms</title>
+<meta name="robots" content="noindex,nofollow"/>
+<meta name="author" content="http://www.merjis.com/" />
+<link rel="stylesheet" href="::theme_css_html_tag::" type="text/css" title="Standard"/>
+</head><body>
+
+<h1>Contact forms</h1>
+
+<ul class="menu">
+<li class="first"><a href="/_bin/create_contact_form.cmo">Create a contact form</a></li>
+</ul>
+
+<form method="post" action="/_bin/delete_contact_form.cmo">
+<table class="top_table">
+<tr>
+<th></th>
+<th> Contact ID </th>
+<th> Name </th>
+<th> Subject line </th>
+<th> # addresses </th>
+</tr>
+::table(contacts)::
+<tr>
+<td> <input type="checkbox" name="delete" value="::id::"/> </td>
+<td class="number"> <a href="/_bin/contact_show.cmo?id=::id::">::id::</a> </td>
+<td> <a href="/_bin/contact_show.cmo?id=::id::">::name_html::</a> </td>
+<td> <a href="/_bin/contact_show.cmo?id=::id::">::subject_html::</a> </td>
+<td class="number"> <a href="/_bin/contact_show.cmo?id=::id::">::count_html::</a> </td>
+</tr>
+::end::
+<tr>
+<td colspan="5">
+<input type="submit" value="Delete contact form"/>
+</td>
+</tr>
+</table>
+</form>
+
+<ul id="topmenu" class="menu">
+<li class="first"> <a href="/">Home&nbsp;page</a> </li>
+<li> <a href="/_sitemap">Sitemap</a> </li>
+<li> <a href="/_recent">Recent&nbsp;changes</a> </li>
+</ul>
+
+<ul id="bottommenu" class="menu">
+<li class="first"> <a href="/">Home&nbsp;page</a> </li>
+::table(sitemenu)::<li> <a href="/::url_html_tag::">::label_html::</a> </li>
+::end::
+<li> <a href="/_sitemap">Sitemap</a> </li>
+</ul>
+
+<hr/>
+
+<ul id="footer" class="menu">
+<li class="first"> <a href="/copyright">Copyright &copy; ::year::</a> </li>
+<li> Powered by <a href="http://sandbox.merjis.com/">::cocanwiki_package_html:: ::cocanwiki_version_html::</a> </li>
+</ul>
+
+</body>
+</html>
\ No newline at end of file