You are here

function filefield_deploy_node_deploy_check in Deploy - Content Staging 6

Implementation of hook_node_deploy_check().

This is the dependency checking hook for nodes, called when a deployment has been requested that includes a node.

Parameters

$node: The node object being deployed

File

modules/filefield_deploy/filefield_deploy.module, line 59
Deployment API which enables modules to deploy items between servers.

Code

function filefield_deploy_node_deploy_check($node) {

  // Figure out which fields in this node are file-related.
  $fields = filefield_deploy_get_file_fields($node->type);

  // Get the remote server info.
  $url = variable_get('deploy_server_url', '');
  $pid = variable_get('deploy_pid', 0);

  // Roll through all the file fields in this content type. If it
  // is not empty, not in the plan already, and doesn't exist on the
  // remote server, then add it to the plan with an appropriate weight.
  if ($fields) {
    foreach ($fields as $field) {
      if (!empty($node->{$field})) {
        foreach ($node->{$field} as $file) {
          if (!deploy_item_is_in_plan($pid, 'filefield', $file['fid'])) {

            // Does this user exist on the remote server?
            $remote_key = deploy_get_remote_key($file['uuid'], 'files');

            // If not we're going to add it to the deployment plan, with a weight
            // of min(weight) - 1.
            if (!$remote_key) {
              deploy_add_to_plan($pid, 'filefield', 'File: ' . $file['filename'], $file['fid'], deploy_get_min_weight($pid) - 1, DEPLOY_FILE_GROUP_WEIGHT);
            }
          }
        }
      }
    }
  }
}