You are here

function export_node_save in Node export 6

Same name and namespace in other branches
  1. 5.2 export.pages.inc \export_node_save()

exports a node by directly saving it.

2 calls to export_node_save()
export_node_check in ./export.pages.inc
Menu callback: prompt the user to confirm the operation
export_node_import in ./export.pages.inc
Import Node UI

File

./export.pages.inc, line 222

Code

function export_node_save($node) {
  global $user;
  if (export_is_permitted($node->type)) {
    $original_node = drupal_clone($node);
    $node->nid = NULL;
    $node->vid = NULL;
    $node->name = $user->name;
    $node->uid = $user->uid;
    $node->created = NULL;
    $node->menu = NULL;
    $node->book['mlid'] = NULL;
    $node->path = NULL;
    $node->files = array();
    if (variable_get('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_export_node_alter(&$node, $original_node, $method)
    // Where $method is either 'prepopulate' or 'save-edit'.
    drupal_alter("export_node", $node, $original_node, "save-edit");
    node_save($node);
    return $node->nid;
  }
}