function book_nodeapi in Drupal 4
Same name and namespace in other branches
- 5 modules/book/book.module \book_nodeapi()
- 6 modules/book/book.module \book_nodeapi()
Implementation of hook_nodeapi().
Appends book navigation to all nodes in the book.
File
- modules/
book.module, line 459 - Allows users to collaboratively author a book.
Code
function book_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {
case 'view':
if (!$teaser) {
$book = db_fetch_array(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid));
if ($book) {
if ($node->moderate && user_access('administer nodes')) {
drupal_set_message(t("The post has been submitted for moderation and won't be accessible until it has been approved."));
}
foreach ($book as $key => $value) {
$node->{$key} = $value;
}
$path = book_location($node);
// Construct the breadcrumb:
$node->breadcrumb = array();
// Overwrite the trail with a book trail.
foreach ($path as $level) {
$node->breadcrumb[] = array(
'path' => 'node/' . $level->nid,
'title' => $level->title,
);
}
$node->breadcrumb[] = array(
'path' => 'node/' . $node->nid,
);
$node->body .= theme('book_navigation', $node);
if ($page) {
menu_set_location($node->breadcrumb);
}
}
}
break;
case 'delete revision':
db_query('DELETE FROM {book} WHERE vid = %d', $node->vid);
break;
case 'delete':
db_query('DELETE FROM {book} WHERE nid = %d', $node->nid);
break;
}
}