--- mm_content.module	Wed Dec 10 09:38:36 2008
+++ mm_content.new	Wed Dec 10 09:46:06 2008
@@ -133,31 +133,39 @@ function mm_content_harvest($action, $co
   $files = array();
   $fields = content_fields();
 
+  $harvest_conditions = '';
   // are we harvesting from a specific NID ?
   if ($nid) {
     $harvest_conditions = ' AND n.nid = '. $nid;
   }
-  else {
-    // select nodes that have beend modified since the last time that this
-    // configuration was run
-    $harvest_conditions = ' AND n.changed > '. ($running_config->last_start_time ? $running_config->last_start_time : 0);
-  }
 
   foreach ($configuration['mm_config_harvest_field'] as $field_name) {
     $db_info = content_database_info($fields[$field_name]);
 
-    // @TODO this has to be adapted for D6 SQL structure
-    $results = db_query('SELECT f.filepath, n.nid FROM {files} f
-      LEFT JOIN '. $db_info['table'] .' c ON c.'. $db_info['columns']['fid']['column'] .' = f.fid
-      LEFT JOIN {node} n ON c.nid = n.nid
-      LEFT JOIN {media_mover_files} m ON m.fid = f.fid AND m.cid = %d
-      WHERE  m.mmfid IS NULL '. $harvest_conditions .'
-      ORDER BY n.nid DESC', $configuration['cid'], $running_config->last_start_time);
-    while ($result = db_fetch_array($results)) {
-      $files[] = array(
-        'harvest_file' => $result['filepath'],
-        'nid' => $result['nid'],
-      );
+    switch ($fields[$field_name]['type']) {
+  
+      // handle text field
+      case 'text':
+        // TODO: harvesting from text field
+      break;
+    
+      // handle image field case
+      case 'filefield':
+      case 'image':
+        $results = db_query('SELECT f.filepath, n.nid FROM {files} f
+           LEFT JOIN '. $db_info['table'] .' c ON c.'. $db_info['columns']['fid']['column'] .' = f.fid
+           LEFT JOIN {node} n ON c.nid = n.nid
+           LEFT JOIN {media_mover_files} m ON n.nid = m.nid AND m.cid = %d
+           WHERE (n.nid IS NOT NULL AND m.nid IS NULL) OR
+                 (n.nid IS NOT NULL AND n.nid = m.nid AND f.filepath <> m.harvest_file)'. $harvest_conditions .'
+           ORDER BY f.timestamp', $configuration['cid']);
+        while ($result = db_fetch_array($results)) {
+          $files[] = array(
+            'harvest_file' => $result['filepath'],
+            'nid' => $result['nid'],
+          );
+        }
+      break;
     }
   }
 
