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