? clone_access_1.diff
? clone_confirm-1.patch.txt
? clone_settings_5.diff
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_clone/README.txt,v
retrieving revision 1.2
diff -u -p -r1.2 README.txt
--- README.txt	28 Jul 2006 01:00:38 -0000	1.2
+++ README.txt	9 Sep 2006 17:50:49 -0000
@@ -14,9 +14,16 @@ This module makes reasonable checks on a
 a node unless they can use the input format of that node, and unless they have
 permission to create new nodes of that type based on a call to node_access().
 
+Settings can be accessed at admin/settings/clone.  On this page you can
+set whether an additional confirmation screen is required before making a clone
+of a node, and also set whether the publishing options are reset when making
+a clone of a node.  This is set for each node type individually.
+
 This module seems to work with common node types, however YMMV. File 
-attachments are not included in the cloned node.  Seems to produce
-functional clones of forms made using webform. In all cases, but especially
+attachments are not included in the cloned node.  It seems to produce
+functional clones of forms made using the webform module, but because of 
+replication of some of the webforms IDs, the form's theming will always be
+the same as the original webform. In all cases, but especially
 if you are using a complex or custom node type, you should evaluate this
 module on a test site with a copy of your database before attempting to use
 it on a live site.
@@ -25,6 +32,6 @@ To install this module, copy it to the /
 installation and enable it at /admin/modules.  A new permission is created, but 
 there are no changes to the database structure.
 
-Note: this module derived from code posted by Steve Ringwood (nevets@drupal) at 
-http://drupal.org/node/73381#comment-137714
+Note: this module originally derived from code posted by Steve Ringwood 
+(nevets@drupal) at http://drupal.org/node/73381#comment-137714
 
Index: clone.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_clone/clone.module,v
retrieving revision 1.4
diff -u -p -r1.4 clone.module
--- clone.module	28 Jul 2006 01:00:06 -0000	1.4
+++ clone.module	9 Sep 2006 17:50:49 -0000
@@ -21,7 +21,9 @@ function clone_perm() {
   return array('clone node');
 }
 
-
+/**
+ * Implementation of hook_menu().
+ */
 function clone_menu($may_cache) {
   $items = array();
 
@@ -32,7 +34,7 @@ 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', 'access' => $access,
+                          'callback' => 'clone_node_confirm', 'access' => $access,
                           'type' => MENU_LOCAL_TASK, 'weight' => 5,); 
        }
     }
@@ -41,22 +43,96 @@ function clone_menu($may_cache) {
   return $items;
 }
 
-function clone_node()
+/**
+* Implementation of hook_settings().
+*/
+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',
+     '#title' => '<b>'.t('Should the publishing options ( e.g. published, promoted, etc) be reset to the defaults?').'</b>',
+   );
+  
+  foreach (node_get_types() as $type => $name) {
+    $form['publishing']['clone_reset_'. $type] = array(
+      '#type' => 'checkbox',
+      '#title' => t('%s: reset publishing options when cloned', array('%s' => $name)),
+      '#default_value' => variable_get('clone_reset_'. $type, FALSE),
+    );    
+  }
+
+  return $form;
+}
+
+/**
+ *  Menu callback: prompt the user to confirm the operation
+ */
+function clone_node_confirm() {
+  
+  if (variable_get('clone_nodes_without_confirm', FALSE)) {
+    clone_node(arg(1));
+  }
+  else {
+    $node = node_load(arg(1)); 
+    $form['nid'] = array('#type' => 'value', '#value' => $node->nid);
+    $output = confirm_form('clone_node_confirm', $form,
+      t('Are you sure you want to clone %title?', array('%title' => theme('placeholder', $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'));
+    
+    return $output;
+  }
+}
+
+/**
+ *  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
+ */
+function clone_node($nid)
 {
+  if (is_numeric($nid)) {
     global $user;
-   
-    $nid=arg(1);    
+    
     $node = node_load($nid);
-   
-    $node->nid = NULL;
-    $node->uid = $user->uid;
-    $node->created = 0;   
-    $node->menu = NULL;
-    $node->path = NULL;   
-    $node->title = 'Clone of '.$node->title;
-   
-    node_save($node);
-   
-    drupal_goto('node/'. $node->nid . '/edit');
+    if (isset($node->nid)) {
+      
+      $node->nid = NULL;
+      $node->uid = $user->uid;
+      $node->created = 0;   
+      $node->menu = NULL;
+      $node->path = NULL;   
+      $node->title = t('Clone of %title', array('%title' => $node->title));
+      
+      if (variable_get('clone_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);
+        } 
+      }
+      
+      node_save($node);
+      drupal_goto('node/'. $node->nid . '/edit');
+    }
+  }
 }
 
