I found the use of book_manager module a little confusing from a user perspective, so I've just made a quick and dirty re-write of the module - attached as ogur_book (to avoid name conflict on my DEV machine). I don't have a CVS account, and really just finding my way in module development, so excuse any howling mistakes. I thought I'd quickly post as a concept, to see if anyone else agreed with the approach.
This re-write delegates access permissions to create, modify and add books through the OG User Roles module (version 4 (or higher) of OGUR is recommended). The OGUR module allows group administrators of organic groups to grant additional user roles to individual members of a certain group. Any such permissions only apply within the context of this group and not globally.
There are no configuration options required, or permissions settings. Although you should probably disable book_manager and the current DEV version of og_book before use. You will need to configure OG-specific roles (eg, group manager, group member etc), then in the Book module settings grant permissions to these roles to add content to books, create new books etc.
All this module does does is strip out books [in the Book Outline section when creating/editing a node] in hook_form_alter(), leaving only the following books available for selection:
- Books that belong to OGs that the current user is a member
- Books that are non-OG nodes where the current user is the node editor
(In this context, 'Book' means the node of the highest level parent within the book)
This is a really simple approach and quite a few assumptions have been made. I haven't done any serious testing, and not sure if any security loopholes have been exposed. I also disabled the personal book manager module, as this probably conflicts with it
If anyone else has a little more expertise, feel free to post any comments or reworks here. If dependency upon OGUR seems more acceptable, then perhaps this code could be re-rolled as og_book 6.x-2.0..?
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | ogur_book.zip | 8.32 KB | snorkers |
Comments
Comment #2
snorkers commentedSorry - the attachment seemed to disappear... try again
Comment #3
batourine_m commentedWe come to conclusion that we need og_book as well and after some code reviews - we settled on ogur_book as minimalistic approach for modifications :-)
I found that both - og_book and ogur_book do not work when book IS OG group - I meant not a member, but Book itself (nid) is OG (og.nid).
Comment #4
gerardf commentedI had to modify ogur_book.module to bypass an error when creating content that can not be part of a group
Fatal error: Unsupported operand types in /etc/drupal/6/sites/all/modules/ogur_book/ogur_book.module on line 49
That line is
$form['book']['bid']['#options'] = array($nid => '') + $form['book']['bid']['#options'];
The mods :
@@ -28,6 +28,14 @@ function ogur_book_form_alter(&$for
_book_add_form_elements($form, $node);
}
+ // if this node type cannot belong to a book, then get out
+ // otherwise it will crash further along
+ if( ! book_type_is_allowed($node->type) )
+ {
+ return;
+ }
+
+
//then need to hide relevant book from list - user is not editor nor og member of
global $user;
if (!user_access('administer nodes')){
This is the first time I touched a drupal module, so I don't know if it is a good idea but it works for me.