You are here

function book_node_deploy in Deploy - Content Staging 6

Implementation of hook_node_deploy(),

Parameters

$nid: Unique identifier for the node we're deploying.

Return value

The results of our xmlrpc call.

File

modules/book_deploy/book_deploy.module, line 16
Deployment module for book pages

Code

function book_node_deploy($node) {
  if (isset($node->book)) {
    $parent = $node->book['plid'];
    if ($parent <= 0) {
      if (!isset($node->remote_nid)) {

        // We are deploying a new book node, we'll need to set its book form
        // element to the "create" option.
        $node->book = array();
        $node->book += _book_link_defaults('new');
        $node->book['bid'] = 'new';
        $node->book['plid'] = -1;
      }
      else {

        // We are deploying a previously deployed top-level book page.
        $remote_book = deploy_get_remote_book($node->uuid);
        $node->book['nid'] = $remote_book['nid'];
        $node->book['bid'] = $remote_book['bid'];
        $node->book['plid'] = 0;
      }
    }
    else {
      $parent_nid = db_result(db_query("SELECT nid FROM {book} WHERE mlid = %d", $parent));

      // We are deploying a child node, whose parent will have been already
      // deployed so we need to get its remote parent id and bid.
      $remote_parent = deploy_get_remote_book(deploy_uuid_get_node_uuid($parent_nid));
      $node->book['bid'] = $remote_parent['bid'];
      $node->book['plid'] = $remote_parent['mlid'];
      $node->book['nid'] = isset($node->remote_nid) ? $node->remote_nid : 'new';
    }
  }
}