--- webform_components.inc.orig	2008-08-08 03:28:02.000000000 +0200
+++ webform_components.inc	2008-09-17 11:48:08.000000000 +0200
@@ -267,10 +267,27 @@ function webform_component_edit_form(&$n
     '#type' => 'value',
     '#value' => $component['type'],
   );
-  $form['nid'] = array(
-    '#type' => 'value',
-    '#value' => $node->nid,
-  );
+  if ($clone) {
+    $form['nid'] = array(
+      '#type' => 'select',
+      '#title' => 'Form',
+      '#description' => t('Which form should this component be cloned to?'),
+      '#required' => 1,
+      '#weight' => '-100',
+      '#default_value' => $node->nid,
+      '#options' => _webform_get_forms_options($node->nid),
+    );
+    $form['original_nid'] = array(
+      '#type' => 'value',
+      '#value' => $node->nid,
+    );
+  }
+  else {
+    $form['nid'] = array(
+      '#type' => 'value',
+      '#value' => $node->nid,
+    );
+  }
   $form['cid'] = array(
     '#type' => 'value',
     '#value' => isset($component['cid']) ? $component['cid'] : NULL,
@@ -408,8 +425,13 @@ function webform_component_edit_form_val
 }
 
 function webform_component_edit_form_submit($form_id, $form_values) {
-  $node = node_load($form_values['nid']);
-
+  if ($form_values['clone']) {
+    $node = node_load($form_values['original_nid']);
+  }
+  else {
+    $node = node_load($form_values['nid']);
+  }
+  
   // Remove empty extra values.
   if (is_array($form_values['extra'])) {
     foreach ($form_values['extra'] as $key => $value) {
@@ -533,7 +555,7 @@ function webform_component_delete($node,
  * @param $component
  *   A full component containing fields from the component form.
  */
-function webform_component_clone(&$node, $component) {
+function webform_component_clone(&$node, $component, $new_nid = NULL) {
   $original_cid = $component['cid'];
   unset($component['cid']);
   $new_cid = webform_component_insert($component);
@@ -541,9 +563,39 @@ function webform_component_clone(&$node,
     foreach ($node->webform['components'] as $cid => $child_component) {
       if ($child_component['pid'] == $original_cid) {
         $child_component['pid'] = $new_cid;
+        $child_component['nid'] = $component['nid'];
         webform_component_clone($node, $child_component);
       }
     }
   }
   return $new_cid;
 }
+
+/**
+ * Retrieves a list of the existing webforms and builds an options array for form cloning.
+ * @param $nid
+ *   The nid of the existing component's webform.
+ */
+function _webform_get_forms_options($current_form = NULL) {
+  if (user_access('administer nodes') || user_access('edit_webforms')) {
+    $result = db_query("SELECT nid, uid, title FROM {node} WHERE type = 'webform'");
+  }
+  else if (user_access('edit own webforms')) {
+    global $user;
+    $result = db_query("SELECT nid, uid, title FROM {node} WHERE type = 'webform' AND uid = %d", $user->uid);
+  }
+  else {
+    // This case doesn't really exist, but it's here for good form.
+    return array();
+  }
+  $forms = array();
+  while ($form = db_fetch_object($result)) {
+    if ($form->nid == $current_form) {
+      $forms[$form->nid] = $form->title . ' ' . t('(current form)');
+    }
+    else {
+      $forms[$form->nid] = $form->title;
+    }
+  }
+  return $forms;
+}
