You are here

function node_export_node_clone in Node export 6.3

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

Generates a pristine cloned node such that it is ready for import. Note, the node_export_features module uses this function to generate cleaner exports.

2 calls to node_export_node_clone()
node_export_features_node_export_alter in modules/node_export_features/node_export_features.module
Implements hook_node_export_alter().
node_export_import in ./node_export.module
Import Function

File

./node_export.module, line 628
The Node export module.

Code

function node_export_node_clone($original_node) {
  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_revision_timestamp_' . $node->type, TRUE)) {
    $node->revision_timestamp = NULL;
  }
  if (variable_get('node_export_reset_last_comment_timestamp_' . $node->type, TRUE)) {
    $node->last_comment_timestamp = 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;
  }
  else {
    if (is_array($node->path) && isset($node->path['pid'])) {
      unset($node->path['pid']);
    }
    if (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);
    }
  }
  return $node;
}