2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: delete_file.ml,v 1.2 2004/09/07 13:40:10 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 file. *)
23 let sth = dbh#prepare_cached "update files
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 = "File #" ^ string_of_int id ^ " has been deleted." in
34 "Page: http://" ^ hostname ^ "/_files?deleted=1" in
36 email_notify ~body ~subject dbh hostid;
39 let buttons = [ ok_button "/_files" ] in
40 ok ~title:"File deleted" ~buttons
41 q "File was deleted successfully."
43 q#redirect ("http://" ^ hostname ^ "/_files")