? 249668-clone-menu-link-20.patch
? clone_menu_v6.patch
Index: clone.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_clone/clone.pages.inc,v
retrieving revision 1.3
diff -u -p -r1.3 clone.pages.inc
--- clone.pages.inc	7 May 2008 02:28:58 -0000	1.3
+++ clone.pages.inc	18 Jul 2010 20:01:02 -0000
@@ -1,6 +1,6 @@
 <?php
 // $Id: clone.pages.inc,v 1.3 2008/05/07 02:28:58 pwolanin Exp $
-// $Name:  $
+// $Name: DRUPAL-6--1 $
 
 /**
  * Menu callback to configure module settings.
@@ -24,7 +24,14 @@ function clone_settings() {
     '#options' => array(t('Require confirmation (recommended)'), t('Bypass confirmation')),
     '#description' => t('A new node may be saved immediately upon clicking the "clone" tab when viewing a node, bypassing the normal confirmation form.'),
   );
-  
+  $form['basic']['clone_menu_link'] = array(
+    '#type' => 'radios',
+    '#title' => t('Clone menu links'),
+    '#options' => array(0 => t('No'), 1 => t('Yes')),
+    '#default_value' => (int) variable_get('clone_menu_link', 0),
+    '#description' => t('Should any menu link for a node also be cloned?'),
+  ); 
+
   $form['publishing'] = array(
     '#type' => 'fieldset',
     '#title' => t('Should the publishing options ( e.g. published, promoted, etc) be reset to the defaults?'),
@@ -38,6 +45,7 @@ function clone_settings() {
       '#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',
@@ -103,6 +111,27 @@ function clone_node_confirm_submit($form
 
 
 /**
+ * Create a new menu link cloned from another node.
+ *
+ * Returns NULL if no existing link, or links are not to be cloned.
+ */
+function clone_node_clone_menu_link($node) {
+  if (variable_get('clone_menu_link', FALSE)) {
+    // This will fetch the existing menu link if the node had one.
+    node_invoke_nodeapi($node, 'prepare');
+    if (!empty($node->menu['mlid'])) {
+      $old_link = $node->menu;
+      $link['link_title'] = t('Clone of !title', array('!title' => $old_link['link_title']));
+      $link['plid'] = $old_link['plid'];
+      $link['menu_name'] = $old_link['menu_name'];
+      $link['weight'] = $old_link['weight'];
+      return $link;
+    }
+  }
+  return NULL;
+}
+
+/**
  *  Clones a node - prepopulate a node editing form
  */
 function clone_node_prepopulate($original_node) {
@@ -117,7 +146,7 @@ function clone_node_prepopulate($origina
       $node->name = $user->name;
       $node->uid = $user->uid;
       $node->created = NULL;
-      $node->menu = NULL;
+      $node->menu = clone_node_clone_menu_link($original_node);
       if (isset($node->book['mlid'])) {
         $node->book['mlid'] = NULL;
       }
@@ -159,7 +188,7 @@ function clone_node_save($nid) {
       $node->name = $user->name;
       $node->uid = $user->uid;
       $node->created = NULL;
-      $node->menu = NULL;
+      $node->menu = clone_node_clone_menu_link($original_node);
       $node->book['mlid'] = NULL;
       $node->path = NULL;
       $node->files = array();
