Index: mm_content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/media_mover/mm_content/mm_content.module,v
retrieving revision 1.1.2.16.2.6
diff -u -p -r1.1.2.16.2.6 mm_content.module
--- mm_content.module	3 Dec 2008 21:38:18 -0000	1.1.2.16.2.6
+++ mm_content.module	4 Dec 2008 17:28:12 -0000
@@ -133,34 +133,45 @@ 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);
+    // select files to harvest have been modified since the last time that this configuration was run
+    $harvest_conditions .= ' AND f.timestamp > '. ($running_config->last_start_time ? $running_config->start_time : 0);
+    $harvest_conditions .= ' AND n.nid IS NOT NULL ';
   }
 
   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']);
-    while ($result = db_fetch_array($results)) {
-      $files[] = array(
-        'harvest_file' => $result['filepath'],
-        'nid' => $result['nid'],
-      );
+    // change the query based on field type
+    switch ($fields[$field_name]['type']) {
+      case 'text':
+        //$node->{$field['field_name']} = array(array('value' => $file['process_file']));
+      break;
+
+      // handle image field case
+      case 'filefield':
+      case 'image':
+        // @TODO this has to be adapted for D6 SQL structure
+        $results = db_queryd('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 f.timestamp', $configuration['cid']);
+        while ($result = db_fetch_array($results)) {
+          $files[] = array(
+            'harvest_file' => $result['filepath'],
+            'nid' => $result['nid'],
+          );
+        }
+      break;
     }
   }
-
   return $files;
 }
 
