? clone_permitted_1.patch
? clone_permitted_2.patch
? clone_permitted_3.patch
? clone_permitted_DRUPAL-5_3.patch
? clone_permitted_DRUPAL-5_4.patch
? prepopulate_clone_1.diff
? prepopulate_clone_4.patch
? 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	4 May 2007 23:33:49 -0000
@@ -39,10 +39,10 @@ function clone_menu($may_cache) {
     if (arg(0) == 'node' && is_numeric(arg(1))){
        $node=node_load(arg(1));
        if ($node->nid) {
-         $access = (user_access('clone node') && filter_access($node->format) && node_access('create',$node->type));
+         $access = (user_access('clone node') && clone_is_permitted($node->type) && filter_access($node->format) && node_access('create',$node->type));
          $items[] = array(
            'path' => 'node/'. $node->nid.'/clone', 
-           'title' => t('clone'),
+           'title' => t('Clone'),
            'callback' => 'clone_node_check', 
            'access' => $access,
            'type' => MENU_LOCAL_TASK, 'weight' => 5,); 
@@ -53,6 +53,10 @@ function clone_menu($may_cache) {
   return $items;
 }
 
+function clone_is_permitted($type) {
+  return !in_array($type, variable_get('clone_omitted', array()));
+}
+
 /**
 * menu callback to configure module settings.
 */
@@ -72,14 +76,25 @@ function clone_settings() {
     '#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_obj) {
-    $form['publishing']['clone_reset_'. $type_obj->type] = array(
+  $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' => $type_obj->name)),
-      '#default_value' => variable_get('clone_reset_'. $type_obj->type, FALSE),
+      '#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
+  );
 
   return system_settings_form($form);
 }
@@ -148,7 +163,7 @@ function clone_node($nid)
     global $user;
     
     $node = node_load($nid);
-    if (isset($node->nid)) {
+    if (isset($node->nid) && clone_is_permitted($node->type)) {
       
       $node->nid = NULL;
       $node->uid = $user->uid;
