You are here

function book_node_import_prepare in Node import 5

Implementation of hook_node_import_prepare().

File

supported/book.inc, line 23
Support file for book module.

Code

function book_node_import_prepare(&$node, $preview = FALSE) {
  $errors = array();
  if (isset($node->node_import_book_parent)) {
    $parent = trim($node->node_import_book_parent);
    unset($node->node_import_book_parent);
    if (strlen($parent) == 0) {
      $node->parent = 0;
    }
    else {
      if ($nid = node_import_nodereference($parent)) {
        $node->parent = $nid;
      }
      else {
        $errors[] = t('Unable to set parent of book page: no node matching %title found.', array(
          '%title' => $parent,
        ));
      }
    }
  }
  return $errors;
}