Simplified edit menu.
authorrich <rich>
Sat, 23 Oct 2004 09:36:10 +0000 (09:36 +0000)
committerrich <rich>
Sat, 23 Oct 2004 09:36:10 +0000 (09:36 +0000)
"Sitewide settings" menu now gets the other entries which used be on
the edit menu.

When creating new users, don't allow setting email address.

Fixed permissions problem with edit_host_css scripts.

html/_css/standard.css
scripts/create_user.ml
scripts/edit_host_css.ml
scripts/edit_host_css_form.ml
scripts/host_menu.ml
scripts/page.ml
templates/create_user_form.html
templates/host_menu.html
templates/page.html

index 77fe8ed..7f90b88 100644 (file)
@@ -1,5 +1,5 @@
 /* Stylesheet for COCANWIKI.
- * $Id: standard.css,v 1.21 2004/10/22 17:17:42 rich Exp $
+ * $Id: standard.css,v 1.22 2004/10/23 09:36:10 rich Exp $
  */
 
 /* Based on the basic stylesheet. */
@@ -197,7 +197,7 @@ li.maillist_li a {
 }
 
 li.recent_li a {
-  padding-left: 16px;
+  padding-left: 18px;
   background: url(/_graphics/recent.png) center left no-repeat;
 }
 
@@ -206,9 +206,9 @@ li.sitemap_li a {
   background: url(/_graphics/sitemap.png) center left no-repeat;
 }
 
-li.recent_li a {
-  padding-left: 18px;
-  background: url(/_graphics/recent.png) center left no-repeat;
+li.stylesheet_li a {
+  padding-left: 16px;
+  background: url(/_graphics/edit.png) center left no-repeat;
 }
 
 li.versions_li a {
index 2767434..b8b8e6c 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.4 2004/10/11 14:13:04 rich Exp $
+ * $Id: create_user.ml,v 1.5 2004/10/23 09:36:11 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
@@ -52,9 +52,6 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
   if String.length username > 32 || String.length password > 32 then
   *)
 
-  let email = trim (q#param "email") in
-  let email = if string_is_whitespace email then `Null else `String email in
-
   (* Not a duplicate? *)
   let sth = dbh#prepare_cached "select id from users
                                  where hostid = ? and name = ?" in
@@ -77,13 +74,13 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
   let force_password_change = q#param_true "force_password_change" in
 
   (* Create the user account. *)
-  let sth = dbh#prepare_cached "insert into users (name, password, email,
+  let sth = dbh#prepare_cached "insert into users (name, password,
                                   hostid, can_edit, can_manage_users,
                                   can_manage_contacts, can_manage_site,
                                   can_edit_global_css, can_import_mail,
                                   force_password_change)
-                                values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" in
-  sth#execute [`String username; `String password; email; `Int hostid;
+                                values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" in
+  sth#execute [`String username; `String password; `Int hostid;
               `Bool can_edit; `Bool can_manage_users;
               `Bool can_manage_contacts; `Bool can_manage_site;
               `Bool can_edit_global_css; `Bool can_import_mail;
index b1a0b5c..7d48632 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_host_css.ml,v 1.2 2004/10/04 15:19:56 rich Exp $
+ * $Id: edit_host_css.ml,v 1.3 2004/10/23 09:36:11 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
@@ -54,4 +54,4 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
        "Note: You must RELOAD the page to see changes to stylesheets.")
 
 let () =
-  register_script ~restrict:[CanEdit] run
+  register_script ~restrict:[CanEditGlobalCSS] run
index 3a51d28..1bef710 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_host_css_form.ml,v 1.2 2004/10/04 15:19:56 rich Exp $
+ * $Id: edit_host_css_form.ml,v 1.3 2004/10/23 09:36:11 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
@@ -44,4 +44,4 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
   q#template template
 
 let () =
