Posted by jgraham on December 3, 2010 at 10:11am
1 follower
| Project: | Book Manager |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | jgraham |
| Status: | postponed |
Issue Summary
Workflow/Visibility
Workflow and visibility settings should apply atomically to all pages or just the current page. This should behavior should be configurable on a global and allowing.
Review optionally enabling or disabling control on a book by book basis and/or governing by a permission.
Comments
#1
A more generic definition of this solution; we want X to happen on all nodes in a book if we edit *any* node in that same book. For this ticket X is "adjust workflow state", and/or "adjust visibility".
Proposal create a helper function that kicks off a batch update of nodes in the same book. This will have to happen *after* the initial node is saved and may require a semaphore per book to avoid race conditions as each node in the book is updated. More thought is required around this.
Proposed hook;
hook_book_manager_batch_update($node, &$nodes);
$node represents the node being changed and $nodes is a list of all the nodes in the same book. Each module defining hook_book_manager_batch_update can choose to act accordingly on each node in the book.
Perhaps a drupal_goto() after the node save that checks the book semaphore and notifies the user and/or auto-retries with an optional confirm batch update if the semaphore was initially locked. If the semaphore indicated unavailability.
#2
We will need a form_validate to block node edits for pages that are in books. If a batch operation is in progress for a book we want to fail validation on all node edits in that book until the semaphore is released. Then the standard drupal forms API should take over and notice the node may (or may not) have been updated by the batch update and force a node reload.
#3
Attached patch updates book nodes to maintain the same status (visibility) for every node in the book.
However, this exposes some really awful behavior with books and unpublished nodes. Since the core book module relies entirely on the menu system for determining what books are valid books if you un-publish a node in a book and subsequently edit any node that was in that book erratic behavior occurs as the book selection widgets omit all of the book pages as they are unpublished and are not valid book or page options. Also related all of the menus and links disappear too.
Reviewing the interaction between the menu system and book module is necessary to determine an appropriate solution. I think menu_tree_check_access() is the real issue as it does an explicit check for node.status = 1. Working around this likely has implications that need to be carefully considered.
This patch does provide a solid proof of concept to apply actions on all pages in a book.
#4
Core issue (http://drupal.org/node/218471 ) related to the erratic behavior described in comment 3
Also related:
http://drupal.org/node/460408
http://drupal.org/node/520786
#5
http://drupal.org/node/26552
A variation of the patch in 26552#17 is very close to what we need: http://drupal.org/files/issues/book_menu_module-D6.patch
Cross-referencing to D7 the problem persists even though a new permission 'view own unpublished content' should govern this. The issue is essentially the same in D7. It ultimately boils down to menu_tree_check_access() doing direct SQL rather than calling node_access() to check a user's access.
http://drupal.org/node/273595
#6
Setting to postponed. There are serious issues with settings nodes within books to 'unpublished'.