If anonymous account creation isn't allowed, then don't print
[cocanwiki.git] / scripts / lib / cocanwiki.ml
index ad625c1..1ce26cf 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: cocanwiki.ml,v 1.10 2006/03/28 16:24:08 rich Exp $
+ * $Id: cocanwiki.ml,v 1.11 2006/07/26 13:19:51 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
@@ -31,7 +31,8 @@ open Cocanwiki_strings
 type host_t = { hostname : string;
                canonical_hostname : string;
                edit_anon : bool;
-               view_anon : bool }
+               view_anon : bool;
+               create_account_anon : bool; }
 
 (* Permissions and restrictions.
  *
@@ -118,7 +119,8 @@ let register_script ?(restrict = []) ?(anonymous = true) run =
           (* Get the host ID, by comparing the Host: header with the hostnames
            * table in the database.
            *)
-          let hostid, hostname, canonical_hostname, edit_anon, view_anon =
+          let hostid, hostname, canonical_hostname, edit_anon, view_anon,
+            create_account_anon =
             let hostname =
               try Request.hostname r
               with Not_found ->
@@ -133,13 +135,16 @@ let register_script ?(restrict = []) ?(anonymous = true) run =
 
             let rows =
               PGSQL(dbh)
-                "select h.id, h.canonical_hostname, h.edit_anon, h.view_anon
+                "select h.id, h.canonical_hostname, h.edit_anon, h.view_anon,
+                         h.create_account_anon
                     from hostnames hn, hosts h
                    where hn.name = $hostname and hn.hostid = h.id" in
 
             match rows with
-            | [id, canonical_hostname, edit_anon, view_anon] ->
-                id, hostname, canonical_hostname, edit_anon, view_anon
+            | [id, canonical_hostname, edit_anon, view_anon,
+               create_account_anon] ->
+                id, hostname, canonical_hostname, edit_anon, view_anon,
+                create_account_anon
             | [] ->
               error ~back_button:true
                 ~title:"Unknown website" dbh (-1l) q
@@ -154,7 +159,8 @@ let register_script ?(restrict = []) ?(anonymous = true) run =
           let host = { hostname = hostname;
                        canonical_hostname = canonical_hostname;
                        edit_anon = edit_anon;
-                       view_anon = view_anon } in
+                       view_anon = view_anon;
+                       create_account_anon = create_account_anon; } in
 
           (* Look for the user's cookie, and determine from this the user
            * object.