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