[Rt-devel] A patch to suppress inline display of uploaded text
files & speed up searching
Kevin Murphy
murphy at genome.chop.edu
Thu Jun 29 15:48:58 EDT 2006
Here's a patch to add two vaguely related features:
# If $SuppressInlineTextFiles is set to a true value, then
attached,
# named text files are prevented from being displayed in-line in
a
# ticket display. Although this is usually what users expect, it
is
# not the
default.
Set($SuppressInlineTextFiles, undef);
# 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, undef);
- - -
The attached patch is to 3.6.0 and affects:
etc/RT_Config.pm.in
html/Ticket/Elements/LoadTextAttachments
html/Ticket/Elements/ShowTransactionAttachments
lib/RT/Tickets_Overlay.pm
I will admit that I need a little help with my change to
LoadTextAttachments -- it doesn't seem to have any practical effect
unless the ShowTransactionAttachments change is also applied. But it
seems harmless.
I'm submitting these because I really like these patches, and I'm
getting tired of re-applying them when I upgrade RT ;-)
-Kevin Murphy
-------------- next part --------------
--- rt-3.6.0/etc/RT_Config.pm.in 2006-05-25 18:12:05.000000000 -0400
+++ rt-3.6.0-patched/etc/RT_Config.pm.in 2006-06-29 13:49:50.000000000 -0400
@@ -461,6 +461,19 @@
'<small>__LastUpdatedRelative__</small>',
'<small>__TimeLeft__</small>'});
+# If $SuppressInlineTextFiles is set to a true value, then uploaded
+# text files (text-type attachments with file names) are prevented
+# from being displayed in-line in a ticket display. This is often
+# what users expect, but the default value is false.
+
+Set($SuppressInlineTextFiles, undef);
+
+# If $DontSearchFileAttachments is set to a true value, then uploaded
+# files (attachments with file names) are not searched. This is often
+# what users expect, but the default value is false.
+
+Set($DontSearchFileAttachments, undef);
+
# }}}
--- rt-3.6.0/html/Ticket/Elements/LoadTextAttachments 2005-02-02 11:32:49.000000000 -0500
+++ rt-3.6.0-patched/html/Ticket/Elements/LoadTextAttachments 2006-06-29 13:52:48.000000000 -0400
@@ -80,8 +80,10 @@
$attachments->Limit ( FIELD => 'ContentType', OPERATOR => '=', VALUE => 'text/plain');
$attachments->Limit ( FIELD => 'ContentType', OPERATOR => 'STARTSWITH', VALUE => 'message/');
$attachments->Limit ( FIELD => 'ContentType', OPERATOR => '=', VALUE => 'text');
-
+ if ($RT::SuppressInlineTextFiles) {
+ $attachments->Limit ( FIELD => 'Filename', OPERATOR => 'IS', VALUE => 'NULL');
+ }
}
return ($attachments);
</%INIT>
--- rt-3.6.0/html/Ticket/Elements/ShowTransactionAttachments 2006-01-11 22:04:46.000000000 -0500
+++ rt-3.6.0-patched/html/Ticket/Elements/ShowTransactionAttachments 2006-06-29 13:53:09.000000000 -0400
@@ -95,7 +95,8 @@
# If it's text
if ( $message->ContentType =~ m{^(text|message)}i
+ && !($RT::SuppressInlineTextFiles && $message->Filename)
&& $message->ContentLength <= $RT::MaxInlineBody )
{
--- rt-3.6.0/lib/RT/Tickets_Overlay.pm 2006-05-25 21:15:05.000000000 -0400
+++ rt-3.6.0-patched/lib/RT/Tickets_Overlay.pm 2006-06-29 13:53:35.000000000 -0400
@@ -684,14 +684,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},
More information about the Rt-devel
mailing list