? 6-update.diff
? both-methods-254328-1.patch
? both-methods-254328-2.patch
? clone-own-231997-6x-14.patch
Index: clone.install
===================================================================
RCS file: clone.install
diff -N clone.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ clone.install	3 May 2008 20:08:01 -0000
@@ -0,0 +1,17 @@
+<?php
+// $Id: clone.module,v 1.20 2008/05/03 18:01:38 pwolanin Exp $
+// $Name:  $
+
+/**
+ * Implementation of hook_uninstall.
+ */
+function clone_uninstall() {
+  
+  variable_del('clone_method');
+  variable_del('clone_omitted');
+  $types = node_get_types('names');
+  foreach ($types as $type => $name) {
+    variable_del('clone_reset_'. $type);
+  }
+}
+
Index: clone.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_clone/clone.module,v
retrieving revision 1.20
diff -u -p -r1.20 clone.module
--- clone.module	3 May 2008 18:01:38 -0000	1.20
+++ clone.module	3 May 2008 20:08:01 -0000
@@ -12,7 +12,10 @@ function clone_help($path, $arg) {
       $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;
     case 'node/%/clone':
-      return t('This clone will not be saved to the database until you submit.');
+      $method = variable_get('clone_method', 'prepopulate');
+      if ($method == 'prepopulate') {
+        return t('This clone will not be saved to the database until you submit.');
+      }
   }
 }
 
@@ -32,17 +35,17 @@ function clone_menu() {
     'page callback' => 'drupal_get_form',
     'page arguments' => array('clone_settings'),
     'title' => 'Clone module',
+    'file' => 'clone.pages.inc',
     'description' => 'Allows users to clone (copy then edit) an existing node.',
   );
   $items['node/%node/clone'] = array(
     'access callback' => 'clone_access',
     'access arguments' => array(1),
-    'page callback' => 'clone_node',
+    'page callback' => 'clone_node_check',
     'page arguments' => array(1),
     'title' => 'Clone',
     'weight' => 5,
-    'file' => 'node.pages.inc',
-    'file path' => drupal_get_path('module', 'node'),
+    'file' => 'clone.pages.inc',
     'type' => MENU_LOCAL_TASK,
   );
   return $items;
