-(* COCANWIKI scripts.
+(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: recent.ml,v 1.6 2004/09/09 09:35:33 rich Exp $
+ * $Id: recent.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
let sth =
dbh#prepare_cached
- "select id, url, url_deleted, title, last_modified_date, logged_ip
- from pages
- where hostid = ?
- and last_modified_date >= current_timestamp - interval ?
- 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.last_modified_date >= current_timestamp - interval ?
+ order by p.last_modified_date desc" in
sth#execute [`Int hostid; `String max_age];
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