You are here

function node_export_node_clone in Node export 6.2

Same name and namespace in other branches
  1. 6.3 node_export.module \node_export_node_clone()
  2. 7.3 node_export.module \node_export_node_clone()

Prepare a clone of the node during import.

2 calls to node_export_node_clone()
node_export_node_prepopulate in ./node_export.module
Exports a node - prepopulate a node editing form
node_export_node_save in ./node_export.module
Exports a node by directly saving it.

File

./node_export.module, line 813
The Node Export module.

Code

function node_export_node_clone($original_node, $mode) {
  global $user;
  $node = drupal_clone($original_node);
  $node->nid = NULL;
  $node->vid = NULL;
  $node->name = $user->name;
  $node->uid = $user->uid;
  if (variable_get('node_export_reset_created_' . $node->type, TRUE)) {
    $node->created = NULL;
  }
  if (variable_get('node_export_reset_changed_' . $node->type, TRUE)) {
    $node->changed = NULL;
  }
  if (variable_get('node_export_reset_menu_' . $node->type, TRUE)) {
    $node->menu = NULL;
  }
  if (variable_get('node_export_reset_path_' . $node->type, TRUE)) {
    $node->path = NULL;
  }
  elseif (module_exists('pathauto')) {

    // Prevent pathauto from creating a new path alias.
    $node->pathauto_perform_alias = FALSE;
  }
  if (variable_get('node_export_reset_book_mlid_' . $node->type, TRUE) && isset($node->book['mlid'])) {
    $node->book['mlid'] = NULL;
  }
  $node->files = array();
  if (variable_get('node_export_reset_' . $node->type, FALSE)) {
    $node_options = variable_get('node_options_' . $node->type, array(
      'status',
      'promote',
    ));

    // Fill in the default values.
    foreach (array(
      'status',
      'moderate',
      'promote',
      'sticky',
      'revision',
    ) as $key) {
      $node->{$key} = in_array($key, $node_options);
    }
  }

  // Let other modules do special fixing up.
  // The function signature is: hook_node_export_node_alter(&$node, $original_node, $method)
  // Where $method is either 'prepopulate' or 'save-edit'.
  drupal_alter('node_export_node', $node, $original_node, $mode);
  return $node;
}