You are here

function book_node_deploy_check in Deploy - Content Staging 6

Implementation of hook_node_deploy_check().

Used to manage deployment dependencies

Parameters

$nid: Unique identifier of the book we're trying to deploy

File

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

Code

function book_node_deploy_check($node) {
  if (isset($node->book)) {
    $parent = isset($node->book['plid']) ? $node->book['plid'] : 0;
    if ($parent > 0) {

      // We are deploying a child page and need to make sure the parent is added
      // to the plan.
      $parent_nid = db_result(db_query("SELECT nid FROM {book} WHERE mlid = %d", $parent));
      $pid = variable_get('deploy_pid', 0);

      // Does the parent node exist on the remote server?
      $remote_key = deploy_get_remote_key(deploy_uuid_get_node_uuid($parent_nid), 'node');

      // If it doesn't exist or the local version is newer, add it to the deployment plan,
      // with a weight of min(weight) - 1, and then run dependency checking on it
      $plan_node = node_load($parent_nid);
      if ($plan_node && (!$remote_key || $remote_key['changed'] < $plan_node->changed) && !deploy_item_is_in_plan($pid, 'node', $plan_node->nid)) {
        deploy_add_to_plan($pid, 'node', $plan_node->type . ': ' . $plan_node->title, $plan_node->nid, deploy_get_min_weight($pid) - 1, DEPLOY_NODE_GROUP_WEIGHT);
        module_invoke_all('node_deploy_check', $plan_node);
      }
    }
  }
}