Added styling to some pages which previously were "outside" the site
[cocanwiki.git] / scripts / delete_user_form.ml
index 382814a..8437488 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: delete_user_form.ml,v 1.2 2004/09/23 11:56:47 rich Exp $
+ * $Id: delete_user_form.ml,v 1.5 2006/03/27 18:09:46 rich Exp $
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,33 +28,33 @@ open Cocanwiki
 open Cocanwiki_template
 open Cocanwiki_ok
 
-let run r (q : cgi) (dbh : Dbi.connection) hostid _ self =
+let run r (q : cgi) dbh hostid _ self =
   let template = get_template dbh hostid "delete_user_form.html" in
 
-  let userid = int_of_string (q#param "userid") in
-  template#set "userid" (string_of_int userid);
+  let userid = Int32.of_string (q#param "userid") in
+  template#set "userid" (Int32.to_string userid);
 
   (* Can't delete self! *)
   let () =
     match self with
-      | User (id, _, _) when id = userid ->
+      | User (id, _, _, _) when id = userid ->
          error ~back_button:true ~title:"Delete own account"
-           q "You cannot delete your own user account.";
+           dbh hostid q "You cannot delete your own user account.";
          return ()
       | _ -> () in
 
   (* Get this user from the database. *)
-  let sth = dbh#prepare_cached "select name, email from users
-                                 where id = ? and hostid = ?" in
-  sth#execute [`Int userid; `Int hostid];
+  let rows =
+    PGSQL(dbh) "select name, email from users
+                 where id = $userid and hostid = $hostid" in
 
   let username, email =
-    match sth#fetch1 () with
-       [ `String username; `String email ] ->
-         username, email
-      | [ `String username; `Null ] ->
-         username, ""
-      | _ -> assert false in
+    match rows with
+    | [ username, Some email ] ->
+       username, email
+    | [ username, None ] ->
+       username, ""
+    | _ -> assert false in
 
   template#set "username" username;
   template#set "email" email;