@@ -61,48 +64,8 @@ function clone_access($node) {
 }
 
 function clone_is_permitted($type) {
-  return !in_array($type, variable_get('clone_omitted', array()));
-}
-
-/**
- * menu callback to configure module settings.
- */
-function clone_settings() {
-
-  $form['heading'] = array(
-    '#value' => '<b>'. t('Configuration options for the clone module:') .'</b>',
-  );
-
-  $form['publishing'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Should the publishing options ( e.g. published, promoted, etc) be reset to the defaults?'),
-  );
-  $types = node_get_types('names');
-
-  foreach ($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),
-    );
-  }
-  // Need the variable default key to be something that's never a valid node type.
-  $types = array_merge( array('!' => "<". t("none") .">"), $types);
-  $form['clone_omitted'] = array(
-    '#type' => 'select',
-    '#title' => t('Omitted content types'),
-    '#default_value' => variable_get('clone_omitted', array('!')),
-    '#options' => $types,
-    '#description' => t('Select any node types which should <em>never</em> be cloned. Typically you should will want to select here all node types for which cloning fails (e.g. image nodes).'),
-    '#multiple' => TRUE
-  );
-
-  $form['clone_method'] = array(
-    '#type' => 'value',
-    '#value' => 'prepopulate',
-  );
-
-  return system_settings_form($form);
+  $omitted = variable_get('clone_omitted', array());
+  return empty($omitted[$type]);
 }
 
 /**
@@ -125,40 +88,3 @@ function clone_node_type($op, $type_obj)
   }
 }
 
-/**
- *  Clones a node - prepopulate a node editing form
- */
-function clone_node($node) {
-  if (isset($node->nid)) {
-    global $user;
-
-    if (clone_is_permitted($node->type)) {
-      // Let other modules do special fixing up.
-      // The function signature is: hook_clone_node_alter(&$node, $method)
-      // Where method is either 'prepopulate' or 'save-edit'.
-      drupal_alter("clone_node", $node, "prepopulate");
-
-      $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();
-      $node->title = t('Clone of !title', array('!title' => $node->title));
-      drupal_set_title(check_plain($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);
-        }
-      }
-      return  drupal_get_form($node->type .'_node_form', $node);
-    }
-  }
-}
-
Index: clone.pages.inc
===================================================================
RCS file: clone.pages.inc
diff -N clone.pages.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ clone.pages.inc	3 May 2008 20:08:01 -0000
@@ -0,0 +1,178 @@
+<?php
+// $Id: clone.module,v 1.20 2008/05/03 18:01:38 pwolanin Exp $
+// $Name:  $
+
+/**
+ * Menu callback to configure module settings.
+ */
+function clone_settings() {
+
+  $form['basic'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Basic configuration'),
+  );
+  $form['basic']['clone_method'] = array(
+    '#type' => 'radios',
+    '#title' => t('Method to use when cloning a node'),
+    '#options' => array('prepopulate' => t('Pre-populate the form'), 'save-edit' => t('Save then edit')),
+    '#default_value' => variable_get('clone_method', 'prepopulate'),
+  );
+
+  $form['publishing'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Should the publishing options ( e.g. published, promoted, etc) be reset to the defaults?'),
+  );
+  $types = node_get_types('names');
+
+  foreach ($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),
+    );
+  }
+  // Need the variable default key to be something that's never a valid node type.
+  $form['omit'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Content types that are not to be cloned - omitted due to incompatibility'),
+  );
+  $form['omit']['clone_omitted'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Omitted content types'),
+    '#default_value' => variable_get('clone_omitted', array()),
+    '#options' => $types,
+    '#description' => t('Select any node types which should <em>never</em> be cloned. Typically you should will want to select here all node types for which cloning fails (e.g. image nodes).'),
+  );
+
+  return system_settings_form($form);
+}
+
+/**
+ *  Menu callback: prompt the user to confirm the operation
+ */
+function clone_node_check($node) {
+
+  $method = variable_get('clone_method', 'prepopulate');
+  
+  switch ($method) {
+    case 'save-edit':
+      if (variable_get('clone_nodes_without_confirm', FALSE)) {
+        $new_nid = clone_node_save($node->nid);
+        drupal_goto('node/'. $new_nid .'/edit');
+      }
+      else {
+        return drupal_get_form('clone_node_confirm', $node);
+      }
+      break;
+    case 'prepopulate':
+    default:
+      include_once(drupal_get_path('module', 'node') .'/node.pages.inc');
+      return clone_node_prepopulate($node);
+      break;
+  }
+}
+
+/**
+ *  form builder: prompt the user to confirm the operation
+ */
+function clone_node_confirm($form_state, $node) {
+
+    $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, &$form_state) {
+  if ($form_state['values']['confirm']) {
+    $new_nid = clone_node_save($form_state['values']['nid']);
+  }
+  $form_state['redirect'] = 'node/'. $new_nid .'/edit';
+}
+
+
+/**
+ *  Clones a node - prepopulate a node editing form
+ */
+function clone_node_prepopulate($original_node) {
+  if (isset($original_node->nid)) {
+    global $user;
+
+    if (clone_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();
+      $node->title = t('Clone of !title', array('!title' => $node->title));
+      drupal_set_title(check_plain($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);
+        }
+      }
+      // Let other modules do special fixing up.
+      // The function signature is: hook_clone_node_alter(&$node, $original_node, $method)
+      // Where $method is either 'prepopulate' or 'save-edit'.
+      drupal_alter("clone_node", $node, $original_node, "prepopulate");
+
+      return drupal_get_form($node->type .'_node_form', $node);
+    }
+  }
+}
+
+/**
+ *  Clones a node by directly saving it.
+ */
+function clone_node_save($nid) {
+  if (is_numeric($nid)) {
+    global $user;
+
+    $node = node_load($nid);
+    if (isset($node->nid) && clone_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();
+      $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);
+        }
+      }
+      // Let other modules do special fixing up.
+      // The function signature is: hook_clone_node_alter(&$node, $original_node, $method)
+      // Where $method is either 'prepopulate' or 'save-edit'.
+      drupal_alter("clone_node", $node, $original_node, "save-edit");
+
+      node_save($node);
+      return $node->nid;
+    }
+  }
+}
+
