Background

A frequent topic on the forums seems to be that all books on a drupal site are handled with the same permissions. It happens that I too was developing a site where I wanted some books to be editable only by administrators and some others to a large set of registered users. So I decided to do something about it.

Note: That the Organic Groups module provides a way to have one book per each group. However, this patch provides a much simpler system, with only one new access permission.

What this patch does

  • One new database column: book.protected
  • For top level book nodes, there is a new checkbox in edit form: Protected book
  • If "Protected book" is set, normal users do not have edit, outline etc... operations on any pages in that book. Note that the setting is per book, it is set on the top-level book page.
  • One new access permission: 'edit protected books'
  • Users with this permission can edit and administer protected books just like they can normal books
  • As an independent feature, this exposes the weight setting for users with 'outline books' permission, I thought that sounds reasonable. (previously, weight could only be set with 'administer nodes' permission.

I believe this contains all the changes as needed and should work as described. I'll welcome any reports from testers or reviewers.

How to try this out

Sorry, but there is no patch yet. I need to put the sql stuff into update.inc before I can give you a patch. (The modified bits are however commented with //ADDED/CHANGED BY HINGO.)

To install:

The attached file is to replace your current book.module. In addition, you should add a column book.node to your drupal database. That's really all there is to it.

To use:

Give a trusted set of users the 'edit protected books' permission. They will also still need the other book related permissions for each specific operation. For instance, a user with 'edit protected books' and 'edit book pages' could edit pages in a protected book, but not create new pages in that book.

Users with 'edit protected books' permission can now make books protected by checking the box in the edit form of the top-level book page.

Feedback below or via email is welcome.

CommentFileSizeAuthor
book_3.module38.84 KBhingo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

magico’s picture

Version: 4.7.1 » x.y.z
Status: Needs review » Needs work

This could have something to do with the Separating each 'book' for richer features combined with a good Node Access Control.

Because features only go for the current HEAD, I'm marking this as "code needs work". Also we don't know what will happen with the "book separation".

hingo’s picture

Version: x.y.z » 4.7.x-dev

I see this has bee not-closed for a year now. I'm just letting any readers know that I do not have any intentions on working on this code at the moment. For my part I consider it a hack I needed to do for my own purposes.

At the same time it looks to me that the book.module never was rewritten as seemed to be the intention last year. As such, I'd propose to leave this patch in it's current state and not close it for as long as it really does solve a limitation in the current book module. Someone might find it useful, at least get inspired by it.

Gerhard Killesreiter’s picture

Status: Needs work » Closed (fixed)

no new features get added to Drupal 4.7, Author won't work on it, closing.