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 \
# 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
OBJS := 00-TEMPLATE.cmo \
contact.cmo \
+ contact_show.cmo \
+ contacts.cmo \
create.cmo \
create_form.cmo \
delete_file.cmo \
--- /dev/null
+(* 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
--- /dev/null
+(* 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
--- /dev/null
+<!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>
+<html>
+<form method="post" action="/_contact">
+<input type="hidden" name="id" value="::id::"/>
+<table class="left_table">
+<tr> <th> Name: </th>
+ <td> <input name="Name" size="50" /> </td> </tr>
+<tr> <th> Tel.: </th>
+ <td> <input name="Phone" size="50" /> </td> </tr>
+<tr> <th> Notes: </th>
+ <td> <textarea name="Notes" rows="5" cols="60"></textarea> </td> </tr>
+<tr> <th></th>
+ <td> <input type="submit" value="Send form"/> </td> </tr>
+</table>
+</form>
+</html>
+</pre>
+
+</td>
+</tr>
+
+</table>
+
+<ul id="topmenu" class="menu">
+<li class="first"> <a href="/">Home page</a> </li>
+<li> <a href="/_sitemap">Sitemap</a> </li>
+<li> <a href="/_recent">Recent changes</a> </li>
+</ul>
+
+<ul id="bottommenu" class="menu">
+<li class="first"> <a href="/">Home 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 © ::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
--- /dev/null
+<!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 page</a> </li>
+<li> <a href="/_sitemap">Sitemap</a> </li>
+<li> <a href="/_recent">Recent changes</a> </li>
+</ul>
+
+<ul id="bottommenu" class="menu">
+<li class="first"> <a href="/">Home 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 © ::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