Added styling to some pages which previously were "outside" the site
[cocanwiki.git] / scripts / edit_host_settings.ml
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: edit_host_settings.ml,v 1.11 2006/07/26 13:12:10 rich Exp $
5  *
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.
10  *
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.
15  *
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.
20  *)
21
22 open Apache
23 open Registry
24 open Cgi
25 open Printf
26
27 open Cocanwiki
28 open Cocanwiki_ok
29 open Cocanwiki_strings
30
31 let run r (q : cgi) dbh hostid { hostname = hostname } _ =
32   (* Cancel? *)
33   if q#param_true "cancel" then
34     (* Request cancelled. *)
35     q#redirect ("http://" ^ hostname ^ "/_bin/host_menu.cmo");
36
37   (* Get parameters. *)
38   let edit_anon = q#param_true "edit_anon" in
39   let create_account_anon = q#param_true "create_account_anon" in
40   let theme_css = q#param "theme_css" in
41   let feedback_email = trim (q#param "feedback_email") in
42   let mailing_list = q#param_true "mailing_list" in
43   let search_box = q#param_true "search_box" in
44   let navigation = q#param_true "navigation" in
45   let view_anon = q#param_true "view_anon" in
46   let brand = trim (q#param "brand") in
47   let brand_tagline = trim (q#param "brand_tagline") in
48   let brand_description = trim (q#param "brand_description") in
49   let pagebug = trim (q#param "pagebug") in
50
51   let theme_css = if theme_css = "" then None else Some theme_css in
52   let feedback_email =
53     if string_is_whitespace feedback_email then
54       None else Some feedback_email in
55   let brand = if string_is_whitespace brand then None else Some brand in
56   let brand_tagline =
57     if string_is_whitespace brand_tagline then None else Some brand_tagline in
58   let brand_description =
59     if string_is_whitespace brand_description then
60       None else Some brand_description in
61   let pagebug =
62     if string_is_whitespace pagebug then None else Some pagebug in
63
64   (* Update the database. *)
65   PGSQL(dbh)
66     "update hosts set edit_anon = $edit_anon,
67        create_account_anon = $create_account_anon, theme_css = $?theme_css,
68        feedback_email = $?feedback_email, mailing_list = $mailing_list,
69        search_box = $search_box, navigation = $navigation,
70        view_anon = $view_anon,
71        brand = $?brand, brand_tagline = $?brand_tagline,
72        brand_description = $?brand_description,
73        pagebug = $?pagebug
74      where id = $hostid";
75
76   PGOCaml.commit dbh;
77
78   (* Finish off. *)
79   ok ~title:"Global settings updated"
80     ~buttons:[ok_button "/_bin/host_menu.cmo"]
81     dbh hostid q "The global settings were updated."
82
83 let () =
84   register_script ~restrict:[CanManageSite] run