Control of the can_edit_macros user permission.
authorrich <rich>
Wed, 26 Jul 2006 16:34:18 +0000 (16:34 +0000)
committerrich <rich>
Wed, 26 Jul 2006 16:34:18 +0000 (16:34 +0000)
scripts/create_user.ml
scripts/edit_user.ml
scripts/edit_user_form.ml
scripts/users.ml
templates/create_user_form.html
templates/edit_user_form.html
templates/users.html

index e8e136e..8cad0de 100644 (file)
@@ -1,7 +1,7 @@
 (* 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.7 2006/03/27 18:09:46 rich Exp $
+ * $Id: create_user.ml,v 1.8 2006/07/26 16:34:18 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
@@ -72,6 +72,7 @@ let run r (q : cgi) dbh hostid _ _ =
   let can_manage_site = q#param_true "can_manage_site" in
   let can_edit_global_css = q#param_true "can_edit_global_css" in
   let can_import_mail = q#param_true "can_import_mail" in
+  let can_edit_macros = q#param_true "can_edit_macros" in
   let force_password_change = q#param_true "force_password_change" in
 
   (* Create the user account. *)
@@ -80,10 +81,12 @@ let run r (q : cgi) dbh hostid _ _ =
                         hostid, can_edit, can_manage_users,
                         can_manage_contacts, can_manage_site,
                         can_edit_global_css, can_import_mail,
+                        can_edit_macros,
                         force_password_change)
      values ($username, $password, $hostid, $can_edit, $can_manage_users,
              $can_manage_contacts, $can_manage_site,
              $can_edit_global_css, $can_import_mail,
+             $can_edit_macros,
              $force_password_change)";
 
   PGOCaml.commit dbh;
