+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: host_menu.ml,v 1.1 2004/09/22 11:41:03 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *)
+
+open Apache
+open Registry
+open Cgi
+open Printf
+
+open Cocanwiki
+open Cocanwiki_template
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+ let template = get_template dbh hostid "host_menu.html" in
+
+ (* Get lots of host-specific stuff from the database. *)
+ let sth =
+ dbh#prepare_cached
+ "select h.canonical_hostname, h.css is not null, h.edit_anon,
+ h.create_account_anon, h.theme_css is not null,
+ t.name, t.description, h.feedback_email
+ from hosts h left outer join themes t on h.theme_css = t.theme_css
+ where h.id = ?" in
+ sth#execute [`Int hostid];
+
+ let canonical_hostname, has_global_css, edit_anon, create_account_anon,
+ has_theme_css, theme_name, theme_description, has_feedback_email,
+ feedback_email =
+ match sth#fetch1 () with
+ [ `String canonical_hostname; `Bool has_global_css;
+ `Bool edit_anon; `Bool create_account_anon; `Bool has_theme_css;
+ (`String _ | `Null) as theme_name;
+ (`String _ | `Null) as theme_description;
+ (`String _ | `Null) as feedback_email ] ->
+ let theme_name =
+ match theme_name with `String s -> s | `Null -> "" in
+ let theme_description =
+ match theme_description with `String s -> s | `Null -> "" in
+ let feedback_email, has_feedback_email =
+ match feedback_email with
+ `String s -> s, true
+ | `Null -> "", false in
+ canonical_hostname, has_global_css, edit_anon, create_account_anon,
+ has_theme_css, theme_name, theme_description, has_feedback_email,
+ feedback_email
+ | _ -> assert false in
+
+ template#set "canonical_hostname" canonical_hostname;
+ template#conditional "has_global_css" has_global_css;
+ template#conditional "edit_anon" edit_anon;
+ template#conditional "create_account_anon" create_account_anon;
+ template#conditional "has_theme_css" has_theme_css;
+ template#set "theme_name" theme_name;
+ template#set "theme_description" theme_description;
+ template#conditional "has_feedback_email" has_feedback_email;
+ template#set "feedback_email" feedback_email;
+
+ q#template template
+
+let () =
+ register_script ~restrict:[CanManageSite] run