2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: delete_image.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
14 open Cocanwiki_emailnotify
18 let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname) _ =
19 let id = int_of_string (q#param "id") in
21 if q#param_true "yes" then (
22 (* Delete the image. *)
23 let sth = dbh#prepare_cached "update images
24 set name_deleted = name, name = null
25 where hostid = ? and id = ?
26 and name is not null" in
27 sth#execute [`Int hostid; `Int id];
32 let subject = "Image #" ^ string_of_int id ^ " has been deleted." in
34 "Page: http://" ^ hostname ^ "/_images?deleted=1" in
36 email_notify ~body ~subject dbh hostid;
38 let buttons = [ ok_button "/_images" ] in
39 ok ~title:"Image deleted" ~buttons
40 q "Image was deleted successfully."
42 q#redirect ("http://" ^ hostname ^ "/_images")