index bfbd191..12eea7f 100644 (file)
@@ -1,7 +1,7 @@
 (* 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.12 2006/03/27 19:10:29 rich Exp $
+ * $Id: edit_user.ml,v 1.13 2006/07/26 16:34:18 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
@@ -73,6 +73,7 @@ let run r (q : cgi) dbh hostid _ self =
   let can_manage_site = q#param_true "can_manage_site" in
   let can_edit_global_css = q#param_true "can_edit_global_css" in
   let can_import_mail = q#param_true "can_import_mail" in
+  let can_edit_macros = q#param_true "can_edit_macros" in
 
   (* Trying to remove manage users permission from self? *)
   (match can_manage_users, self with
@@ -91,7 +92,8 @@ let run r (q : cgi) dbh hostid _ self =
        can_manage_contacts = $can_manage_contacts,
        can_manage_site = $can_manage_site,
        can_edit_global_css = $can_edit_global_css,
-       can_import_mail = $can_import_mail
+       can_import_mail = $can_import_mail,
+       can_edit_macros = $can_edit_macros
      where hostid = $hostid and id = $userid";
 
   (* Finish up. *)
index 76caf6a..f9695a5 100644 (file)
@@ -1,7 +1,7 @@
 (* 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.10 2006/03/27 19:10:29 rich Exp $
+ * $Id: edit_user_form.ml,v 1.11 2006/07/26 16:34:18 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
@@ -38,6 +38,7 @@ let run r (q : cgi) dbh hostid _ _ =
       "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, u.can_import_mail,
+              u.can_edit_macros,
               (select count(*) from pages where logged_user = u.id)::int4,
               (select count(*) from pages
                 where logged_user = u.id and url_deleted is null)::int4
@@ -45,16 +46,16 @@ let run r (q : cgi) dbh hostid _ _ =
 
   let name, email, registration_date, can_edit, can_manage_users,
       can_manage_contacts, can_manage_site, can_edit_global_css,
-      can_import_mail, nr_edits, nr_edits_live =
+      can_import_mail, can_edit_macros, nr_edits, nr_edits_live =
     match rows with
     | [name, email, registration_date,
        can_edit, can_manage_users, can_manage_contacts,
        can_manage_site, can_edit_global_css,
-       can_import_mail,
+       can_import_mail, can_edit_macros,
        nr_edits, nr_edits_live] ->
        name, email, registration_date, can_edit, can_manage_users,
        can_manage_contacts, can_manage_site, can_edit_global_css,
-       can_import_mail, nr_edits, nr_edits_live
+       can_import_mail, can_edit_macros, nr_edits, nr_edits_live
     | _ -> assert false in
 
   template#set "userid" (Int32.to_string userid);
@@ -67,6 +68,7 @@ let run r (q : cgi) dbh hostid _ _ =
   template#conditional "can_manage_site" can_manage_site;
   template#conditional "can_edit_global_css" can_edit_global_css;
   template#conditional "can_import_mail" can_import_mail;
+  template#conditional "can_edit_macros" can_edit_macros;
   template#set "nr_edits" (Int32.to_string (Option.get nr_edits));
   template#set "nr_edits_live" (Int32.to_string (Option.get nr_edits_live));
 
index 8a3fcec..651cbde 100644 (file)
@@ -1,7 +1,7 @@
 (* 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.10 2006/03/28 16:24:08 rich Exp $
+ * $Id: users.ml,v 1.11 2006/07/26 16:34:18 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
@@ -36,14 +36,14 @@ let run r (q : cgi) dbh hostid _ _ =
       "select id, name, email, registration_date, invite is not null,
               can_edit, can_manage_users,
               can_manage_contacts, can_manage_site, can_edit_global_css,
-              can_import_mail
+              can_import_mail, can_edit_macros
          from users where hostid = $hostid order by name" in
 
   let table =
     List.map
       (fun (userid, name, email, registration_date, invite_pending,
            can_edit, can_manage_users, can_manage_contacts, can_manage_site,
-           can_edit_global_css, can_import_mail) ->
+           can_edit_global_css, can_import_mail, can_edit_macros) ->
         let email = match email with None -> "" | Some s -> s in
         let invite_pending = Option.get invite_pending in
         [ "userid", Template.VarString (Int32.to_string userid);
@@ -61,7 +61,9 @@ let run r (q : cgi) dbh hostid _ _ =
           "can_edit_global_css",
           Template.VarConditional can_edit_global_css;
           "can_import_mail",
-          Template.VarConditional can_import_mail;]
+          Template.VarConditional can_import_mail;
+          "can_edit_macros",
+          Template.VarConditional can_edit_macros;]
       ) rows in
 
   template#table "users" table;
index f11e82a..97e93dd 100644 (file)
@@ -47,6 +47,8 @@
 <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>
 <br/>
 <input id="can_import_mail" type="checkbox" name="can_import_mail" value="1"/><label for="can_import_mail">Import mail</label>
+<br/>
+<input id="can_edit_macros" type="checkbox" name="can_edit_macros" value="1"/><label for="can_edit_macros">Edit macros</label>
 </td>
 </tr>
 <tr>
index dd82092..4156150 100644 (file)
@@ -42,6 +42,8 @@
 <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>
 <br/>
 <input id="can_import_mail" type="checkbox" name="can_import_mail" value="1" ::if(can_import_mail)::checked="checked"::end::/><label for="can_import_mail">Import mail</label>
+<br/>
+<input id="can_edit_macros" type="checkbox" name="can_edit_macros" value="1" ::if(can_edit_macros)::checked="checked"::end::/><label for="can_edit_macros">Edit macros</label>
 </td>
 </tr>
 <tr>
index 6d50aea..cf19b46 100644 (file)
@@ -28,6 +28,7 @@
 <th> Manage site </th>
 <th> Edit global stylesheet </th>
 <th> Import mail </th>
+<th> Edit macros </th>
 </tr>
 
 ::table(users)::
@@ -45,6 +46,7 @@
 <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>
 <td> ::if(can_import_mail)::<img src="/_graphics/tick.png" width="10" height="10" alt="Can import mail"/>::end:: </td>
+<td> ::if(can_edit_macros)::<img src="/_graphics/tick.png" width="10" height="10" alt="Can edit macros"/>::end:: </td>
 </tr>
 ::end::
 </table>
@@ -142,6 +144,16 @@ If set, user may import e-mail.
 
 </dd>
 
+<dt> <strong>Edit global stylesheet</strong> </dt>
+<dd>
+
+<p>
+If set, user may edit the <code>{{macros}}</code> which
+can affect many pages.
+</p>
+
+</dd>
+
 </dl>
 
 ::include(footer.html)::