1 (* COCANWIKI - a wiki written in Objective CAML.
2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: host_menu.ml,v 1.13 2006/12/06 09:46:57 rich Exp $
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
28 open Cocanwiki_template
30 let run r (q : cgi) dbh hostid host user =
31 let template = get_template r dbh hostid "host_menu.html" in
33 (* Get user's specific permissions. *)
34 let can_manage_users = can_manage_users host user in
35 let can_manage_contacts = can_manage_contacts host user in
36 let can_edit_global_css = can_edit_global_css host user in
37 let can_edit_macros = can_edit_macros host user in
38 let can_manage_site = can_manage_site host user in
39 template#conditional "can_manage_users" can_manage_users;
40 template#conditional "can_manage_contacts" can_manage_contacts;
41 template#conditional "can_edit_global_css" can_edit_global_css;
42 template#conditional "can_edit_macros" can_edit_macros;
43 template#conditional "can_manage_site" can_manage_site;
45 if can_manage_site then (
46 (* Get lots of host-specific stuff from the database. *)
48 PGSQL(dbh) "nullable-results"
49 "select h.canonical_hostname,
51 h.ie6_fixes_css is not null, h.ie7_fixes_css is not null,
53 h.create_account_anon, h.theme_css is not null,
54 t.name, t.description, h.feedback_email, h.mailing_list,
55 h.search_box, h.navigation, h.view_anon,
56 h.brand, coalesce (h.brand_tagline, ''),
57 coalesce (h.brand_description, ''),
58 h.ie_imagetoolbar_no, h.global_noodp
59 from hosts h left outer join themes t on h.theme_css = t.theme_css
60 where h.id = $hostid" in
62 let canonical_hostname, has_global_css,
63 has_ie6_fixes_css, has_ie7_fixes_css,
64 edit_anon, create_account_anon,
65 has_theme_css, theme_name, theme_description, has_feedback_email,
66 feedback_email, mailing_list, search_box, navigation, view_anon,
67 has_brand, brand, brand_tagline, brand_description,
68 ie_imagetoolbar_no, global_noodp =
70 [ Some canonical_hostname, Some has_global_css,
71 Some has_ie6_fixes_css, Some has_ie7_fixes_css,
72 Some edit_anon, Some create_account_anon, Some has_theme_css,
73 theme_name, theme_description,
75 Some mailing_list, Some search_box, Some navigation, Some view_anon,
76 brand, brand_tagline, brand_description, Some ie_imagetoolbar_no,
77 Some global_noodp ] ->
79 match theme_name with Some s -> s | None -> "" in
80 let theme_description =
81 match theme_description with Some s -> s | None -> "" in
82 let feedback_email, has_feedback_email =
83 match feedback_email with
85 | None -> "", false in
86 let brand, has_brand =
89 | None -> "", false in
91 match brand_tagline with None -> "" | Some s -> s in
92 let brand_description =
93 match brand_description with None -> "" | Some s -> s in
94 canonical_hostname, has_global_css,
95 has_ie6_fixes_css, has_ie7_fixes_css,
96 edit_anon, create_account_anon,
97 has_theme_css, theme_name, theme_description, has_feedback_email,
98 feedback_email, mailing_list, search_box, navigation, view_anon,
99 has_brand, brand, brand_tagline, brand_description,
100 ie_imagetoolbar_no, global_noodp
101 | _ -> assert false in
103 template#set "canonical_hostname" canonical_hostname;
104 template#conditional "has_global_css" has_global_css;
105 template#conditional "has_ie6_fixes_css" has_ie6_fixes_css;
106 template#conditional "has_ie7_fixes_css" has_ie7_fixes_css;
107 template#conditional "edit_anon" edit_anon;
108 template#conditional "create_account_anon" create_account_anon;
109 template#conditional "has_theme_css" has_theme_css;
110 template#set "theme_name" theme_name;
111 template#set "theme_description" theme_description;
112 template#conditional "has_feedback_email" has_feedback_email;
113 template#set "feedback_email" feedback_email;
114 template#conditional "mailing_list" mailing_list;
115 template#conditional "search_box" search_box;
116 template#conditional "ie_imagetoolbar_no" ie_imagetoolbar_no;
117 template#conditional "global_noodp" global_noodp;
118 template#conditional "navigation" navigation;
119 template#conditional "view_anon" view_anon;
120 template#conditional "has_brand" has_brand;
121 template#set "brand" brand;
122 template#set "brand_tagline" brand_tagline;
123 template#set "brand_description" brand_description;
129 register_script ~restrict:[CanEdit] run