[rt-commit] [svn] r461 - in rt/branches/rt-3.1: html/Ticket
html/Ticket/Elements lib/RT lib/RT/Action
jesse at fsck.com
jesse at fsck.com
Wed Mar 3 00:31:25 EST 2004
Author: jesse
Date: Wed Mar 3 00:31:24 2004
New Revision: 461
Added:
rt/branches/rt-3.1/html/Ticket/ShowEmailRecord.html
Modified:
rt/branches/rt-3.1/html/Ticket/Elements/ShowMessageHeaders
rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction
rt/branches/rt-3.1/lib/RT/Action/SendEmail.pm
rt/branches/rt-3.1/lib/RT/Attachment_Overlay.pm
rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm
rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm
Log:
Improved handling of 'EmailRecord' messages and message headers in ticket display
Modified: rt/branches/rt-3.1/html/Ticket/Elements/ShowMessageHeaders
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/ShowMessageHeaders (original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/ShowMessageHeaders Wed Mar 3 00:31:24 2004
@@ -1,4 +1,4 @@
-%# BEGIN LICENSE BLOCK
+%# BEGIN LICENSE BLOCK;
%#
%# Copyright (c) 1996-2003 Jesse Vincent <jesse at bestpractical.com>
%#
@@ -21,12 +21,45 @@
%#
%#
%# END LICENSE BLOCK
-<%$content |n%>
+% use Data::Dumper;
+<table>
+% foreach my $header (@headers) {
+% next unless ($display_headers{'_all'} || $display_headers{lc($header->{'Tag'})});
+<tr>
+<td align="right" class="message-header-key"><pre><%$header->{'Tag'}%>:</pre></td>
+<td class="message-header-value"><%$header->{'Value'}|n%></td>
+</td>
+</tr>
+% }
+</table>
<%INIT>
my $content = $Headers;
RT::Interface::Web::EscapeUTF8(\$content);
$m->comp('/Elements/Callback', content => \$content, %ARGS);
+
+
+my @lines = split (/\n/,$content);
+my $in_header = 0;
+my @headers =();
+foreach (@lines) {
+ if (/^(\S+):\s+(.*)$/) {
+ push (@headers, { Tag => $1, Value => $2} );
+ } elsif ($headers[-1]) {
+ $headers[-1]->{'Value'} .= $_;
+ } else {
+
+ push (@headers, { Tag => $_, Value => ''} );
+ }
+
+}
+
+my %display_headers;
+
+map { $display_headers{lc($_)} = 1 } @$DisplayHeaders;
+
+
</%INIT>
<%ARGS>
$Headers => undef
+$DisplayHeaders => undef
</%ARGS>
Modified: rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction (original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction Wed Mar 3 00:31:24 2004
@@ -36,35 +36,30 @@
<%PERL>
unless ($Collapsed) {
- $attachments->GotoFirstItem;
- while (my $message=$attachments->Next) {
+ $attachments->GotoFirstItem;
+ while ( my $message = $attachments->Next ) {
- my ($headers, $quoted);
- if ($ShowHeaders && ($ShowHeaders == $Ticket->Id)) {
- $headers = $message->Headers;
- } else {
- $headers = $message->NiceHeaders;
- }
- chomp $headers;
- if ($headers) {
- # localize the common headers (like 'Subject:'), too.
- eval {$headers =~ s/^([^:]+)(?=:)/loc($1)/em; } # we eval here to catch errors when 5.6 panics
- }
- # 13456 is a random # of about the biggest size we want to see inline text
- # It's here to catch anyone who hasn't updated RT_Config.pm since this
- # constant was moved out there.
- my $MAX_INLINE_BODY = $RT::MaxInlineBody || 13456;
- if ($message->ContentType =~ m{^(text/plain|message|text$)}i &&
- $message->ContentLength < $MAX_INLINE_BODY ) {
- eval {
- require Text::Quoted;
- $quoted = Text::Quoted::extract($message->Content);
- };
- if ($@) {
- $quoted = $message->Content;
+ my $quoted;
+ my $headers = $message->Headers;
+ chomp $headers;
+
+ # localize the common headers (like 'Subject:'), too.
+ eval {
+ $headers =~ s/^([^:]+)(?=:)/loc($1)/em;
+ }; # we eval here to catch errors when 5.6 panics
+
+ my $MAX_INLINE_BODY = $RT::MaxInlineBody || 13456;
+ if ( $message->ContentType =~ m{^(text/plain|message|text$)}i
+ && $message->ContentLength < $MAX_INLINE_BODY ) {
+ eval {
+ require Text::Quoted;
+ $quoted = Text::Quoted::extract( $message->Content );
+ };
+ if ($@) {
+ $quoted = $message->Content;
+ }
}
- }
-
+
</%PERL>
<TR class="<% $RowNum%2 ? 'oddline' : 'evenline'%>" >
<TD BGCOLOR="<%$bgcolor%>"> </TD>
@@ -72,10 +67,12 @@
<TD COLSPAN=3 VALIGN=TOP>
<span class="message">
<PRE>
-<& ShowMessageHeaders, Headers => $headers, Transaction => $Transaction &>
+<& ShowMessageHeaders, Headers => $headers, Transaction => $Transaction, DisplayHeaders => \@DisplayHeaders &>
</PRE>
+% if ($ShowBody) {
% if (!length($quoted) && $message->ContentType =~ m#^text/#) {
-<blockquote><i><&|/l&>Message body not shown because it is too large or is not plain text.</&><br>
+<blockquote><i>
+<&|/l&>Message body not shown because it is too large or is not plain text.</&><br>
<&|/l&>You can access it with the Download button on the right.</&></i></blockquote>
% } else {
<& ShowMessageStanza, Depth => 0, Message => $quoted, Transaction => $Transaction &>
@@ -100,12 +97,13 @@
</%PERL>
<font size=-1><A HREF="<%$AttachPath%>/<%$Transaction->Id%>/<%$message->Id%>/<%$message->Filename | u%>"><&|/l&>Download</&> <% $message->Filename|| loc('(untitled)') %></a> <% $size %></font>
% }
+% } else {
+<TD> </TD>
+% }
+% }
</TD>
</TR>
% }
-% }
-
-
<%ARGS>
$Ticket => undef
@@ -115,67 +113,103 @@
$ShowTitleBarCommands => 1
$RowNum => 1
$AttachPath => $RT::WebPath."/Ticket/Attachment"
+$ShowBody => 1
</%ARGS>
<%INIT>
-
-my ($TimeTaken, $TicketString, $bgcolor);
+my ( $TimeTaken, $TicketString, $bgcolor );
my $transdate = $Transaction->CreatedAsString();
$transdate =~ s/\s/ /g;
-if ($Transaction->Type =~ /^(Create|Correspond|Comment$)/) {
- if ($Transaction->IsInbound) {
- $bgcolor="#336699";
- }
- else {
- $bgcolor="#339999";
- }
-} elsif (($Transaction->Field =~ /^Owner$/) or
- ($Transaction->Type =~ /^(AddWatcher|DelWatcher)$/)) {
- $bgcolor="#333399";
-
-} elsif ($Transaction->Type =~ /^(AddLink|DeleteLink)$/) {
- $bgcolor="#336633";
-} elsif ($Transaction->Type =~ /^(Status|Set|Told)$/) {
- if ($Transaction->Field =~ /^(Told|Starts|Started|Due)$/) {
- $bgcolor="#663366";
- }
- else {
- $bgcolor="#993333";
- }
+if ( $Transaction->Type =~ /^(Create|Correspond|Comment$)/ ) {
+ if ( $Transaction->IsInbound ) {
+ $bgcolor = "#336699";
+ }
+ else {
+ $bgcolor = "#339999";
+ }
+}
+elsif ( ( $Transaction->Field =~ /^Owner$/ )
+ or ( $Transaction->Type =~ /^(AddWatcher|DelWatcher)$/ ) ) {
+ $bgcolor = "#333399";
+
+}
+elsif ( $Transaction->Type =~ /^(AddLink|DeleteLink)$/ ) {
+ $bgcolor = "#336633";
+}
+elsif ( $Transaction->Type =~ /^(Status|Set|Told)$/ ) {
+ if ( $Transaction->Field =~ /^(Told|Starts|Started|Due)$/ ) {
+ $bgcolor = "#663366";
+ }
+ else {
+ $bgcolor = "#993333";
+ }
}
else {
- $bgcolor="#cccccc";
+ $bgcolor = "#cccccc";
}
-if ($Ticket->Id != $Transaction->Ticket) {
- $TicketString = "Ticket ".$Transaction->Ticket .": ";
+if ( $Ticket->Id != $Transaction->Ticket ) {
+ $TicketString = "Ticket " . $Transaction->Ticket . ": ";
}
-if ($Transaction->TimeTaken > 0) {
- $TimeTaken = $Transaction->TimeTaken." min"
+if ( $Transaction->TimeTaken > 0 ) {
+ $TimeTaken = $Transaction->TimeTaken . " min";
}
my $attachments = $Transaction->Attachments;
-$attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId) );
+$attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId)
+);
-my $titlebar_commands=' ';
+my $titlebar_commands = ' ';
-# If the transaction has anything attached to it at all
-if ($Transaction->Attachments->First && $ShowTitleBarCommands) {
- if ($Transaction->TicketObj->CurrentUserHasRight('ReplyToTicket')) {
- $titlebar_commands .=
- "[<a href=\"Update.html?id=".
- $Transaction->Ticket . "&QuoteTransaction=".$Transaction->Id.
- "&Action=Respond\">". loc('Reply') ."</a>] ";
- }
- if ($Transaction->TicketObj->CurrentUserHasRight('CommentOnTicket')) {
- $titlebar_commands .=
- "[<a href=\"Update.html?id=".$Transaction->Ticket.
- "&QuoteTransaction=".$Transaction->Id.
- "&Action=Comment\">". loc('Comment') ."</a>]";
- }
+my @DisplayHeaders=qw ( _all);
+
+if ( $Transaction->Type =~ /EmailRecord$/ ) {
+ @DisplayHeaders = qw(To Cc Bcc);
+
+ $titlebar_commands .=
+ "[<a target=\"_blank\" href=\"ShowEmailRecord.html?id="
+ . $Transaction->Ticket
+ . "&Transaction="
+ . $Transaction->Id
+ . "&Attachment="
+ . ( $Transaction->Attachments->First
+ && $Transaction->Attachments->First->Id )
+
+ . '">' . loc('Show') . "</a>] ";
+ $ShowBody = 0;
}
+
+# If the transaction has anything attached to it at all
+else {
+
+ unless ( $ShowHeaders && ( $ShowHeaders == $Ticket->Id ) ) {
+ @DisplayHeaders = qw(To From RT-Send-Cc Cc Bcc Date Subject);
+ }
+
+ if ( $Transaction->Attachments->First && $ShowTitleBarCommands ) {
+ if ( $Transaction->TicketObj->CurrentUserHasRight('ReplyToTicket') ) {
+ $titlebar_commands .=
+ "[<a href=\"Update.html?id="
+ . $Transaction->Ticket
+ . "&QuoteTransaction="
+ . $Transaction->Id
+ . "&Action=Respond\">"
+ . loc('Reply')
+ . "</a>] ";
+ }
+ if ( $Transaction->TicketObj->CurrentUserHasRight('CommentOnTicket') ) {
+ $titlebar_commands .=
+ "[<a href=\"Update.html?id="
+ . $Transaction->Ticket
+ . "&QuoteTransaction="
+ . $Transaction->Id
+ . "&Action=Comment\">"
+ . loc('Comment') . "</a>]";
+ }
+ }
+}
</%INIT>
Added: rt/branches/rt-3.1/html/Ticket/ShowEmailRecord.html
==============================================================================
--- (empty file)
+++ rt/branches/rt-3.1/html/Ticket/ShowEmailRecord.html Wed Mar 3 00:31:24 2004
@@ -0,0 +1,22 @@
+<%args>
+$Attachment => undef
+$Transaction => undef
+</%ARGS>
+<%init>
+ my $AttachmentObj = new RT::Attachment($session{'CurrentUser'});
+ $AttachmentObj->Load($Attachment) || Abort(loc("Attachment '[_1]' could not be loaded", $Attachment));
+
+
+ unless ($AttachmentObj->id) {
+ Abort(loc("Attachment '[_1]' could not be loaded", $Attachment));
+ }
+ unless ($AttachmentObj->TransactionId() == $Transaction ) {
+ Abort(loc("Attachment '[_1]' could not be loaded", $Attachment));
+ }
+
+</%init>
+<pre>
+<%$AttachmentObj->Headers%>
+<hr>
+<%$AttachmentObj->Content%>
+</pre>
Modified: rt/branches/rt-3.1/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Action/SendEmail.pm (original)
+++ rt/branches/rt-3.1/lib/RT/Action/SendEmail.pm Wed Mar 3 00:31:24 2004
@@ -339,7 +339,15 @@
# XXX: TODO -> Record attachments as references to things in the attachments table, maybe.
- my ($id, $msg) = $transaction->Create( Ticket => $self->TicketObj->Id, Type => 'EmailRecord', Data => $MIMEObj->head->get('Message-Id'), MIMEObj => $MIMEObj, ActivateScrips => 0);
+ my $type;
+ if ($self->TransactionObj->Type eq 'Comment') {
+ $type = 'CommentEmailRecord';
+ } else {
+ $type = 'EmailRecord';
+ }
+
+
+ my ($id, $msg) = $transaction->Create( Ticket => $self->TicketObj->Id, Type => $type, Data => $MIMEObj->head->get('Message-Id'), MIMEObj => $MIMEObj, ActivateScrips => 0);
}
Modified: rt/branches/rt-3.1/lib/RT/Attachment_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Attachment_Overlay.pm (original)
+++ rt/branches/rt-3.1/lib/RT/Attachment_Overlay.pm Wed Mar 3 00:31:24 2004
@@ -440,7 +440,7 @@
my $hdrs = "";
my @hdrs = split(/\n/,$self->Headers);
while (my $str = shift @hdrs) {
- next unless $str =~ /^(To|From|RT-Send-Cc|Cc|Date|Subject): /i;
+ next unless $str =~ /^(To|From|RT-Send-Cc|Cc|Bcc:Date|Subject): /i;
$hdrs .= $str . "\n";
$hdrs .= shift( @hdrs ) . "\n" while ($hdrs[0] =~ /^[ \t]+/);
}
Modified: rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm (original)
+++ rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm Wed Mar 3 00:31:24 2004
@@ -3886,6 +3886,11 @@
OPERATOR => '!=',
VALUE => "Comment"
);
+ $transactions->Limit(
+ FIELD => 'Type',
+ OPERATOR => '!=',
+ VALUE => "CommentEmailRecord"
+ );
}
}
Modified: rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm (original)
+++ rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm Wed Mar 3 00:31:24 2004
@@ -435,8 +435,10 @@
my $self = shift;
#Check those ACLs
- #If it's a comment, we need to be extra special careful
- if ( $self->__Value('Type') eq 'Comment' ) {
+ #If it's a comment or a comment email record,
+ # we need to be extra special careful
+
+ if ( $self->__Value('Type') =~ /^Comment/ ) {
unless ( $self->CurrentUserHasRight('ShowTicketComments') ) {
return ( $self->loc("Permission Denied") );
}
@@ -470,9 +472,9 @@
my $self = shift;
- #Check those ACLs
- #If it's a comment, we need to be extra special careful
- if ( $self->__Value('Type') eq 'Comment' ) {
+ #If it's a comment or a comment email record,
+ # we need to be extra special careful
+ if ( $self->__Value('Type') =~ /^Comment/ ) {
unless ( $self->CurrentUserHasRight('ShowTicketComments') ) {
return ( $self->loc("Permission Denied") );
}
@@ -518,6 +520,14 @@
}
%_BriefDescriptions = (
+ CommentEmailRecord => sub {
+ my $self = shift;
+ return $self->loc("Outgoing email about a comment recorded");
+ },
+ EmailRecord => sub {
+ my $self = shift;
+ return $self->loc("Outgoing email recorded");
+ },
Correspond => sub {
my $self = shift;
return $self->loc("Correspondence added");
More information about the Rt-commit
mailing list