(* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. * $Id: edit_user_form.ml,v 1.1 2004/09/08 12:45:38 rich Exp $ *) open Apache open Registry open Cgi open Printf open Cocanwiki open Cocanwiki_template open Cocanwiki_date let template = get_template "edit_user_form.html" let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ = let userid = int_of_string (q#param "userid") in let sth = dbh#prepare_cached "select u.name, u.email, u.registration_date, u.can_edit, u.can_manage_users, (select count(*) from pages where logged_user = u.id), (select count(*) from pages where logged_user = u.id and url_deleted is null) from users u where u.hostid = ? and u.id = ?" in sth#execute [`Int hostid; `Int userid]; let name, email, registration_date, can_edit, can_manage_users, nr_edits, nr_edits_live = match sth#fetch1 () with [`String name; (`Null | `String _) as email; `Date registration_date; `Bool can_edit; `Bool can_manage_users; `Int nr_edits; `Int nr_edits_live] -> name, email, registration_date, can_edit, can_manage_users, nr_edits, nr_edits_live | _ -> assert false in template#set "userid" (string_of_int userid); template#set "name" name; template#set "email" (match email with `Null -> "" | `String s -> s); template#set "registration_date" (printable_date' registration_date); template#conditional "can_edit" can_edit; template#conditional "can_manage_users" can_manage_users; template#set "nr_edits" (string_of_int nr_edits); template#set "nr_edits_live" (string_of_int nr_edits_live); q#template template let () = register_script ~restrict:[CanManageUsers] run