Changes done on the Mac.
[cocanwiki.git] / scripts / login_form.ml
index dfef268..39fbb06 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: login_form.ml,v 1.4 2004/09/09 12:21:22 rich Exp $
+ * $Id: login_form.ml,v 1.7 2006/03/28 13:20:00 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,7 +28,7 @@ open Cocanwiki
 open Cocanwiki_template
 open Cocanwiki_strings
 
-let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+let run r (q : cgi) dbh hostid _ _ =
   let template = get_template dbh hostid "login_form.html" in
 
   let redirect = try q#param "redirect" with Not_found -> "" in
@@ -40,14 +40,14 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
     template#set "redirect" redirect
   );
 
-  let sth = dbh#prepare_cached "select create_account_anon from hosts
-                                 where id = ?" in
-  sth#execute [`Int hostid];
+  let username = try q#param "username" with Not_found -> "" in
+  template#set "username" username;
 
   let create_account_anon =
-    match sth#fetch1 () with
-       [ `Bool b ] -> b
-      | _ -> assert false in
+    List.hd (
+      PGSQL(dbh) "select create_account_anon from hosts
+                   where id = $hostid"
+    ) in
 
   template#conditional "create_account_anon" create_account_anon;