You are here

function export_node_prepopulate in Node export 6

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

exports a node - prepopulate a node editing form

1 call to export_node_prepopulate()
export_node_check in ./export.pages.inc
Menu callback: prompt the user to confirm the operation

File

./export.pages.inc, line 185

Code

function export_node_prepopulate($original_node) {
  global $user;
  if (export_is_permitted($original_node->type)) {
    $node = drupal_clone($original_node);
    $node->nid = NULL;
    $node->vid = NULL;
    $node->name = $user->name;
    $node->uid = $user->uid;
    $node->created = NULL;
    $node->menu = NULL;
    if (isset($node->book['mlid'])) {
      $node->book['mlid'] = NULL;
    }
    $node->path = NULL;
    $node->files = array();
    drupal_set_title(check_plain($node->title));
    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, "prepopulate");
    return str_replace('admin/content/import', 'node/add/' . $node->type, drupal_get_form($node->type . '_node_form', $node));
  }
}