-  register_script ~restrict:[CanEdit] run
+  register_script ~restrict:[CanEditGlobalCSS] run
index 4a03afa..7806efc 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: host_menu.ml,v 1.5 2004/10/10 16:14:43 rich Exp $
+ * $Id: host_menu.ml,v 1.6 2004/10/23 09:36:11 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
@@ -27,59 +27,71 @@ open Printf
 open Cocanwiki
 open Cocanwiki_template
 
-let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+let run r (q : cgi) (dbh : Dbi.connection) hostid host user =
   let template = get_template dbh hostid "host_menu.html" in
 
-  (* Get lots of host-specific stuff from the database. *)
-  let sth =
-    dbh#prepare_cached
-      "select h.canonical_hostname, h.css is not null, h.edit_anon,
-              h.create_account_anon, h.theme_css is not null,
-              t.name, t.description, h.feedback_email, h.mailing_list,
-              h.search_box, h.navigation, h.view_anon
-         from hosts h left outer join themes t on h.theme_css = t.theme_css
-        where h.id = ?" in
-  sth#execute [`Int hostid];
+  (* Get user's specific permissions. *)
+  let can_manage_users = can_manage_users host user in
+  let can_manage_contacts = can_manage_contacts host user in
+  let can_edit_global_css = can_edit_global_css host user in
+  let can_manage_site = can_manage_site host user in
+  template#conditional "can_manage_users" can_manage_users;
+  template#conditional "can_manage_contacts" can_manage_contacts;
+  template#conditional "can_edit_global_css" can_edit_global_css;
+  template#conditional "can_manage_site" can_manage_site;
 
-  let canonical_hostname, has_global_css, edit_anon, create_account_anon,
-      has_theme_css, theme_name, theme_description, has_feedback_email,
-      feedback_email, mailing_list, search_box, navigation, view_anon =
-    match sth#fetch1 () with
-       [ `String canonical_hostname; `Bool has_global_css;
-         `Bool edit_anon; `Bool create_account_anon; `Bool has_theme_css;
-         (`String _ | `Null) as theme_name;
-         (`String _ | `Null) as theme_description;
-         (`String _ | `Null) as feedback_email;
-         `Bool mailing_list; `Bool search_box; `Bool navigation;
-         `Bool view_anon ] ->
-         let theme_name =
-           match theme_name with `String s -> s | `Null -> "" in
-         let theme_description =
-           match theme_description with `String s -> s | `Null -> "" in
-         let feedback_email, has_feedback_email =
-           match feedback_email with
-               `String s -> s, true
-             | `Null -> "", false in
-         canonical_hostname, has_global_css, edit_anon, create_account_anon,
-         has_theme_css, theme_name, theme_description, has_feedback_email,
-         feedback_email, mailing_list, search_box, navigation, view_anon
-      | _ -> assert false in
+  if can_manage_site then (
+    (* Get lots of host-specific stuff from the database. *)
+    let sth =
+      dbh#prepare_cached
+       "select h.canonical_hostname, h.css is not null, h.edit_anon,
+                h.create_account_anon, h.theme_css is not null,
+                t.name, t.description, h.feedback_email, h.mailing_list,
+                h.search_box, h.navigation, h.view_anon
+           from hosts h left outer join themes t on h.theme_css = t.theme_css
+          where h.id = ?" in
+    sth#execute [`Int hostid];
 
-  template#set "canonical_hostname" canonical_hostname;
-  template#conditional "has_global_css" has_global_css;
-  template#conditional "edit_anon" edit_anon;
-  template#conditional "create_account_anon" create_account_anon;
-  template#conditional "has_theme_css" has_theme_css;
-  template#set "theme_name" theme_name;
-  template#set "theme_description" theme_description;
-  template#conditional "has_feedback_email" has_feedback_email;
-  template#set "feedback_email" feedback_email;
-  template#conditional "mailing_list" mailing_list;
-  template#conditional "search_box" search_box;
-  template#conditional "navigation" navigation;
-  template#conditional "view_anon" view_anon;
+    let canonical_hostname, has_global_css, edit_anon, create_account_anon,
+    has_theme_css, theme_name, theme_description, has_feedback_email,
+    feedback_email, mailing_list, search_box, navigation, view_anon =
+      match sth#fetch1 () with
+         [ `String canonical_hostname; `Bool has_global_css;
+           `Bool edit_anon; `Bool create_account_anon; `Bool has_theme_css;
+           (`String _ | `Null) as theme_name;
+           (`String _ | `Null) as theme_description;
+           (`String _ | `Null) as feedback_email;
+           `Bool mailing_list; `Bool search_box; `Bool navigation;
+           `Bool view_anon ] ->
+           let theme_name =
+             match theme_name with `String s -> s | `Null -> "" in
+           let theme_description =
+             match theme_description with `String s -> s | `Null -> "" in
+           let feedback_email, has_feedback_email =
+             match feedback_email with
+                 `String s -> s, true
+               | `Null -> "", false in
+           canonical_hostname, has_global_css, edit_anon, create_account_anon,
+           has_theme_css, theme_name, theme_description, has_feedback_email,
+           feedback_email, mailing_list, search_box, navigation, view_anon
+       | _ -> assert false in
+
+    template#set "canonical_hostname" canonical_hostname;
+    template#conditional "has_global_css" has_global_css;
+    template#conditional "edit_anon" edit_anon;
+    template#conditional "create_account_anon" create_account_anon;
+    template#conditional "has_theme_css" has_theme_css;
+    template#set "theme_name" theme_name;
+    template#set "theme_description" theme_description;
+    template#conditional "has_feedback_email" has_feedback_email;
+    template#set "feedback_email" feedback_email;
+    template#conditional "mailing_list" mailing_list;
+    template#conditional "search_box" search_box;
+    template#conditional "navigation" navigation;
+    template#conditional "view_anon" view_anon
+  );
 
   q#template template
 
 let () =
-  register_script ~restrict:[CanManageSite] run
+  register_script ~restrict:[CanEdit] run
index 3657919..091f213 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: page.ml,v 1.33 2004/10/17 19:43:19 rich Exp $
+ * $Id: page.ml,v 1.34 2004/10/23 09:36:11 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
@@ -76,12 +76,8 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid
          navigation
       | _ -> assert false in
 
-  (* Can the user edit?  Manage users?  etc. *)
+  (* Can the user edit? *)
   let can_edit = can_edit host user in
-  let can_manage_users = can_manage_users host user in
-  let can_manage_contacts = can_manage_contacts host user in
-  let can_manage_site = can_manage_site host user in
-  let can_edit_global_css = can_edit_global_css host user in
 
   (* Do we have a stats page set up? *)
   let has_stats = server_settings_stats_page dbh <> None in
@@ -202,11 +198,6 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid
     t#conditional "navigation" navigation;
 
     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;
-
     t#conditional "has_stats" has_stats;
 
     (* Pull out the sections in this page. *)
@@ -384,13 +375,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid
     t#set "search_terms" search_terms;
 
     t#conditional "has_host_css" has_host_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;
-
     t#conditional "has_stats" has_stats;
 
     q#template t
index bf9767e..1231dbf 100644 (file)
 </tr>
 
 <tr>
-<th> Email: </th>
-<td> <input name="email" value="" size="40"/> </td>
-</tr>
-<tr>
 <th> Permissions: </th>
 <td>
 
index a759fa0..faa2a63 100644 (file)
@@ -1,13 +1,38 @@
 <!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>Global settings</title>
+<title>Sitewide settings</title>
 <meta name="author" content="http://www.merjis.com/" />
 <link rel="stylesheet" href="::theme_css_html_tag::" type="text/css" title="Standard"/>
 <link rel="alternate stylesheet" href="/_css/easytoread.css" type="text/css" title="High contrast, big fonts"/>
 </head><body>
 
-<h1>Global settings</h1>
+<h1>Sitewide settings</h1>
+
+<ul>
+<li> <a href="/_bin/largest_pages.cmo">Largest pages</a> </li>
+<li> <a href="/_bin/dead_ends.cmo">Dead end pages</a> </li>
+<li> <a href="/_bin/broken_links.cmo">Broken links</a> </li>
+
+<li> <a href="/_bin/edit_sitemenu.cmo">Edit site menu</a> </li>
+
+::if(can_manage_users)::
+<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_edit_global_css)::
+<li> <a href="/_bin/edit_host_css_form.cmo">Edit global stylesheet</a> </li>
+::end::
+
+</ul>
+
+::if(can_manage_site)::
+
+<h2>Site management</h2>
 
 <table class="left_table">
 <tr>
 <tr>
 <th> Global stylesheet: </th>
 <td> ::if(has_global_css)::<a href="/_global.css">View global stylesheet</a>::else::No global stylesheet for this site.::end::<br/>
-<a href="/_bin/edit_host_css_form.cmo">Edit global stylesheet ...</a> </td>
+::if(can_edit_global_css)::
+<a href="/_bin/edit_host_css_form.cmo">Edit global stylesheet ...</a>
+::end::
+</td>
 </tr>
 <tr>
 <th> Allow anyone to see the site: </th>
@@ -68,6 +96,7 @@
 <ul>
 <li> <a href="/_bin/rebuild_links.cmo">Rebuild link structure</a>
 </ul>
+::end::
 
 ::include(footer.html)::
 </body>
index 03974ad..81fe534 100644 (file)
 </ul>
 
 <ul id="editmenu" class="menu">
-<li class="first login_li"> ::if(user_logged_in):: ::username_html:: <a href="/_logout">(logout)</a> ::else:: <a href="/_login">Create account or log in</a> ::end:: </li>
+
+<li class="first login_li"> ::if(user_logged_in):: ::username_html:: (<a href="/_prefs">prefs</a>, <a href="/_logout">logout</a>) ::else:: <a href="/_login">Create account or log in</a> ::end:: </li>
+
 ::if(can_edit)::
 <li class="edit_li"> <a href="/::page_html_tag::/edit"><strong>Edit this page</strong></a> </li>
 <li class="recent_li"> <a href="/_recent">Recent changes</a> </li>
 <li class="versions_li"> <a href="/::page_html_tag::/history">Versions of this page</a> </li>
-<li> <a href="/::page_html_tag::/editcss">Edit stylesheet for this page</a> </li>
-<li> <a href="/::page_html_tag::/edittitle">Edit title</a> </li>
 <li class="wlh_li"> <a href="/_bin/what_links_here.cmo?page=::page_url::">What links here?</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="/_bin/dead_ends.cmo">Dead end pages</a> </li>
-<li> <a href="/_bin/broken_links.cmo">Broken links</a> </li>
+<li class="stylesheet_li"> <a href="/::page_html_tag::/editcss">Edit stylesheet</a> </li>
+<li> <a href="/::page_html_tag::/edittitle">Rename page</a> </li>
 <li class="images_li"> <a href="/_images">Images</a> </li>
 <li class="files_li"> <a href="/_files">Files</a> </li>
 ::if(has_stats)::
 <li> <a href="/::page_html_tag::/stats">Stats</a> </li>
 ::end::
 ::end::
-::if(can_manage_users)::
-<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/host_menu.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::
+
 <li class="maillist_li"> <a href="/_bin/page_email_form.cmo?page=::page_url::">Send email if this page changes</a> </li>
+
 ::if(mailing_list)::
 <li class="maillist_li"> <a href="/_bin/mailing_list_form.cmo">Join our mailing list</a> </li>
 ::end::
+
+::if(can_edit)::
+<li> <a href="/_bin/host_menu.cmo">Sitewide settings</a> </li>
+::end::
+
 ::if(user_logged_in)::
-<li> <a href="/_bin/change_password_form.cmo">Change password</a> </li>
+<li> <a href="/_bin/change_password_form.cmo">Change password</a> (XXX TEMP XXX) </li>
 ::end::
+
 </ul>
 </div>