2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: edit_emails_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
13 open Cocanwiki_template
15 let template = get_template "admin/edit_emails_form.html"
17 let run r (q : cgi) (dbh : Dbi.connection) _ _ =
18 let hostid = int_of_string (q#param "hostid") in
20 template#set "id" (string_of_int hostid);
22 let sth = dbh#prepare_cached
23 "select canonical_hostname from hosts where id = ?" in
24 sth#execute [`Int hostid];
26 let canonical_hostname = sth#fetch1string () in
27 template#set "canonical_hostname" canonical_hostname;
29 let sth = dbh#prepare_cached
30 "select email, name from email_notify where hostid = ?" in
31 sth#execute [`Int hostid];
33 let emails = sth#map (function
34 [`String email; `Null] ->
36 | [`String email; `String name] ->
37 sprintf "%s <%s>" name email
38 | _ -> assert false) in
40 template#set "emails" (String.concat "\n" emails);