hostid integer NOT NULL,
logged_ip text,
redirect text,
- css text
+ css text,
+ logged_user integer
);
--
--- TOC entry 40 (OID 540831)
+-- TOC entry 41 (OID 540831)
-- Name: users_name_uq; Type: INDEX; Schema: public; Owner: rich
--
--
+-- TOC entry 40 (OID 540946)
+-- Name: users_id_uq; Type: INDEX; Schema: public; Owner: rich
+--
+
+CREATE UNIQUE INDEX users_id_uq ON users USING btree (hostid, id);
+
+
+--
-- TOC entry 29 (OID 536012)
-- Name: pages_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 41 (OID 540825)
+-- TOC entry 42 (OID 540825)
-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 44 (OID 536029)
+-- TOC entry 47 (OID 536029)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 46 (OID 536384)
+-- TOC entry 49 (OID 536384)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 45 (OID 536394)
+-- TOC entry 48 (OID 536394)
-- Name: hosts_hostname_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 42 (OID 536404)
+-- TOC entry 43 (OID 536404)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 47 (OID 536920)
+-- TOC entry 50 (OID 536920)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 48 (OID 537160)
+-- TOC entry 51 (OID 537160)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 49 (OID 537175)
+-- TOC entry 52 (OID 537175)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 43 (OID 539155)
+-- TOC entry 44 (OID 539155)
-- Name: pages_redirect_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 50 (OID 540827)
+-- TOC entry 53 (OID 540827)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--
--
--- TOC entry 51 (OID 540837)
+-- TOC entry 54 (OID 540837)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--
ADD CONSTRAINT "$1" FOREIGN KEY (userid) REFERENCES users(id);
+--
+-- TOC entry 45 (OID 540942)
+-- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: rich
+--
+
+ALTER TABLE ONLY pages
+ ADD CONSTRAINT "$2" FOREIGN KEY (logged_user) REFERENCES users(id);
+
+
+--
+-- TOC entry 46 (OID 540947)
+-- Name: pages_user_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
+--
+
+ALTER TABLE ONLY pages
+ ADD CONSTRAINT pages_user_cn FOREIGN KEY (hostid, logged_user) REFERENCES users(hostid, id);
+
+
SET SESSION AUTHORIZATION 'postgres';
--
--- /dev/null
+/* Stylesheet for COCANWIKI, derived from EWM.
+ * $Id: users.css,v 1.1 2004/09/08 10:42:20 rich Exp $
+ */
+
# Makefile for COCANWIKI.
-# $Id: Makefile,v 1.6 2004/09/07 17:16:46 rich Exp $
+# $Id: Makefile,v 1.7 2004/09/08 10:42:20 rich Exp $
include ../Makefile.config
upload_file.cmo \
upload_file_form.cmo \
upload_image.cmo \
- upload_image_form.cmo
+ upload_image_form.cmo \
+ users.cmo
ADMIN_OBJS := \
admin/admin.cmo \
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_date.ml,v 1.2 2004/09/07 14:58:34 rich Exp $
+ * $Id: cocanwiki_date.ml,v 1.3 2004/09/08 10:42:20 rich Exp $
*)
open Apache
| _ -> invalid_arg "short_month"
(* Generate a printable datestamp for pages. *)
-let printable_date (date, _) =
+let printable_date' date =
sprintf "%d %s %04d" date.Dbi.day (short_month date.Dbi.month) date.Dbi.year
+let printable_date (date, _) = printable_date' date
+
let printable_date_time (date, time) =
sprintf "%d %s %04d %02d:%02d" date.Dbi.day (short_month date.Dbi.month)
date.Dbi.year time.Dbi.hour time.Dbi.min
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: page.ml,v 1.5 2004/09/08 09:54:28 rich Exp $
+ * $Id: page.ml,v 1.6 2004/09/08 10:42:20 rich Exp $
*)
open Apache
| [ `Bool has_host_css ] -> has_host_css
| _ -> assert false in
- (* Can the user edit? *)
+ (* Can the user edit? Manage users? *)
let can_edit = can_edit edit_anon user in
+ let can_manage_users = can_manage_users user in
(* This code generates ordinary pages. *)
let make_page title description pageid last_modified_date has_page_css
t#conditional "has_page_css" has_page_css;
t#conditional "can_edit" can_edit;
+ t#conditional "can_manage_users" can_manage_users;
(* Pull out the sections in this page. *)
let sth = dbh#prepare_cached
--- /dev/null
+(* COCANWIKI scripts.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: users.ml,v 1.1 2004/09/08 10:42:20 rich Exp $
+ *)
+
+open Apache
+open Registry
+open Cgi
+open Printf
+
+open Cocanwiki
+open Cocanwiki_template
+open Cocanwiki_date
+
+let template = get_template "users.html"
+
+let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let sth =
+ dbh#prepare_cached
+ "select id, name, email, registration_date, can_edit, can_manage_users
+ from users where hostid = ? order by name" in
+ sth#execute [`Int hostid];
+
+ let table =
+ sth#map
+ (function
+ [`Int userid; `String name; (`Null | `String _) as email;
+ `Date registration_date;
+ `Bool can_edit; `Bool can_manage_users] ->
+ let email = match email with `Null -> "" | `String s -> s in
+ [ "userid", Template.VarString (string_of_int userid);
+ "name", Template.VarString name;
+ "email", Template.VarString email;
+ "registration_date",
+ Template.VarString (printable_date' registration_date);
+ "can_edit", Template.VarConditional can_edit;
+ "can_manage_users", Template.VarConditional can_manage_users ]
+ | _ -> assert false) in
+
+ template#table "users" table;
+
+ q#template template
+
+let () =
+ register_script ~restrict:[CanManageUsers] run
<li> <a href="/::page_html_tag::/editcss">Edit stylesheet for this page</a> | </li>
<li> <a href="/_bin/admin/admin.cmo">Wiki administration</a> | </li>
::end::
-<li> ::if(user_logged_in):: ::username_html:: <a href="/_logout">(logout)</a> ::else:: <a href="/_login">Create account or login</a> ::end:: </li>
+<li> ::if(user_logged_in):: ::username_html:: <a href="/_logout">(logout)</a> ::else:: <a href="/_login">Create account or log in</a> ::end:: | </li>
+::if(can_manage_users)::
+<li> <a href="/_bin/users.cmo">Manage users</a> </li>
+::end::
</ul>
<hr/>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<title>Users</title>
+<meta name="author" content="http://www.merjis.com/" />
+<link rel="stylesheet" href="/_css/standard.css" type="text/css" title="Standard"/>
+<link rel="stylesheet" href="/_css/users.css" type="text/css" title="Standard"/>
+</head><body>
+
+<h1>Users</h1>
+
+<ul class="menu">
+<li><a href="/_bin/create_user_form.cmo">Create a user account</a></li>
+</ul>
+
+<table id="users">
+<tr>
+<th rowspan="2"> Name </th>
+<th rowspan="2"> Email address </th>
+<th rowspan="2"> Registration </th>
+<th colspan="2"> Permissions </th>
+</tr>
+<tr>
+<th> Can edit </th>
+<th> Can manage users </th>
+</tr>
+
+::table(users)::
+<tr>
+<td> <a href="/_bin/edit_user_form.cmo" title="Modify details, permissions, set password, or delete this user"><strong>::name_html::</strong></a> </td>
+<td> ::email_html:: </td>
+<td> ::registration_date_html:: </td>
+<td> ::if(can_edit)::<img src="/_graphics/tick.png" width="10" height="10" alt="Can edit"/>::end:: </td>
+<td> ::if(can_manage_users)::<img src="/_graphics/tick.png" width="10" height="10" alt="Can manage users"/>::end:: </td>
+</tr>
+::end::
+
+</table>
+
+<ul id="topmenu" class="menu">
+<li> <a href="/">Home page</a> | </li>
+<li> <a href="/_sitemap">Sitemap</a> | </li>
+<li> <a href="/_recent">Recent changes</a> </li>
+</ul>
+
+<ul id="bottommenu" class="menu">
+<li> <a href="/">Home page</a> | </li>
+<li> <a href="/_sitemap">Sitemap</a> | </li>
+<li> <a href="/_recent">Recent changes</a> </li>
+</ul>
+
+<hr/>
+
+<ul id="footer" class="menu">
+<li> <a href="/copyright">Copyright © 2004</a> </li>
+</ul>
+
+</body>
+</html>
\ No newline at end of file