Added the navigation box (see email).
[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.6 2004/10/10 16:14:43 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
30 let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ =
31   (* Cancel? *)
32   if q#param_true "cancel" then (
33     (* Request cancelled. *)
34     q#redirect ("http://" ^ hostname ^ "/_bin/host_menu.cmo");
35     return ()
36   );
37
38   (* Get parameters. *)
39   let edit_anon = q#param_true "edit_anon" in
40   let create_account_anon = q#param_true "create_account_anon" in
41   let theme_css = q#param "theme_css" in
42   let feedback_email = q#param "feedback_email" in
43   let mailing_list = q#param_true "mailing_list" in
44   let search_box = q#param_true "search_box" in
45   let navigation = q#param_true "navigation" in
46   let view_anon = q#param_true "view_anon" in
47
48   let theme_css = if theme_css = "" then `Null else `String theme_css in
49   let feedback_email =
50     if feedback_email = "" then `Null else `String feedback_email in
51
52   (* Update the database. *)
53   let sth = dbh#prepare_cached "update hosts set edit_anon = ?,
54                                   create_account_anon = ?, theme_css = ?,
55                                   feedback_email = ?, mailing_list = ?,
56                                   search_box = ?, navigation = ?, view_anon = ?
57                                 where id = ?" in
58   sth#execute [`Bool edit_anon; `Bool create_account_anon;
59                theme_css; feedback_email; `Bool mailing_list; `Bool search_box;
60                `Bool navigation; `Bool view_anon;
61                `Int hostid];
62
63   dbh#commit ();
64
65   (* Finish off. *)
66   ok ~title:"Global settings updated"
67     ~buttons:[ok_button "/_bin/host_menu.cmo"]
68     q "The global settings were updated."
69
70 let () =
71   register_script ~restrict:[CanManageSite] run