X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Fhistory.ml;h=556a6ada9ef901e265d3c232aabec73946aedb6a;hb=c22e34dd58cdc2a79b71dedd3c52ed705c9b8b51;hp=a5fdf5bea4d0c7662d5c32c81f3327cca4ce93bc;hpb=3062d573a7617339324c23cdd4755f8f04956b92;p=cocanwiki.git diff --git a/scripts/history.ml b/scripts/history.ml index a5fdf5b..556a6ad 100644 --- a/scripts/history.ml +++ b/scripts/history.ml @@ -1,7 +1,22 @@ -(* COCANWIKI scripts. +(* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: history.ml,v 1.1 2004/09/07 10:14:09 rich Exp $ + * $Id: history.ml,v 1.8 2004/09/21 13:01:16 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 @@ -10,55 +25,70 @@ open Cgi open Printf open Cocanwiki +open Cocanwiki_template +open Cocanwiki_date -open Merjisforwiki +let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = + let template = get_template dbh hostid "history.html" in -let template = get_template "history.html" - -let run r (q : cgi) (dbh : Dbi.connection) (hostid, _) _ = let page = q#param "page" in let page = if page = "" then "index" else page in let sth = dbh#prepare_cached - "select id, url, url_deleted, title, last_modified_date, logged_ip - from pages - where hostid = ? and (url = ? or url_deleted = ?) - order by last_modified_date desc" in + "select p.id, p.url, p.url_deleted, p.title, p.last_modified_date, + p.logged_ip, u.name + from pages p left outer join users u on p.logged_user = u.id + where p.hostid = ? and (p.url = ? or p.url_deleted = ?) + order by p.last_modified_date desc" in sth#execute [`Int hostid; `String page; `String page]; let table = sth#map (function | [`Int version; `String url; _; `String title; - `Timestamp last_modified_date; logged_ip ] -> + `Timestamp last_modified_date; logged_ip; logged_user ] -> let date = printable_date_time last_modified_date in let has_logged_ip, logged_ip = match logged_ip with `Null -> false, "" | `String ip -> true, ip | _ -> assert false in + let has_logged_user, logged_user = + match logged_user with + `Null -> false, "" + | `String name -> true, name + | _ -> assert false in [ "version", Template.VarString (string_of_int version); "url", Template.VarString url; "title", Template.VarString title; "last_modified_date", Template.VarString date; "has_logged_ip", Template.VarConditional has_logged_ip; "logged_ip", Template.VarString logged_ip; + "has_logged_user", Template.VarConditional has_logged_user; + "logged_user", Template.VarString logged_user; "is_live", Template.VarConditional true ] | [`Int version; `Null; `String url; `String title; - `Timestamp last_modified_date; logged_ip ] -> + `Timestamp last_modified_date; logged_ip; logged_user ] -> let date = printable_date_time last_modified_date in let has_logged_ip, logged_ip = match logged_ip with `Null -> false, "" | `String ip -> true, ip | _ -> assert false in + let has_logged_user, logged_user = + match logged_user with + `Null -> false, "" + | `String name -> true, name + | _ -> assert false in [ "version", Template.VarString (string_of_int version); "url", Template.VarString url; "title", Template.VarString title; "last_modified_date", Template.VarString date; "has_logged_ip", Template.VarConditional has_logged_ip; "logged_ip", Template.VarString logged_ip; + "has_logged_user", Template.VarConditional has_logged_user; + "logged_user", Template.VarString logged_user; "is_live", Template.VarConditional false ] | _ -> assert false) in @@ -67,4 +97,4 @@ let run r (q : cgi) (dbh : Dbi.connection) (hostid, _) _ = q#template template let () = - register_script run + register_script ~restrict:[CanEdit] run