Added hosts.feedback_email field to the database.
Moved the edit menu around to make it slightly more logical.
css text,
edit_anon boolean DEFAULT true NOT NULL,
create_account_anon boolean DEFAULT true NOT NULL,
- theme_css text
+ theme_css text,
+ feedback_email text
);
registration_date date DEFAULT ('now'::text)::date NOT NULL,
can_edit boolean DEFAULT true NOT NULL,
can_manage_users boolean DEFAULT false NOT NULL,
- can_manage_contacts boolean DEFAULT false NOT NULL
+ can_manage_contacts boolean DEFAULT false NOT NULL,
+ can_manage_site boolean DEFAULT false NOT NULL,
+ can_edit_global_css boolean DEFAULT false NOT NULL
);
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki.ml,v 1.8 2004/09/20 15:34:36 rich Exp $
+ * $Id: cocanwiki.ml,v 1.9 2004/09/22 10:19:26 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
* register_script ~restrict:[CanEdit ; CanManageUsers] run
*)
type permissions_t = CanEdit | CanManageUsers | CanManageContacts
+ | CanManageSite | CanEditGlobalCSS
(* The "user object". *)
type user_t = Anonymous (* Not logged in. *)
let can_edit edit_anon = test_permission edit_anon CanEdit
let can_manage_users = test_permission false CanManageUsers
let can_manage_contacts = test_permission false CanManageContacts
+let can_manage_site = test_permission false CanManageSite
+let can_edit_global_css = test_permission false CanEditGlobalCSS
(* The "host object". *)
type host_t = { hostname : string;
let sth =
dbh#prepare_cached
"select u.id, u.name, u.can_edit, u.can_manage_users,
- u.can_manage_contacts
+ u.can_manage_contacts, u.can_manage_site,
+ u.can_edit_global_css
from usercookies uc, users u
where uc.cookie = ? and uc.userid = u.id and u.hostid = ?" in
sth#execute [`String cookie; `Int hostid];
(match sth#fetch1 () with
[ `Int userid; `String name;
`Bool can_edit; `Bool can_manage_users;
- `Bool can_manage_contacts ] ->
+ `Bool can_manage_contacts; `Bool can_manage_site;
+ `Bool can_edit_global_css ] ->
+ let perms = if can_edit then [ CanEdit ] else [] in
let perms =
- (if can_edit then [ CanEdit ] else []) @
- (if can_manage_users then [ CanManageUsers ] else []) @
- (if can_manage_contacts then [ CanManageContacts ] else [])
- in
+ if can_manage_users then CanManageUsers :: perms
+ else perms in
+ let perms =
+ if can_manage_contacts then CanManageContacts :: perms
+ else perms in
+ let perms =
+ if can_manage_site then CanManageSite :: perms
+ else perms in
+ let perms =
+ if can_edit_global_css then CanEditGlobalCSS :: perms
+ else perms in
User (userid, name, perms)
| _ -> assert false)
with
match restrict with
[] -> true (* empty list = no restrictions *)
| rs ->
- List.fold_left ((||)) false
+ List.fold_left (||) false
(List.map (fun r -> test_permission edit_anon r user) rs) in
if permitted then (
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: create_user.ml,v 1.1 2004/09/21 13:01:15 rich Exp $
+ * $Id: create_user.ml,v 1.2 2004/09/22 10:19:26 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
let can_edit = q#param_true "can_edit" in
let can_manage_users = q#param_true "can_manage_users" in
let can_manage_contacts = q#param_true "can_manage_contacts" in
+ let can_manage_site = q#param_true "can_manage_site" in
+ let can_edit_global_css = q#param_true "can_edit_global_css" in
(* Create the user account. *)
let sth = dbh#prepare_cached "insert into users (name, password, email,
hostid, can_edit, can_manage_users,
- can_manage_contacts)
- values (?, ?, ?, ?, ?, ?, ?)" in
+ can_manage_contacts, can_manage_site,
+ can_edit_global_css)
+ values (?, ?, ?, ?, ?, ?, ?, ?, ?)" in
sth#execute [`String username; `String password; email; `Int hostid;
`Bool can_edit; `Bool can_manage_users;
- `Bool can_manage_contacts];
+ `Bool can_manage_contacts; `Bool can_manage_site;
+ `Bool can_edit_global_css];
dbh#commit ();
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_user.ml,v 1.4 2004/09/17 15:24:54 rich Exp $
+ * $Id: edit_user.ml,v 1.5 2004/09/22 10:19:26 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
let can_edit = q#param_true "can_edit" in
let can_manage_users = q#param_true "can_manage_users" in
let can_manage_contacts = q#param_true "can_manage_contacts" in
+ let can_manage_site = q#param_true "can_manage_site" in
+ let can_edit_global_css = q#param_true "can_edit_global_css" in
(* Trying to remove manage users permission from self? *)
(match can_manage_users, self with
let sth = dbh#prepare_cached "update users set email = ?,
can_edit = ?, can_manage_users = ?,
- can_manage_contacts = ?
+ can_manage_contacts = ?,
+ can_manage_site = ?,
+ can_edit_global_css = ?
where hostid = ? and id = ?" in
sth#execute [email; `Bool can_edit; `Bool can_manage_users;
- `Bool can_manage_contacts;
+ `Bool can_manage_contacts; `Bool can_manage_site;
+ `Bool can_edit_global_css;
`Int hostid; `Int userid];
(* Finish up. *)
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_user_form.ml,v 1.5 2004/09/17 15:24:54 rich Exp $
+ * $Id: edit_user_form.ml,v 1.6 2004/09/22 10:19:26 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
dbh#prepare_cached
"select u.name, u.email, u.registration_date,
u.can_edit, u.can_manage_users, u.can_manage_contacts,
+ u.can_manage_site, u.can_edit_global_css,
(select count(*) from pages where logged_user = u.id),
(select count(*) from pages
where logged_user = u.id and url_deleted is null)
sth#execute [`Int hostid; `Int userid];
let name, email, registration_date, can_edit, can_manage_users,
- can_manage_contacts, nr_edits, nr_edits_live =
+ can_manage_contacts, can_manage_site, can_edit_global_css,
+ nr_edits, nr_edits_live =
match sth#fetch1 () with
[`String name; (`Null | `String _) as email;
`Date registration_date;
`Bool can_edit; `Bool can_manage_users; `Bool can_manage_contacts;
+ `Bool can_manage_site; `Bool can_edit_global_css;
`Int nr_edits; `Int nr_edits_live] ->
name, email, registration_date, can_edit, can_manage_users,
- can_manage_contacts, nr_edits, nr_edits_live
+ can_manage_contacts, can_manage_site, can_edit_global_css,
+ nr_edits, nr_edits_live
| _ -> assert false in
template#set "userid" (string_of_int userid);
template#conditional "can_edit" can_edit;
template#conditional "can_manage_users" can_manage_users;
template#conditional "can_manage_contacts" can_manage_contacts;
+ template#conditional "can_manage_site" can_manage_site;
+ template#conditional "can_edit_global_css" can_edit_global_css;
template#set "nr_edits" (string_of_int nr_edits);
template#set "nr_edits_live" (string_of_int nr_edits_live);
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: page.ml,v 1.16 2004/09/20 17:18:26 rich Exp $
+ * $Id: page.ml,v 1.17 2004/09/22 10:19:26 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
let can_edit = can_edit edit_anon user in
let can_manage_users = can_manage_users user in
let can_manage_contacts = can_manage_contacts user in
+ let can_manage_site = can_manage_site user in
+ let can_edit_global_css = can_edit_global_css user in
(* This code generates ordinary pages. *)
let make_page title description pageid last_modified_date has_page_css
t#conditional "can_edit" can_edit;
t#conditional "can_manage_users" can_manage_users;
t#conditional "can_manage_contacts" can_manage_contacts;
+ t#conditional "can_manage_site" can_manage_site;
+ t#conditional "can_edit_global_css" can_edit_global_css;
(* Pull out the sections in this page. *)
let sth = dbh#prepare_cached
t#conditional "can_edit" can_edit;
t#conditional "can_manage_users" can_manage_users;
t#conditional "can_manage_contacts" can_manage_contacts;
+ t#conditional "can_manage_site" can_manage_site;
+ t#conditional "can_edit_global_css" can_edit_global_css;
q#template t
in
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: users.ml,v 1.5 2004/09/17 15:24:54 rich Exp $
+ * $Id: users.ml,v 1.6 2004/09/22 10:19:26 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
let sth =
dbh#prepare_cached
"select id, name, email, registration_date, can_edit, can_manage_users,
- can_manage_contacts
+ can_manage_contacts, can_manage_site, can_edit_global_css
from users where hostid = ? order by name" in
sth#execute [`Int hostid];
[`Int userid; `String name; (`Null | `String _) as email;
`Date registration_date;
`Bool can_edit; `Bool can_manage_users;
- `Bool can_manage_contacts] ->
+ `Bool can_manage_contacts; `Bool can_manage_site;
+ `Bool can_edit_global_css] ->
let email = match email with `Null -> "" | `String s -> s in
[ "userid", Template.VarString (string_of_int userid);
"name", Template.VarString name;
"can_edit", Template.VarConditional can_edit;
"can_manage_users", Template.VarConditional can_manage_users;
"can_manage_contacts",
- Template.VarConditional can_manage_contacts ]
+ Template.VarConditional can_manage_contacts;
+ "can_manage_site", Template.VarConditional can_manage_site;
+ "can_edit_global_css",
+ Template.VarConditional can_edit_global_css; ]
| _ -> assert false) in
template#table "users" table;
<input id="can_manage_users" type="checkbox" name="can_manage_users" value="1"/><label for="can_manage_users">Manage users</label>
<br/>
<input id="can_manage_contacts" type="checkbox" name="can_manage_contacts" value="1"/><label for="can_manage_contacts">Manage contacts</label>
+<br/>
+<input id="can_manage_site" type="checkbox" name="can_manage_site" value="1"/><label for="can_manage_site">Manage site</label>
+<br/>
+<input id="can_edit_global_css" type="checkbox" name="can_edit_global_css" value="1"/><label for="can_edit_global_css">Edit global stylesheet</label>
</td>
</tr>
<tr>
<input id="can_manage_users" type="checkbox" name="can_manage_users" value="1" ::if(can_manage_users)::checked="checked"::end::/><label for="can_manage_users">Manage users</label>
<br/>
<input id="can_manage_contacts" type="checkbox" name="can_manage_contacts" value="1" ::if(can_manage_contacts)::checked="checked"::end::/><label for="can_manage_contacts">Manage contacts</label>
+<br/>
+<input id="can_manage_site" type="checkbox" name="can_manage_site" value="1" ::if(can_manage_site)::checked="checked"::end::/><label for="can_manage_site">Manage site</label>
+<br/>
+<input id="can_edit_global_css" type="checkbox" name="can_edit_global_css" value="1" ::if(can_edit_global_css)::checked="checked"::end::/><label for="can_edit_global_css">Edit global stylesheet</label>
</td>
</tr>
<tr>
<li> <a href="/::page_html_tag::/edit"><strong>Edit this page</strong></a> </li>
<li> <a href="/_recent">Recent changes</a> </li>
<li> <a href="/::page_html_tag::/history">Versions of this page</a> </li>
-<li> <a href="/_images">Images</a> </li>
-<li> <a href="/_files">Files</a> </li>
-<li> <a href="/_bin/largest_pages.cmo">Largest pages</a> </li>
<li> <a href="/::page_html_tag::/editcss">Edit stylesheet for this page</a> </li>
<li> <a href="/_bin/edit_sitemenu.cmo">Edit site menu</a> </li>
+<li> <a href="/_bin/largest_pages.cmo">Largest pages</a> </li>
+<li> <a href="/_images">Images</a> </li>
+<li> <a href="/_files">Files</a> </li>
::end::
::if(can_manage_users)::
-<li> <a href="/_users">Manage users</a> </li>
+<li> <a href="/_users">Users</a> </li>
::end::
::if(can_manage_contacts)::
<li> <a href="/_bin/contacts.cmo">Contact forms</a> </li>
::end::
+::if(can_manage_site)::
+<li> <a href="/_bin/sitemenu.cmo">Global settings</a> </li>
+::end::
+::if(can_edit_global_css)::
+<li> <a href="/_bin/edit_host_css_form.cmo">Edit global stylesheet</a> </li>
+::end::
::if(can_edit)::
<li> <a href="/_admin">Server administration</a> </li>
::end::
<th rowspan="2"> Username </th>
<th rowspan="2"> Email address </th>
<th rowspan="2"> Registration </th>
-<th colspan="3"> Permissions </th>
+<th colspan="5"> Permissions </th>
</tr>
<tr>
<th> Edit </th>
<th> Manage users </th>
<th> Manage contacts </th>
+<th> Manage site </th>
+<th> Edit global stylesheet </th>
</tr>
::table(users)::
<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>
<td> ::if(can_manage_contacts)::<img src="/_graphics/tick.png" width="10" height="10" alt="Can manage contacts"/>::end:: </td>
+<td> ::if(can_manage_site)::<img src="/_graphics/tick.png" width="10" height="10" alt="Can manage site"/>::end:: </td>
+<td> ::if(can_edit_global_css)::<img src="/_graphics/tick.png" width="10" height="10" alt="Can edit global stylesheet"/>::end:: </td>
</tr>
::end::
</dd>
+<dt> <strong>Manage site</strong> </dt>
+<dd>
+
+<p>
+If set, user may:
+</p>
+
+<ul>
+<li>control the global theme for the site</li>
+<li>set whether anonymous editing and signup are allowed (<strong>note:</strong> this will allow them to indirectly create extra user accounts)</li>
+<li>set email address for feedback</li>
+</ul>
+
+</dd>
+
+<dt> <strong>Edit global stylesheet</strong> </dt>
+<dd>
+
+<p>
+If set, user may edit the global stylesheet which controls
+the look and feel of the site across all pages.
+</p>
+
+</dd>
+
</dl>
<ul id="topmenu" class="menu">