X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Fcocanwiki_server_settings.ml;h=f8a7898deffeab118f3c236fc6f4527f0e832068;hb=aec0096a00df1b58b7a057618ad9f3baab7c846c;hp=cb4212a2aebcef92524cf1e2fb8d973356c57227;hpb=03be670f1c2a13931f1b824f22cc9cebe4d61216;p=cocanwiki.git diff --git a/scripts/cocanwiki_server_settings.ml b/scripts/cocanwiki_server_settings.ml index cb4212a..f8a7898 100644 --- a/scripts/cocanwiki_server_settings.ml +++ b/scripts/cocanwiki_server_settings.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: cocanwiki_server_settings.ml,v 1.1 2004/09/23 15:16:21 rich Exp $ + * $Id: cocanwiki_server_settings.ml,v 1.3 2004/10/09 15:01:58 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 @@ -35,25 +35,34 @@ open Printf * allowed to access the database. We thus read them at the earliest * opportunity, in a request context, and cache the results. *) -let server_settings_version, server_settings_stats_page = +let server_settings_version, server_settings_stats_page, + server_settings_crash_email = + let default = 1, None, None in let settings = ref None in let get_settings (dbh : Dbi.connection) = - let sth = dbh#prepare "select version, stats_page from server_settings" in + let sth = dbh#prepare "select version, stats_page, crash_email + from server_settings" in sth#execute []; let s = - match sth#fetch1 () with - | [ `Int version; (`String _ | `Null) as stats_page ] -> - let stats_page = - match stats_page with `String s -> Some s | `Null -> None in - version, stats_page - | _ -> assert false in + try + (match sth#fetch1 () with + | [ `Int version; (`String _ | `Null) as stats_page; + (`String _ | `Null) as crash_email ] -> + let stats_page = + match stats_page with `String s -> Some s | `Null -> None in + let crash_email = + match crash_email with `String s -> Some s | `Null -> None in + version, stats_page, crash_email + | _ -> assert false) + with + Not_found -> default in sth#finish (); settings := Some s; s in let server_settings_version dbh = - let (version, _) = + let (version, _, _) = match !settings with None -> get_settings dbh | Some settings -> settings in @@ -61,11 +70,20 @@ let server_settings_version, server_settings_stats_page = in let server_settings_stats_page dbh = - let (_, stats_page) = + let (_, stats_page, _) = match !settings with None -> get_settings dbh | Some settings -> settings in stats_page in - server_settings_version, server_settings_stats_page + let server_settings_crash_email dbh = + let (_, _, crash_email) = + match !settings with + None -> get_settings dbh + | Some settings -> settings in + crash_email + in + + server_settings_version, server_settings_stats_page, + server_settings_crash_email