If anonymous account creation isn't allowed, then don't print
authorrich <rich>
Wed, 26 Jul 2006 13:19:49 +0000 (13:19 +0000)
committerrich <rich>
Wed, 26 Jul 2006 13:19:49 +0000 (13:19 +0000)
"Create account or log in".  Should reduce the amount of clueless
emails we get on the subject.

scripts/lib/cocanwiki.ml
scripts/login_form.ml
scripts/page.ml
templates/page.html

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.
index 39fbb06..9d2ed94 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.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
@@ -28,7 +28,8 @@ open Cocanwiki
 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
@@ -43,12 +44,6 @@ let run r (q : cgi) dbh hostid _ _ =
   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
index 7001a08..d1e8b09 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.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
@@ -299,6 +299,11 @@ let run r (q : cgi) dbh hostid
           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
index 2f40a89..76c8d49 100644 (file)
@@ -47,7 +47,7 @@
 
 <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>