X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Fdelete_user_form.ml;h=8437488c4a0dda1dbc00d02dace403e1cd15584c;hb=c7a57233daadec4f174176a474fc7b5018cdf986;hp=382814ad05a1d6576c245d8564b74efa47c6a267;hpb=6b0b6830a2e784eee99dcd1b1a3cb8b44e27c765;p=cocanwiki.git diff --git a/scripts/delete_user_form.ml b/scripts/delete_user_form.ml index 382814a..8437488 100644 --- a/scripts/delete_user_form.ml +++ b/scripts/delete_user_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * 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;