summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5fbc095)
"Create account or log in". Should reduce the amount of clueless
emails we get on the subject.
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
(* 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
*
* 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;
type host_t = { hostname : string;
canonical_hostname : string;
edit_anon : bool;
+ view_anon : bool;
+ create_account_anon : bool; }
(* Permissions and restrictions.
*
(* Permissions and restrictions.
*
(* Get the host ID, by comparing the Host: header with the hostnames
* table in the database.
*)
(* 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 hostname =
try Request.hostname r
with Not_found ->
- "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
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
| [] ->
error ~back_button:true
~title:"Unknown website" dbh (-1l) q
let host = { hostname = hostname;
canonical_hostname = canonical_hostname;
edit_anon = edit_anon;
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.
(* 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.
(* 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
*
* 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
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 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 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
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.
(* 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
*
* 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);
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
(* If logged in, we want to update the recently_visited table. *)
if pageid <> None then (
match user with
<ul id="editmenu" class="menu">
<ul id="editmenu" class="menu">
-<li class="first login_li"> ::if(user_logged_in):: ::username_html:: (<a href="/_userprefs">prefs</a>, <a href="/_logout">logout</a>) ::else:: <a href="/_login">Create account or log in</a> ::end:: </li>
+<li class="first login_li"> ::if(user_logged_in):: ::username_html:: (<a href="/_userprefs">prefs</a>, <a href="/_logout">logout</a>) ::else:: <a href="/_login">::if(create_account_anon)::Create account or log in::else::Site administration::end::</a> ::end:: </li>
::if(can_edit)::
<li class="edit_li"> <a href="/::page_html_tag::/edit"><strong>Edit this page</strong></a> </li>
::if(can_edit)::
<li class="edit_li"> <a href="/::page_html_tag::/edit"><strong>Edit this page</strong></a> </li>