--- clone.pages.inc	2009-03-10 11:30:30.000000000 +0100
+++ clone.pages.inc.new	2009-03-10 11:30:01.000000000 +0100
@@ -38,6 +38,18 @@
       '#default_value' => variable_get('clone_reset_'. $type, FALSE),
     );
   }
+
+  $form['menu'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Should the menu entry (title, menu parent, weight) be cloned?'),
+  );
+  $form['menu']['clone_menu'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Clone menu entry'),
+      '#default_value' => variable_get('clone_menu', FALSE),
+    );
+
+
   // Need the variable default key to be something that's never a valid node type.
   $form['omit'] = array(
     '#type' => 'fieldset',
@@ -103,6 +115,32 @@
 
 
 /**
+ * Create a new menu entry with title, parent and weight cloned from
+ * another nodes menu. Returns NULL if the node has no menu title
+ */
+function clone_node_clone_menu($node) {
+  // if the node has a menu, it will be in $node->menu after this call
+  // so we can get the menu title and menu parent later. Otherwise
+  // the menu will be prepopulated with the default values
+  if (variable_get('clone_menu', FALSE)) {
+    node_invoke_nodeapi($node, 'prepare');
+    if (!empty($node->menu['link_title'])) {
+      $new_menu=$node->menu;
+      // The new menu entry doesn't exist yet, so it has no mlid and no children
+      $new_menu['mlid']=0;
+      $new_menu['has_children']=0;
+      $new_menu['link_title']=t('Clone of !title', array('!title' => $node->menu['link_title']));
+      $new_menu['plid']=$node->menu['plid'];
+      $new_menu['menu_name']=$node->menu['menu_name'];
+      $new_menu['weight']=$node->menu['weight'];
+      return $new_menu;
+      }
+  }
+  return NULL;
+}
+
+
+/**
  *  Clones a node - prepopulate a node editing form
  */
 function clone_node_prepopulate($original_node) {
@@ -117,7 +155,7 @@
       $node->name = $user->name;
       $node->uid = $user->uid;
       $node->created = NULL;
-      $node->menu = NULL;
+      $node->menu = clone_node_clone_menu($original_node);
       if (isset($node->book['mlid'])) {
         $node->book['mlid'] = NULL;
       }
@@ -159,7 +197,7 @@
       $node->name = $user->name;
       $node->uid = $user->uid;
       $node->created = NULL;
-      $node->menu = NULL;
+      $node->menu = clone_node_clone_menu($original_node);
       $node->book['mlid'] = NULL;
       $node->path = NULL;
       $node->files = array();
