### Eclipse Workspace Patch 1.0 #P search Index: modules/search_attachments/search_attachments.module =================================================================== RCS file: /cvs/drupal/contributions/modules/search_files/modules/search_attachments/Attic/search_attachments.module,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 search_attachments.module --- modules/search_attachments/search_attachments.module 12 Jan 2009 16:38:36 -0000 1.1.2.2 +++ modules/search_attachments/search_attachments.module 21 Mar 2009 17:29:52 -0000 @@ -90,9 +90,23 @@ // Load results. $results = array(); + + //check which module if being use for uploads + //I'm going to make the assumption that no one uses the upload and the filefield together + + $uploadM = module_exists('upload'); + $filefielM = module_exists('filefield'); + + if($uploadM){$searchQuery = "SELECT f.*, d.data, u.nid FROM {files} f JOIN {upload} u USING(fid) INNER JOIN {search_dataset} d ON f.fid = d.sid WHERE fid = %d"; } + if($filefielM){$searchQuery = "SELECT f . * , d.data, u.nid FROM {files} f JOIN {content_type_files} u ON u.field_files_fid = f.fid INNER JOIN {search_dataset} d ON f.fid = d.sid WHERE fid = %d"; } + + + //the upload module nor the filefield module is enable + //so don't bother running the query + if($uploadM || $filefielM){ foreach ($find as $item) { // Build the node body. - $file = db_fetch_object(db_query("SELECT f.*, d.data, u.nid FROM {files} f JOIN {upload} u USING(fid) INNER JOIN {search_dataset} d ON f.fid = d.sid WHERE fid = %d", $item->sid)); + $file = db_fetch_object(db_query($searchQuery, $item->sid)); $node = node_load($file->nid); $file->absolute_path = $_SERVER['DOCUMENT_ROOT'].$base_path.$file->filepath; if (is_file($file->absolute_path)) { @@ -111,6 +125,10 @@ ); } } + } + else{ + $results = FALSE; + } return $results; } }