Same name and namespace in other branches
  1. 4.7.x modules/book.module \book_nodeapi()
  2. 5.x modules/book/book.module \book_nodeapi()
  3. 6.x modules/book/book.module \book_nodeapi()

Implementation of hook_nodeapi().

Appends book navigation to all nodes in the book.

File

modules/book.module, line 413
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 nid = %d', $node->nid));
        if ($book) {
          if ($node->moderate && user_access('administer nodes')) {
            drupal_set_message(t("This update/post awaits moderation and won't be accessible until approved."));
          }
          foreach ($book as $key => $value) {
            $node->{$key} = $value;
          }
          $node = theme('book_navigation', $node);
          if ($page) {
            menu_set_location($node->breadcrumb);
          }
        }
      }
      break;
  }
}