You are here

function course_book_node_view in Course 7.2

Same name and namespace in other branches
  1. 7 modules/course_book/course_book.module \course_book_node_view()

Implements hook_node_view().

File

modules/course_book/course_book.module, line 58

Code

function course_book_node_view($node, $view_mode = 'full') {
  if (node_is_page($node)) {
    global $user;
    $search = !empty($node->book['bid']) ? $node->book['bid'] : $node->nid;
    if ($courseObject = course_get_course_object('course_book', 'book', $search)) {
      $options = array();

      // Mark this node as fulfillment in course_book's fulfillment tracking.
      if (!empty($node->book['mlid'])) {
        $options['book_fulfillment'][$node->book['mlid']] = TRUE;
        $courseObject
          ->getFulfillment($user)
          ->addOptions($options)
          ->save();
      }
      $courseObject
        ->grade($user);
    }
  }
}