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