You are here

function clone_node_prepopulate in Node clone 7

Same name and namespace in other branches
  1. 6 clone.pages.inc \clone_node_prepopulate()

Clones a node - prepopulate a node editing form

1 call to clone_node_prepopulate()
clone_node_check in ./clone.pages.inc
Menu callback: prompt the user to confirm the operation

File

./clone.pages.inc, line 171
Additional functions for Node_Clone module.

Code

function clone_node_prepopulate($original_node) {
  if (isset($original_node->nid)) {
    if (clone_is_permitted($original_node->type)) {
      $node = _clone_node_prepare($original_node, TRUE);
      drupal_set_title($node->title);

      // Let other modules do special fixing up.
      $context = array(
        'method' => 'prepopulate',
        'original_node' => $original_node,
      );
      drupal_alter('clone_node', $node, $context);

      // Make sure the file defining the node form is loaded.
      $form_state = array();
      $form_state['build_info']['args'] = array(
        $node,
      );
      form_load_include($form_state, 'inc', 'node', 'node.pages');
      return drupal_build_form($node->type . '_node_form', $form_state);
    }
  }
}