? node_clone.zip
? prepopulate_clone_1.diff
? prepopulate_clone_5x_2.patch
? prepopulate_clone_5x_3.patch
Index: clone.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_clone/clone.module,v
retrieving revision 1.9
diff -u -p -r1.9 clone.module
--- clone.module	11 Nov 2006 04:10:13 -0000	1.9
+++ clone.module	14 Feb 2007 21:01:04 -0000
@@ -7,7 +7,7 @@ function clone_help($section) {
   switch ($section) {
     case 'admin/help#clone':
       $output = '<p>'. t('The clone module allows users to make a copy of an existing node and then edit that copy. The authorship is set to the current user, the menu and url aliases are reset, and the words "Clone of" are inserted into the title to remind you that you are not editing the original node.') .'</p>';
-      $output .= '<p>'. t('Users with the "clone node" permission can utilize this functionality. A new tab will appear on node pages with the word "clone". Once you click this tab you have <em>already</em> created a new node that is a copy of the node you were viewing, and you will be redirected to an edit screen for that new node.') .'</p>';
+      $output .= '<p>'. t('Users with the "clone node" permission can utilize this functionality. A new tab will appear on node pages with the word "Clone".') .'</p>';
       return $output;
   }
 }
@@ -42,8 +42,9 @@ function clone_menu($may_cache) {
          $access = (user_access('clone node') && filter_access($node->format) && node_access('create',$node->type));
          $items[] = array(
            'path' => 'node/'. $node->nid.'/clone', 
-           'title' => t('clone'),
-           'callback' => 'clone_node_check', 
+           'title' => t('Clone'),
+           'callback' => 'clone_node',
+           'callback arguments' => $node->nid,
            'access' => $access,
            'type' => MENU_LOCAL_TASK, 'weight' => 5,); 
        }
@@ -61,12 +62,6 @@ function clone_settings() {
   $form['heading'] = array(
     '#value' => '<b>'.t('Configuration options for the clone module:').'</b>',
   );
-  $form['clone_nodes_without_confirm'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Clone nodes without requiring confirmation'),
-    '#default_value' => variable_get('clone_nodes_without_confirm', FALSE),
-    '#description' => t('If this is set, a new node will be created immediately upon clicking the "clone" tab when viewing a node.'),
-  );
 
   $form['publishing'] = array(
     '#type' => 'fieldset',
@@ -105,42 +100,7 @@ function clone_node_type($op, $type_obj)
 }
 
 /**
- *  Menu callback: prompt the user to confirm the operation
- */
-function clone_node_check() {
-  
-  if (variable_get('clone_nodes_without_confirm', FALSE)) {
-    clone_node(arg(1));
-    return;
-  }
-  return drupal_get_form('clone_node_confirm');
-}
-
-/**
- *  form builder: prompt the user to confirm the operation
- */
-function clone_node_confirm() {
-  
-    $node = node_load(arg(1)); 
-    $form['nid'] = array('#type' => 'value', '#value' => $node->nid);
-    return confirm_form($form,
-      t('Are you sure you want to clone %title?', array('%title' =>  $node->title)),
-      'node/'. $node->nid,'<p>'. t('This action will create a new node. You willl then be redirected to the edit page for the new node.'). '</p>',
-      t('Clone'), t('Cancel'));
-}
-
-/**
- *  Handle confirm form submission
- */
-function clone_node_confirm_submit($form_id, $form_values) {
-  if ($form_values['confirm']) {
-    clone_node($form_values['nid']);    
-  }
-  return '';
-} 
-
-/**
- *  Clones a node
+ *  Clones a node - prepopulate a node editing form
  */
 function clone_node($nid)
 {
@@ -154,7 +114,8 @@ function clone_node($nid)
       $node->uid = $user->uid;
       $node->created = 0;   
       $node->menu = NULL;
-      $node->path = NULL;   
+      $node->path = NULL;
+      $node->files = NULL;
       $node->title = t('Clone of @title', array('@title' => $node->title));
       
       if (variable_get('clone_reset_'. $node->type, FALSE)) {
@@ -164,9 +125,10 @@ function clone_node($nid)
           $node->$key = in_array($key, $node_options);
         } 
       }
-      
-      node_save($node);
-      drupal_goto('node/'. $node->nid . '/edit');
+      if (empty($_POST['op'])) {
+        drupal_set_message('This clone will not be saved to the database until you submit.');
+      }
+      return  drupal_get_form($node->type .'_node_form', $node); 
     }
   }
 }
