Here's a patch I use to prevent content searches from searching named attachments (uploaded files). This patch is to 3.6.1, but I haven't tested it much.

I create a modified version of $RTHOME/lib/RT/Tickets_Overlay.pm in $RTHOME/local/lib/RT/.

This patch is contingent on a configuration variable, so the following has to be added to RT_SiteConfig.pm:

# If $DontSearchFileAttachments is set to a true value, then named # attached files are not searched. Although this is usually what # users expect, it is not the default.

Set($DontSearchFileAttachments, 'true');

Here's the patch:

--- old/Tickets_Overlay.pm      2006-07-18 17:51:35.000000000 -0400
+++ new/Tickets_Overlay.pm      2006-10-23 20:14:39.000000000 -0400
@@ -679,14 +679,36 @@
    $self->_OpenParen;

    #Search for the right field
-    $self->_SQLLimit(
-        ALIAS         => $self->{_sql_trattachalias},
-        FIELD         => $field,
-        OPERATOR      => $op,
-        VALUE         => $value,
-        CASESENSITIVE => 0,
-        @rest
-    );
+    if ($field eq 'Content' and $RT::DontSearchFileAttachments) {
+       $self->_SQLLimit(
+                       ALIAS         => $self->{_sql_trattachalias},
+                       FIELD         => 'Filename',
+                       OPERATOR      => 'IS',
+                       VALUE         => 'NULL',
+                       SUBCLAUSE     => 'contentquery',
+                       ENTRYAGGREGATOR => 'AND',
+                      );
+       $self->_SQLLimit(
+                       ALIAS         => $self->{_sql_trattachalias},
+                       FIELD         => $field,
+                       OPERATOR      => $op,
+                       VALUE         => $value,
+                       CASESENSITIVE => 0,
+                       @rest,
+                       ENTRYAGGREGATOR => 'AND',
+                       SUBCLAUSE     => 'contentquery',
+                      );
+    } else {
+       $self->_SQLLimit(
+                       ALIAS         => $self->{_sql_trattachalias},
+                       FIELD         => $field,
+                       OPERATOR      => $op,
+                       VALUE         => $value,
+                       CASESENSITIVE => 0,
+                       ENTRYAGGREGATOR => 'AND',
+                       @rest
+                      );
+    }

    $self->_SQLJoin(
        ALIAS1 => $self->{_sql_trattachalias},

_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. Buy a copy at http://rtbook.bestpractical.com

Reply via email to