(* 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
type host_t = { hostname : string;
canonical_hostname : string;
edit_anon : bool;
- view_anon : bool }
+ view_anon : bool;
+ create_account_anon : bool; }
(* Permissions and restrictions.
*
(* 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 ->
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
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.
(* 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.7 2006/03/28 13:20:00 rich Exp $
+ * $Id: login_form.ml,v 1.8 2006/07/26 13:19:49 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
open Cocanwiki_template
open Cocanwiki_strings
-let run r (q : cgi) dbh hostid _ _ =
+let run r (q : cgi) dbh hostid
+ { create_account_anon = create_account_anon } _ =
let template = get_template dbh hostid "login_form.html" in
let redirect = try q#param "redirect" with Not_found -> "" in
let username = try q#param "username" with Not_found -> "" in
template#set "username" username;
- let create_account_anon =
- List.hd (
- PGSQL(dbh) "select create_account_anon from hosts
- where id = $hostid"
- ) in
-
template#conditional "create_account_anon" create_account_anon;
q#template template
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: page.ml,v 1.46 2006/07/26 13:11:25 rich Exp $
+ * $Id: page.ml,v 1.47 2006/07/26 13:19:49 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
t#conditional "user_logged_in" true;
t#set "username" username);
+ (* Can anonymous users create accounts? If not them we don't
+ * want to offer to create accounts for them.
+ *)
+ t#conditional "create_account_anon" host.create_account_anon;
+
(* If logged in, we want to update the recently_visited table. *)
if pageid <> None then (
match user with