You are here

function course_book_node_view in Course 7

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

Implements hook_node_view().

File

modules/course_book/course_book.module, line 57

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, $user)) {
      $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()
          ->addOptions($options)
          ->save();
      }
      $courseObject
        ->grade();
    }
  }
}