2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: edit_user_form.ml,v 1.1 2004/09/08 12:45:38 rich Exp $
13 open Cocanwiki_template
16 let template = get_template "edit_user_form.html"
18 let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
19 let userid = int_of_string (q#param "userid") in
23 "select u.name, u.email, u.registration_date,
24 u.can_edit, u.can_manage_users,
25 (select count(*) from pages where logged_user = u.id),
26 (select count(*) from pages
27 where logged_user = u.id and url_deleted is null)
28 from users u where u.hostid = ? and u.id = ?" in
29 sth#execute [`Int hostid; `Int userid];
31 let name, email, registration_date, can_edit, can_manage_users, nr_edits,
33 match sth#fetch1 () with
34 [`String name; (`Null | `String _) as email;
35 `Date registration_date;
36 `Bool can_edit; `Bool can_manage_users;
37 `Int nr_edits; `Int nr_edits_live] ->
38 name, email, registration_date, can_edit, can_manage_users,
39 nr_edits, nr_edits_live
40 | _ -> assert false in
42 template#set "userid" (string_of_int userid);
43 template#set "name" name;
44 template#set "email" (match email with `Null -> "" | `String s -> s);
45 template#set "registration_date" (printable_date' registration_date);
46 template#conditional "can_edit" can_edit;
47 template#conditional "can_manage_users" can_manage_users;
48 template#set "nr_edits" (string_of_int nr_edits);
49 template#set "nr_edits_live" (string_of_int nr_edits_live);
54 register_script ~restrict:[CanManageUsers] run