The 'create host' code is now in a separate library so TNAAA can call it.
[cocanwiki.git] / scripts / page.ml
index a98e688..52debcc 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.24 2004/09/27 18:08:02 rich Exp $
+ * $Id: page.ml,v 1.25 2004/10/04 15:19:56 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
@@ -53,7 +53,10 @@ let split_qs_re = Pcre.regexp "\\?"
 
 let xhtml_re = Pcre.regexp "<.*?>|[^<>]+"
 
-let run r (q : cgi) (dbh : Dbi.connection) hostid {edit_anon=edit_anon} user =
+let run r (q : cgi) (dbh : Dbi.connection) hostid
+    ({ edit_anon = edit_anon;
+       view_anon = view_anon } as host)
+    user =
   let template_page = get_template dbh hostid "page.html" in
   let template_404  = get_template dbh hostid "page_404.html" in
 
@@ -74,11 +77,11 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {edit_anon=edit_anon} user =
       | _ -> assert false in
 
   (* Can the user edit?  Manage users?  etc. *)
-  let can_edit = can_edit edit_anon user in
-  let can_manage_users = can_manage_users user in
-  let can_manage_contacts = can_manage_contacts user in
-  let can_manage_site = can_manage_site user in
-  let can_edit_global_css = can_edit_global_css user in
+  let can_edit = can_edit host user in
+  let can_manage_users = can_manage_users host user in
+  let can_manage_contacts = can_manage_contacts host user in
+  let can_manage_site = can_manage_site host user in
+  let can_edit_global_css = can_edit_global_css host user in
 
   (* Do we have a stats page set up? *)
   let has_stats = server_settings_stats_page dbh <> None in
@@ -381,4 +384,4 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {edit_anon=edit_anon} user =
   loop page 0
 
 let () =
-  register_script run
+  register_script ~restrict:[CanView] run