(* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. * $Id: edit_host_settings.ml,v 1.10 2006/03/27 18:09:46 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_ok open Cocanwiki_strings let run r (q : cgi) dbh hostid { hostname = hostname } _ = (* Cancel? *) if q#param_true "cancel" then ( (* Request cancelled. *) q#redirect ("http://" ^ hostname ^ "/_bin/host_menu.cmo"); return () ); (* Get parameters. *) let edit_anon = q#param_true "edit_anon" in let create_account_anon = q#param_true "create_account_anon" in let theme_css = q#param "theme_css" in let feedback_email = trim (q#param "feedback_email") in let mailing_list = q#param_true "mailing_list" in let search_box = q#param_true "search_box" in let navigation = q#param_true "navigation" in let view_anon = q#param_true "view_anon" in let brand = trim (q#param "brand") in let brand_tagline = trim (q#param "brand_tagline") in let brand_description = trim (q#param "brand_description") in let pagebug = trim (q#param "pagebug") in let theme_css = if theme_css = "" then None else Some theme_css in let feedback_email = if string_is_whitespace feedback_email then None else Some feedback_email in let brand = if string_is_whitespace brand then None else Some brand in let brand_tagline = if string_is_whitespace brand_tagline then None else Some brand_tagline in let brand_description = if string_is_whitespace brand_description then None else Some brand_description in let pagebug = if string_is_whitespace pagebug then None else Some pagebug in (* Update the database. *) PGSQL(dbh) "update hosts set edit_anon = $edit_anon, create_account_anon = $create_account_anon, theme_css = $?theme_css, feedback_email = $?feedback_email, mailing_list = $mailing_list, search_box = $search_box, navigation = $navigation, view_anon = $view_anon, brand = $?brand, brand_tagline = $?brand_tagline, brand_description = $?brand_description, pagebug = $?pagebug where id = $hostid"; PGOCaml.commit dbh; (* Finish off. *) ok ~title:"Global settings updated" ~buttons:[ok_button "/_bin/host_menu.cmo"] dbh hostid q "The global settings were updated." let () = register_script ~restrict:[CanManageSite] run