(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_host_settings.ml,v 1.9 2005/11/24 14:54:11 rich Exp $
+ * $Id: edit_host_settings.ml,v 1.11 2006/07/26 13:12:10 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
open Cocanwiki_ok
open Cocanwiki_strings
-let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ =
+let run r (q : cgi) dbh hostid { hostname = hostname } _ =
(* Cancel? *)
- if q#param_true "cancel" then (
+ 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 brand_description = trim (q#param "brand_description") in
let pagebug = trim (q#param "pagebug") in
- let theme_css = if theme_css = "" then `Null else `String theme_css in
+ let theme_css = if theme_css = "" then None else Some theme_css in
let feedback_email =
- if feedback_email = "" then `Null else `String feedback_email in
- let brand = if brand = "" then `Null else `String brand in
+ 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 brand_tagline = "" then `Null else `String brand_tagline in
+ if string_is_whitespace brand_tagline then None else Some brand_tagline in
let brand_description =
- if brand_description = "" then `Null else `String brand_description in
+ if string_is_whitespace brand_description then
+ None else Some brand_description in
let pagebug =
- if pagebug = "" then `Null else `String pagebug in
+ if string_is_whitespace pagebug then None else Some pagebug in
(* Update the database. *)
- let sth = dbh#prepare_cached "update hosts set edit_anon = ?,
- create_account_anon = ?, theme_css = ?,
- feedback_email = ?, mailing_list = ?,
- search_box = ?, navigation = ?,
- view_anon = ?,
- brand = ?, brand_tagline = ?,
- brand_description = ?,
- pagebug = ?
- where id = ?" in
- sth#execute [`Bool edit_anon; `Bool create_account_anon;
- theme_css; feedback_email; `Bool mailing_list; `Bool search_box;
- `Bool navigation; `Bool view_anon;
- brand; brand_tagline; brand_description;
- pagebug;
- `Int hostid];
+ 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";
- dbh#commit ();
+ PGOCaml.commit dbh;
(* Finish off. *)
ok ~title:"Global settings updated"