
# HG changeset patch
# User rich@hotspoons
# Date 1257995775 18000
# Node ID d6ae0305439e64159c887f8a30bc371a68c912a6
# Parent  82b4b8c736a5b8325042fd9a35ee7fa9e9fd1be7
Updated with fix

--- a/search_files_attachments.module	Wed Nov 11 22:16:08 2009 -0500
+++ b/search_files_attachments.module	Wed Nov 11 22:16:15 2009 -0500
@@ -166,17 +166,32 @@
           $realpath = realpath($file->filepath);
           if (is_file($realpath)) {
             $fileinfo = (object)pathinfo($realpath);
-            $results[] = array(
-              'link' => url($file->filepath),
-              'title' => $file->filename,
-              'user' => theme('username', $node),
-              'date' => $file->timestamp,
-              'type' => check_plain(search_files_helper_name($fileinfo->extension)),
-              'node' => $node,
-              'score' => $item->score / $total,
-              'extra' => array(l(t('Node'), "node/" . $node->nid)),
-              'snippet' => search_excerpt($keys, $file->data),
-            );
+            if(variable_get('search_files_attachments_link_nodes', FALSE)){
+              $results[] = array(
+                'link' => url('node/'.$file->nid),
+                'title' => $node->title,
+                'user' => theme('username', $node),
+                'date' => $file->timestamp,
+                'type' => check_plain(search_files_helper_name($fileinfo->extension)),
+                'node' => $node,
+                'score' => $item->score / $total,
+                'extra' => array(l(t('Download'), $file->filepath)),
+                'snippet' => search_excerpt($keys, $file->data),
+              );
+            }
+            else{
+              $results[] = array(
+                'link' => url($file->filepath),
+                'title' => $file->filename,
+                'user' => theme('username', $node),
+                'date' => $file->timestamp,
+                'type' => check_plain(search_files_helper_name($fileinfo->extension)),
+                'node' => $node,
+                'score' => $item->score / $total,
+                'extra' => array(l(t('Node'), "node/" . $node->nid)),
+                'snippet' => search_excerpt($keys, $file->data),
+              );
+            }
           }
         }
       }
@@ -273,6 +288,12 @@
     '#default_value' => variable_get('search_files_attachments_tab_disabled', FALSE),
     '#return_value' => 1,
   );
+  $form['search_files_attachments_link_nodes'] = array(
+    '#title' => t('Use node title in results and link to node instead of directly to files'),
+    '#type' => 'checkbox',
+    '#default_value' => variable_get('search_files_attachments_link_nodes', FALSE),
+    '#return_value' => 1,
+  );    
   return system_settings_form($form);
 }
 

