Support for users, roles, restrictions.
[cocanwiki.git] / scripts / delete_image_form.ml
1 (* COCANWIKI scripts.
2  * Written by Richard W.M. Jones <rich@merjis.com>.
3  * Copyright (C) 2004 Merjis Ltd.
4  * $Id: delete_image_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
5  *)
6
7 open Apache
8 open Registry
9 open Cgi
10 open Printf
11
12 open Merjisforwiki
13
14 open Cocanwiki
15 open Cocanwiki_template
16
17 let template = get_template "delete_image_form.html"
18
19 let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
20   let id = int_of_string (q#param "id") in
21
22   let sth = dbh#prepare_cached "select name, width, height, alt
23                                   from images
24                                  where hostid = ? and id = ?" in
25   sth#execute [`Int hostid; `Int id];
26
27   let name, width, height, alt =
28     match sth#fetch1 () with
29         [ `String name; `Int width; `Int height; `String alt] ->
30           name, width, height, alt
31       | _ -> assert false in
32
33   template#set "id" (string_of_int id);
34   template#set "name" name;
35   template#set "width" (string_of_int width);
36   template#set "height" (string_of_int height);
37   template#set "alt" alt;
38
39   q#template template
40
41 let () =
42   register_script run