Index: comment.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/migrate/supported/Attic/comment.inc,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 comment.inc
--- comment.inc	5 Apr 2009 20:22:38 -0000	1.1.2.3
+++ comment.inc	7 Apr 2009 22:17:13 -0000
@@ -12,7 +12,7 @@
  * @param unknown_type $type
  * @return unknown
  */
-function migrate_migrate_destination_fields_comment($type) {
+function comment_migrate_destination_fields_comment($type) {
   $fields = array(
     'subject' => t('Comment: Title'),
     'comment' => t('Comment: Body'),
@@ -26,7 +26,7 @@ function migrate_migrate_destination_fie
   return $fields;
 }
 
-function migrate_migrate_destination_delete_comment($cid) {
+function comment_migrate_destination_delete_comment($cid) {
   $path = drupal_get_path('module', 'comment') . '/comment.admin.inc';
   include_once($path);
   // Backdoor deletion - query stolen from comment_delete()
@@ -41,11 +41,13 @@ function migrate_migrate_destination_del
   comment_confirm_delete_submit($form, $form_state);
 }
 
-function migrate_migrate_destination_import_comment($tblinfo, $row) {
+function comment_migrate_destination_import_comment($tblinfo, $row) {
   $comment = array();
   $errors = array();
   $sourcekey = $tblinfo->sourcekey;
   
+  
+  //TODO: replace this with the migrate_destination_invoke_all(); 
   foreach ($tblinfo->fields as $destfield => $values) {
      if ($values['srcfield'] && $row->$values['srcfield']) {
       $comment[$destfield] = $row->$values['srcfield'];
@@ -54,6 +56,8 @@ function migrate_migrate_destination_imp
     }
   }
   
+
+  
   // Prepare the comment for import. We could have use migrate_invoke_all()
   // but unfortunately arguments are passed by value
   foreach (module_list() as $module_name) {
@@ -65,20 +69,15 @@ function migrate_migrate_destination_imp
     }
   }
   
-  // nid and uid are initially populated with the source file's ID - translate to 
-  // Drupal IDs
-  if ($comment['nid']) {
-    $comment['nid'] = _migrate_xlat_get_new_id('node', $comment['nid']);
-  }
+    /*
+   * Validation: should probably create a validation hook instead
+   */
   if (!$comment['nid']) {
     $errors[] = migrate_message(t('No node found'));
   }
-  if ($comment['uid']) {
-    $comment['uid'] = _migrate_xlat_get_new_id('user', $comment['uid']);
-    if (!$comment['name']) {
-      $commentuser = user_load(array('uid' => $comment['uid']));
-      $comment['name'] = $commentuser->name;
-    }
+  if (!$comment['name']) {
+    $commentuser = user_load(array('uid' => $comment['uid']));
+    $comment['name'] = $commentuser->name;
   }
   if (!$comment['name']) {
     $errors[] = migrate_message(t('No user id or name found'));
@@ -91,26 +90,42 @@ function migrate_migrate_destination_imp
       $errors[] = migrate_message(t('Provided timestamp is invalid'));
     }
   }
-  
+ 
+  //TODO: we should probably check actual errors, some may be info messages. 
   if (count($errors) == 0) {
     $cid = comment_save($comment);
-    if ($cid) {
-      // comment_save() always saves time() as the timestamp, override if we have a value
-      if ($comment['timestamp']) {
-        db_query("UPDATE {comments}
-                  SET timestamp=%d
-                  WHERE cid=%d",
-                 $comment['timestamp'], $cid);
-      }
-      $sourcekey = $tblinfo->sourcekey;
-      //@TODO: Factor out into caller
-      db_query("INSERT INTO {" . $tblinfo->maptable . "}
-                ($sourcekey, commentid, mcsid)
-                VALUES(%d, %d, %d)",
-               $row->$sourcekey, $cid, $tblinfo->mcsid);
-    } else {
-      $errors[] = migrate_message(t('Comment not saved'));
+  }
+  
+  //TODO: replace this with the migrate_destination_invoke_all();
+  foreach (module_list() as $module_name) {
+    $function = $module_name .'_migrate_destination_complete_comment';
+    if (function_exists($function)) {
+      timer_start($function);
+      $errors = array_merge($errors, (array)$function($cid, $tblinfo, $row));
+      timer_stop($function);
+    }
+  }
+  
+  return $errors;
+}
+
+function comment_migrate_destination_complete_comment(&$cid, $tblinfo, $row) {
+  if ($cid) {
+    // comment_save() always saves time() as the timestamp, override if we have a value
+    if ($comment['timestamp']) {
+      db_query("UPDATE {comments}
+                SET timestamp=%d
+                WHERE cid=%d",
+               $comment['timestamp'], $cid);
     }
+    $sourcekey = $tblinfo->sourcekey;
+    //@TODO: Factor out into caller
+    db_query("INSERT INTO {" . $tblinfo->maptable . "}
+              ($sourcekey, commentid, mcsid)
+              VALUES(%d, %d, %d)",
+             $row->$sourcekey, $cid, $tblinfo->mcsid);
+  } else {
+    $errors[] = migrate_message(t('Comment not saved'));
   }
   return $errors;
 }
