COCANWIKI is now ~95% UTF-8 safe.
[cocanwiki.git] / scripts / page_email_form.ml
index 53c51ae..f361135 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: page_email_form.ml,v 1.1 2004/09/24 15:53:57 rich Exp $
+ * $Id: page_email_form.ml,v 1.4 2006/03/28 16:24:07 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
@@ -27,21 +27,20 @@ open Printf
 open Cocanwiki
 open Cocanwiki_template
 
-let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+let run r (q : cgi) dbh hostid _ _ =
   let template = get_template dbh hostid "page_email_form.html" in
 
   let page = q#param "page" in
   template#set "page" page;
 
   (* Get the page title. *)
-  let sth = dbh#prepare_cached "select title from pages
-                                 where hostid = ? and url = ?" in
-  sth#execute [`Int hostid; `String page];
-
-  let title = sth#fetch1string () in
+  let title = List.hd (
+    PGSQL(dbh) "select title from pages
+                 where hostid = $hostid and url = $page"
+  ) in
   template#set "title" title;
 
   q#template template
 
 let () =
-  register_script run
+  register_script ~restrict:[CanView] run