1 (* COCANWIKI - a wiki written in Objective CAML.
2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: edit_user_form.ml,v 1.11 2006/07/26 16:34:18 rich Exp $
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
28 open Cocanwiki_template
31 let run r (q : cgi) dbh hostid _ _ =
32 let template = get_template dbh hostid "edit_user_form.html" in
34 let userid = Int32.of_string (q#param "userid") in
38 "select u.name, u.email, u.registration_date,
39 u.can_edit, u.can_manage_users, u.can_manage_contacts,
40 u.can_manage_site, u.can_edit_global_css, u.can_import_mail,
42 (select count(*) from pages where logged_user = u.id)::int4,
43 (select count(*) from pages
44 where logged_user = u.id and url_deleted is null)::int4
45 from users u where u.hostid = $hostid and u.id = $userid" in
47 let name, email, registration_date, can_edit, can_manage_users,
48 can_manage_contacts, can_manage_site, can_edit_global_css,
49 can_import_mail, can_edit_macros, nr_edits, nr_edits_live =
51 | [name, email, registration_date,
52 can_edit, can_manage_users, can_manage_contacts,
53 can_manage_site, can_edit_global_css,
54 can_import_mail, can_edit_macros,
55 nr_edits, nr_edits_live] ->
56 name, email, registration_date, can_edit, can_manage_users,
57 can_manage_contacts, can_manage_site, can_edit_global_css,
58 can_import_mail, can_edit_macros, nr_edits, nr_edits_live
59 | _ -> assert false in
61 template#set "userid" (Int32.to_string userid);
62 template#set "name" name;
63 template#set "email" (match email with None -> "" | Some s -> s);
64 template#set "registration_date" (printable_date' registration_date);
65 template#conditional "can_edit" can_edit;
66 template#conditional "can_manage_users" can_manage_users;
67 template#conditional "can_manage_contacts" can_manage_contacts;
68 template#conditional "can_manage_site" can_manage_site;
69 template#conditional "can_edit_global_css" can_edit_global_css;
70 template#conditional "can_import_mail" can_import_mail;
71 template#conditional "can_edit_macros" can_edit_macros;
72 template#set "nr_edits" (Int32.to_string (Option.get nr_edits));
73 template#set "nr_edits_live" (Int32.to_string (Option.get nr_edits_live));
78 register_script ~restrict:[CanManageUsers] run