I wanted to suppress which books are listed in the block, using some complex rules best done in a module. Normal node access control was not enough for my use case, without getting very messy.
Added hook_show_book to ABB. It sends the id of the book to hook implementations. ABB shows a book if any module implementing the hook returns true for a given book. That makes it a white list, not a black list.
Here's the code, starting at 479. Sorry it's not in the right version control format. I don't know how to do that yet (but am learning!).
while ($book = db_fetch_object($result)) {
if (!in_array($book->bid, $books)) {
$allowed = module_invoke_all('show_book', $book->bid);
if ( in_array(TRUE, $allowed) ) {
$books[] = $book->bid;
}
}
}
Here's how a (silly) module might implement the hook:
function module_show_book($bid) {
return $bid < 10;
}
This might be useful for others, or maybe not. Good chance there's a better way to implement it (I'm no expert). E.g., should the hook name be something like hook_abb_show_book?
Kieran
http://coredogs.com
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | abb_new_hook.patch | 475 bytes | mathieso |
Comments
Comment #1
mathieso commentedOK, this might be the right patch file. But maybe I didn't make it correctly.