[Rt-commit] rt branch, records_history, updated. rt-3.8.8-135-g9a75318

Ruslan Zakirov ruz at bestpractical.com
Mon Sep 20 16:40:24 EDT 2010


The branch, records_history has been updated
       via  9a75318b839ef53c2a2ef0f25a6f3ef1f05819ef (commit)
       via  721f4c30430c091abf5857f531fe3c0ee9f24407 (commit)
       via  d61814a8bccf155eaf6d4646857d1f1bb789bbd4 (commit)
       via  a7f0e0322c8a0d4fb85769132ad0df2073fe48d8 (commit)
       via  addbce3202241e92345818a606495c9fe22bc95a (commit)
       via  7b1d297f9591b3ac3e09ecc964fcd9bd82e678fc (commit)
       via  725198c30a9130cf10abcbaf09e4d6b680a8d352 (commit)
       via  a186def11a91757d43c3685e389cc23c3d1ea0b1 (commit)
       via  125fb84b87bdfc39e9f2989a0655b1563c7cb094 (commit)
       via  7aeab3ca0283665a762180037e50110d8b852822 (commit)
      from  9cc674624c7cbb6c63e16fef60c9e240e10a4ff4 (commit)

Summary of changes:
 lib/RT/Attachment_Overlay.pm                       |    2 +
 lib/RT/Ticket_Overlay.pm                           |    4 +-
 share/html/Elements/ShowHistory                    |    8 ++-
 share/html/Elements/ShowTransaction                |    5 ++-
 share/html/Helpers/TicketHistory.html              |    4 +-
 share/html/NoAuth/css/web2/ticket.css              |   49 ++++++++++----------
 share/html/Ticket/Display.html                     |    2 +-
 share/html/Ticket/Elements/LoadTextAttachments     |    2 +-
 share/html/Ticket/Elements/ShowHistory             |   18 ++++----
 share/html/Ticket/Elements/ShowTransaction         |   13 +++--
 .../Ticket/Elements/ShowTransactionAttachments     |   39 +++++++---------
 share/html/Ticket/History.html                     |    5 +-
 12 files changed, 77 insertions(+), 74 deletions(-)

- Log -----------------------------------------------------------------
commit 7aeab3ca0283665a762180037e50110d8b852822
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jul 6 17:51:45 2010 +0400

    delete variables we don't use

diff --git a/share/html/Ticket/Elements/ShowTransactionAttachments b/share/html/Ticket/Elements/ShowTransactionAttachments
index 2d81346..216cdc0 100644
--- a/share/html/Ticket/Elements/ShowTransactionAttachments
+++ b/share/html/Ticket/Elements/ShowTransactionAttachments
@@ -98,16 +98,10 @@ $m->comp(
 $Ticket => undef
 $Transaction => undef
 $ShowHeaders => 0
-$Collapsed => undef
 $DownloadableHeaders => 1
-$ShowTitleBarCommands => 1
-$RowNum => 1
 $AttachPath => RT->Config->Get('WebPath')."/Ticket/Attachment"
-$UpdatePath => RT->Config->Get('WebPath')."/Ticket/Update.html"
-$EmailRecordPath => RT->Config->Get('WebPath')."/Ticket/ShowEmailRecord.html"
 $Attachments => undef
 $AttachmentContent => {}
-$ShowBody => 1
 $Parent => 0
 $ParentObj => undef
 $WarnUnsigned => 0

commit 125fb84b87bdfc39e9f2989a0655b1563c7cb094
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Jul 7 17:03:57 2010 +0400

    escape filename for title/alt and add it the end of URL for download

diff --git a/share/html/Ticket/Elements/ShowTransactionAttachments b/share/html/Ticket/Elements/ShowTransactionAttachments
index 216cdc0..f7c8dde 100644
--- a/share/html/Ticket/Elements/ShowTransactionAttachments
+++ b/share/html/Ticket/Elements/ShowTransactionAttachments
@@ -210,19 +210,14 @@ my $render_attachment = sub {
             return;
         }
 
-        my $filename =  $message->Filename || loc('(untitled)');
-        $m->out('<img'
-              . ' alt="'
-              . $filename
-              . '"' 
-              . ' title="'
-              . $filename
-              . '"' 
-              . ' src="'
-              . $AttachPath . '/'
-              . $Transaction->Id . '/'
-              . $message->Id
-              . '/" />' );
+        my $filename = $message->Filename || loc('(untitled)');
+        my $efilename = $m->interp->apply_escapes( $filename, 'h' );
+        $m->out(
+            qq{<img alt="$efilename" title="$efilename"}
+            . ' src="'. $AttachPath .'/'. $Transaction->Id .'/'. $message->Id .'/'
+                . ($filename? $m->interp->apply_escapes( $filename, 'uh' ) : '' ) .'"'
+            . '/>'
+        );
     }
     elsif ( $message->ContentLength > 0 ) {
         $m->out( '<p>' .

commit a186def11a91757d43c3685e389cc23c3d1ea0b1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Jul 7 17:19:13 2010 +0400

    announce record type as CSS class on history wrapping div

diff --git a/share/html/Elements/ShowHistory b/share/html/Elements/ShowHistory
index e75f2fc..aa189d4 100644
--- a/share/html/Elements/ShowHistory
+++ b/share/html/Elements/ShowHistory
@@ -67,7 +67,7 @@ if ( $ShowDisplayModes or $ShowTitle ) {
         }
     }
 </%perl>
-<div class="history">
+<div class="history <% lc $record_type %>">
 <& /Widgets/TitleBoxStart,
     title => $ShowTitle ? loc('History') : '&nbsp;',
     titleright_raw => $titleright,
@@ -157,6 +157,8 @@ my %attachment_content = map { $_->id => $_ }
         $ARGS{ $arg } = $request_path . $path;
     }
 }
+
+my $record_type = $Object->RecordType;
 </%INIT>
 <%ARGS>
 $Object

commit 725198c30a9130cf10abcbaf09e4d6b680a8d352
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Jul 7 17:21:38 2010 +0400

    use <record type>-<id>-history id for history wrapper

diff --git a/share/html/Elements/ShowHistory b/share/html/Elements/ShowHistory
index aa189d4..5cd3877 100644
--- a/share/html/Elements/ShowHistory
+++ b/share/html/Elements/ShowHistory
@@ -74,7 +74,7 @@ if ( $ShowDisplayModes or $ShowTitle ) {
 &>
 % }
 
-<div id="ticket-history">
+<div id="<% lc $record_type %>-<% $Object->id %>-history">
 <%perl>
 my $i = 1;
 while ( my $Transaction = $Transactions->Next ) {

commit 7b1d297f9591b3ac3e09ecc964fcd9bd82e678fc
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Jul 7 17:25:26 2010 +0400

    move <div class="history <% lc $record_type %>"> out of if clause

diff --git a/share/html/Elements/ShowHistory b/share/html/Elements/ShowHistory
index 5cd3877..3730119 100644
--- a/share/html/Elements/ShowHistory
+++ b/share/html/Elements/ShowHistory
@@ -45,6 +45,7 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
+<div class="history <% lc $record_type %>">
 <%perl>
 if ( $ShowDisplayModes or $ShowTitle ) {
     my $titleright = '';
@@ -67,7 +68,6 @@ if ( $ShowDisplayModes or $ShowTitle ) {
         }
     }
 </%perl>
-<div class="history <% lc $record_type %>">
 <& /Widgets/TitleBoxStart,
     title => $ShowTitle ? loc('History') : '&nbsp;',
     titleright_raw => $titleright,
@@ -118,8 +118,8 @@ while ( my $Transaction = $Transactions->Next ) {
 </div>
 % if ($ShowDisplayModes or $ShowTitle) {
 <& /Widgets/TitleBoxEnd &>
-</div>
 % }
+</div>
 <%INIT>
 my $Transactions = $Object->Transactions;
 

commit addbce3202241e92345818a606495c9fe22bc95a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sun Sep 19 04:39:15 2010 +0400

    fix RT::Ticket->Attachments SQL query

diff --git a/lib/RT/Ticket_Overlay.pm b/lib/RT/Ticket_Overlay.pm
index 470f2fb..2a16fa5 100755
--- a/lib/RT/Ticket_Overlay.pm
+++ b/lib/RT/Ticket_Overlay.pm
@@ -3596,9 +3596,9 @@ sub Attachments {
     );
     my $ticket_alias = $res->Join(
         ALIAS1 => $txn_alias,
-        FIELD1 => 'id',
+        FIELD1 => 'ObjectId',
         TABLE2 => 'Tickets',
-        FIELD2 => 'EffectiveId',
+        FIELD2 => 'id',
     );
     $res->Limit(
         ALIAS => $ticket_alias,

commit a7f0e0322c8a0d4fb85769132ad0df2073fe48d8
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sun Sep 19 04:40:31 2010 +0400

    return error asap from RT::Attachment->Create

diff --git a/lib/RT/Attachment_Overlay.pm b/lib/RT/Attachment_Overlay.pm
index e3c1b9c..8c60185 100644
--- a/lib/RT/Attachment_Overlay.pm
+++ b/lib/RT/Attachment_Overlay.pm
@@ -154,6 +154,7 @@ sub Create {
 
         unless ($id) {
             $RT::Logger->crit("Attachment insert failed - ". $RT::Handle->dbh->errstr);
+            return ($id);
         }
 
         foreach my $part ( $Attachment->parts ) {
@@ -165,6 +166,7 @@ sub Create {
             );
             unless ($id) {
                 $RT::Logger->crit("Attachment insert failed: ". $RT::Handle->dbh->errstr);
+                return ($id);
             }
         }
         return ($id);

commit d61814a8bccf155eaf6d4646857d1f1bb789bbd4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Sep 20 03:00:45 2010 +0400

    use new Attachments retrieving API instead of comps

diff --git a/share/html/Helpers/TicketHistory.html b/share/html/Helpers/TicketHistory.html
index a2531aa..9a486ca 100644
--- a/share/html/Helpers/TicketHistory.html
+++ b/share/html/Helpers/TicketHistory.html
@@ -52,8 +52,8 @@ $id
 my $TicketObj = RT::Ticket->new($session{'CurrentUser'});
 $TicketObj->Load($id);
 
-my $attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $TicketObj);
-my $attachment_content = $m->comp('/Ticket/Elements/LoadTextAttachments', Ticket => $TicketObj);
+my $attachments = $TicketObj->Attachments;
+my $attachment_content = $TicketObj->TextAttachments;
 
 $m->comp('/Ticket/Elements/ShowHistory',
     Ticket => $TicketObj, 
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index b4d23f4..c647546 100755
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -201,7 +201,7 @@ if (@Actions) {
 }
 
 my $attachments = $m->comp('Elements/FindAttachments', Ticket => $TicketObj, Tickets => $Tickets);
-my $attachment_content = $m->comp('Elements/LoadTextAttachments', Ticket => $TicketObj);
+my $attachment_content = $TicketObj->TextAttachments;
 
 my %link_rel;
 if (defined $session{'tickets'} and ($ARGS{'Query'} or $session{'CurrentSearchHash'}->{'Query'})) {
diff --git a/share/html/Ticket/Elements/LoadTextAttachments b/share/html/Ticket/Elements/LoadTextAttachments
index 4b1e68c..a508025 100644
--- a/share/html/Ticket/Elements/LoadTextAttachments
+++ b/share/html/Ticket/Elements/LoadTextAttachments
@@ -47,7 +47,7 @@
 %# END BPS TAGGED BLOCK }}}
 <%INIT>
 
-# DON'T USE IT. it's here for backwards
+# DON'T USE IT. it's here for backwards compatibility
 
 return $Ticket->TextAttachments;
 </%INIT>
diff --git a/share/html/Ticket/Elements/ShowHistory b/share/html/Ticket/Elements/ShowHistory
index f8c7101..887832d 100755
--- a/share/html/Ticket/Elements/ShowHistory
+++ b/share/html/Ticket/Elements/ShowHistory
@@ -143,9 +143,7 @@ $Transactions->OrderByCols(
 $Attachments ||= $m->comp('/Ticket/Elements/FindAttachments',
     Ticket => $Ticket, Tickets => $Tickets,
 );
-$AttachmentContent ||= $m->comp('/Ticket/Elements/LoadTextAttachments',
-    Ticket => $Ticket
-);
+$AttachmentContent ||= $Ticket->TextAttachments;
 
 my %attachments;
 push @{ $attachments{ $_->TransactionId } ||= [] }, $_
diff --git a/share/html/Ticket/History.html b/share/html/Ticket/History.html
index 3e9d143..d45986e 100755
--- a/share/html/Ticket/History.html
+++ b/share/html/Ticket/History.html
@@ -79,9 +79,8 @@ unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
     Abort("No permission to view ticket");
 }
 
-my $attachments = $m->comp('Elements/FindAttachments', Ticket => $Ticket);
-my $attachment_content = $m->comp('Elements/LoadTextAttachments', Ticket =>
-$Ticket);
+my $attachments = $Ticket->Attachments;
+my $attachment_content = $Ticket->TextAttachments;
 
 
 </%INIT>

commit 721f4c30430c091abf5857f531fe3c0ee9f24407
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Sep 21 00:37:30 2010 +0400

    make CSS classes ticket-agnostic

diff --git a/share/html/Elements/ShowHistory b/share/html/Elements/ShowHistory
index 3730119..2fe99f8 100644
--- a/share/html/Elements/ShowHistory
+++ b/share/html/Elements/ShowHistory
@@ -74,7 +74,7 @@ if ( $ShowDisplayModes or $ShowTitle ) {
 &>
 % }
 
-<div id="<% lc $record_type %>-<% $Object->id %>-history">
+<div id="<% lc $record_type %>-<% $Object->id %>-history" class="history-container">
 <%perl>
 my $i = 1;
 while ( my $Transaction = $Transactions->Next ) {
diff --git a/share/html/NoAuth/css/web2/ticket.css b/share/html/NoAuth/css/web2/ticket.css
index 78477e0..b8149bb 100644
--- a/share/html/NoAuth/css/web2/ticket.css
+++ b/share/html/NoAuth/css/web2/ticket.css
@@ -45,17 +45,16 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
-div#ticket-history div.ticket-transaction {
+div.history div.transaction {
  border-top: 1px solid #ccc;
  padding-bottom: 0.25em;
-
 }
 
-div#ticket-history div.odd {
+div.history div.odd {
  background-color: #fff;
 }
 
-div#ticket-history {
+div.history-container {
 
  margin-top: 0.75em;
  border-left: 1px solid #ccc;
@@ -65,7 +64,7 @@ div#ticket-history {
 
 }
 
-.ticket-transaction div.metadata span.actions {
+.transaction div.metadata span.actions {
  position: absolute;
  right: 2.3em;
  padding: 0em;
@@ -79,7 +78,7 @@ div#ticket-history {
  white-space: nowrap;
 }
 
-.ticket-transaction div.metadata  span.type {
+.transaction div.metadata  span.type {
  text-align: center;
  float: left;
  margin: 0.25em 0.70em 0.25em 0.25em;
@@ -92,26 +91,26 @@ div#ticket-history {
  -webkit-border-bottom-right-radius: 0.25em;
 }
 
-div#ticket-history span.type a {
+.transaction div.metadata span.type a {
  color: #fff;
 }
 
 
-div#ticket-history span.date {
+.transaction div.metadata span.date {
  width: 10em;
 }
 
 
-div#ticket-history span.description {
+.transaction div.metadata span.description {
  margin-left: 1em;
  font-weight: bold;
 }
 
-div#ticket-history span.time-taken {
+.transaction div.metadata span.time-taken {
  margin-left: 1em;
 }
 
-div#ticket-history div.content {
+.transaction div.content {
  padding-right: 1em;
  padding-bottom: 0.7em;
  font-size: 1.1em;
@@ -123,7 +122,7 @@ div#ticket-history div.content {
  font-family: monospace;
 }
 
-.ticket-transaction .messagebody {
+.transaction .messagebody {
  font-size: 1em;
  padding-left: 1em;
  margin-top: 0.5em;
@@ -135,11 +134,11 @@ div#ticket-history div.content {
  clear: left;
 }
 
-.ticket-transaction .messagebody img {
+.transaction .messagebody img {
  max-width: 100%;
 }
 
-div#ticket-history div.downloadattachment {
+div.history div.downloadattachment {
 float: right;
 clear: both;
 font-size: 0.9em;
@@ -157,20 +156,20 @@ margin-top: 0.5em;
 
 }
 
-div#ticket-history div.downloadattachment .downloadcontenttype{
+div.history div.downloadattachment .downloadcontenttype {
 color: #666;
 padding-right:0.25em;
 }
 
 
-div#ticket-history .message-header-key {
+div.history .message-header-key {
   width: 7em;
   font-weight: bold;
   color: #666;
 }
 
 
-div#ticket-history .messagebody .messagebody{
+div.history .messagebody .messagebody{
  font-size: 1em;
  padding: 0; 
  border: 0;
@@ -179,14 +178,14 @@ div#ticket-history .messagebody .messagebody{
 
 
 
-.ticket-transaction.basics .type { background: #b32; }
-.ticket-transaction.cfs .type { background: #b32; }
-.ticket-transaction.people .type { background: #48c; }
-.ticket-transaction.links .type { background: #316531; }
-.ticket-transaction.dates .type { background: #633063; }
-.ticket-transaction.message .type { background: #069; }
-.ticket-transaction.reminders .type { background: #369; }
-.ticket-transaction.other .type { background: #abc; }
+.transaction.basics .type { background: #b32; }
+.transaction.cfs .type { background: #b32; }
+.transaction.people .type { background: #48c; }
+.transaction.links .type { background: #316531; }
+.transaction.dates .type { background: #633063; }
+.transaction.message .type { background: #069; }
+.transaction.reminders .type { background: #369; }
+.transaction.other .type { background: #abc; }
 
 
 
diff --git a/share/html/Ticket/Elements/ShowHistory b/share/html/Ticket/Elements/ShowHistory
index 887832d..6e6a19b 100755
--- a/share/html/Ticket/Elements/ShowHistory
+++ b/share/html/Ticket/Elements/ShowHistory
@@ -45,6 +45,7 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
+<div class="history ticket">
 <%doc>
 #   This is (ab)used in Admin/(Users|Groups)/History.html and should probably
 #   be generalized at some point.
@@ -73,11 +74,10 @@ if ( $ShowDisplayModes or $ShowTitle ) {
         }
     }
 </%perl>
-<div class="history">
 <& /Widgets/TitleBoxStart, title => $title, titleright_raw => $titleright &>
 % }
 
-<div id="ticket-history">
+<div id="ticket-<% $Ticket->id %>-history" class="history-container">
 <%perl>
 my $i = 1;
 while ( my $Transaction = $Transactions->Next ) {
@@ -121,8 +121,8 @@ while ( my $Transaction = $Transactions->Next ) {
 </div>
 % if ($ShowDisplayModes or $ShowTitle) {
 <& /Widgets/TitleBoxEnd &>
-</div>
 % }
+</div>
 <%INIT>
 my $Transactions = new RT::Transactions($session{'CurrentUser'});
 if ( $Tickets ) {
diff --git a/share/html/Ticket/Elements/ShowTransaction b/share/html/Ticket/Elements/ShowTransaction
index 6ccbb0c..4ceacf1 100755
--- a/share/html/Ticket/Elements/ShowTransaction
+++ b/share/html/Ticket/Elements/ShowTransaction
@@ -45,10 +45,10 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
-<div class="ticket-transaction <% $type_class %> <% $RowNum % 2 ? 'odd' : 'even' %>">
+<div class="transaction <% $type_class %> <% $RowNum % 2 ? 'odd' : 'even' %>">
 % $m->callback( titlebar_cmd => \$titlebar_commands, Transaction => $Transaction, %ARGS, CallbackName => 'ModifyDisplay' );
 
-<div class="ticket-transaction">
+<div class="transaction">
 % $m->callback( titlebar_cmd => \$titlebar_commands, Transaction => $Transaction, %ARGS, CallbackName => 'ModifyCommand' );
   <div class="metadata">
     <span class="type">

commit 9a75318b839ef53c2a2ef0f25a6f3ef1f05819ef
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Sep 21 00:42:31 2010 +0400

    organize pre-fetched attachments like we need them later

diff --git a/share/html/Elements/ShowTransaction b/share/html/Elements/ShowTransaction
index de5dda1..d180b58 100644
--- a/share/html/Elements/ShowTransaction
+++ b/share/html/Elements/ShowTransaction
@@ -130,6 +130,8 @@ $time = loc('[quant,_1,min,min]', $Transaction->TimeTaken)
     if $Transaction->TimeTaken;
 
 unless ( $Attachments ) { 
+    $ARGS{'Attachments'} = $Attachments = {};
+
     my $attachments = $Transaction->Attachments;
     $attachments->Columns( qw(
         Id TransactionId Parent MessageId
@@ -137,7 +139,8 @@ unless ( $Attachments ) {
         ContentEncoding ContentType
         Creator Created
     ) );
-    $ARGS{'Attachments'} = $Attachments = $attachments->ItemsArrayRef;
+    push @{ $Attachments->{ $_->Parent || 0 } ||= [] }, $_
+        foreach @{ $attachments->ItemsArrayRef };
 }
 
 my @actions = ();
diff --git a/share/html/Ticket/Elements/ShowHistory b/share/html/Ticket/Elements/ShowHistory
index 6e6a19b..bf511e8 100755
--- a/share/html/Ticket/Elements/ShowHistory
+++ b/share/html/Ticket/Elements/ShowHistory
@@ -105,7 +105,7 @@ while ( my $Transaction = $Transactions->Next ) {
         Transaction       => $Transaction,
         ShowHeaders       => $ShowHeaders,
         RowNum            => $i,
-        Attachments       => $attachments{ $Transaction->id } || [],
+        Attachments       => $attachments{ $Transaction->id } || {},
         AttachmentContent => \%attachment_content,
         LastTransaction   => $IsLastTransaction
     );
@@ -146,8 +146,10 @@ $Attachments ||= $m->comp('/Ticket/Elements/FindAttachments',
 $AttachmentContent ||= $Ticket->TextAttachments;
 
 my %attachments;
-push @{ $attachments{ $_->TransactionId } ||= [] }, $_
-    foreach @{ $Attachments->ItemsArrayRef };
+foreach ( @{ $Attachments->ItemsArrayRef } ) {
+    my $tmp = $attachments{ $_->TransactionId } ||= {};
+    push @{ $tmp->{ $_->Parent || 0 } ||= [] }, $_;
+}
 my %attachment_content = map { $_->id => $_ }
     @{ $AttachmentContent->ItemsArrayRef };
 
diff --git a/share/html/Ticket/Elements/ShowTransaction b/share/html/Ticket/Elements/ShowTransaction
index 4ceacf1..1fcf99e 100755
--- a/share/html/Ticket/Elements/ShowTransaction
+++ b/share/html/Ticket/Elements/ShowTransaction
@@ -154,7 +154,10 @@ $TimeTaken = $Transaction->TimeTaken . " min"
 unless ($Attachments) { 
     my $attachments = $Transaction->Attachments;
     $attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId) );
-    $ARGS{'Attachments'} = $Attachments = $attachments->ItemsArrayRef();
+    $ARGS{'Attachments'} = $Attachments = {};
+
+    push @{ $Attachments->{ $_->Parent } ||= [] }, $_
+        foreach $attachments->ItemsArrayRef();
 }
 my $titlebar_commands = '';
 
@@ -166,7 +169,7 @@ if ( $type =~ /EmailRecord$/ ) {
       . "&Transaction="
       . $Transaction->Id
       . "&Attachment="
-      . ( $Attachments->[0] && $Attachments->[0]->id )
+      . ( $Attachments->{0}[0] && $Attachments->{0}[0]->id )
       . '">' . loc('Show') . "</a>]&nbsp;";
     $ShowBody = 0;
 }
@@ -175,7 +178,7 @@ if ( $type =~ /EmailRecord$/ ) {
 # If the transaction has anything attached to it at all
 else {
 
-    if ( $Attachments->[0] && $ShowTitleBarCommands ) {
+    if ( keys %$Attachments && $ShowTitleBarCommands ) {
         my $ticket = $Transaction->TicketObj;
         my $can_modify = $ticket->CurrentUserHasRight('ModifyTicket');
         if ( $can_modify || $ticket->CurrentUserHasRight('ReplyToTicket') ) {
diff --git a/share/html/Ticket/Elements/ShowTransactionAttachments b/share/html/Ticket/Elements/ShowTransactionAttachments
index f7c8dde..3ea1bb7 100644
--- a/share/html/Ticket/Elements/ShowTransactionAttachments
+++ b/share/html/Ticket/Elements/ShowTransactionAttachments
@@ -48,7 +48,7 @@
 <%PERL>
 # Find all the attachments which have parent $Parent
 # For each of these attachments
-foreach my $message ( grep $_->__Value('Parent') == $Parent, @$Attachments ) {
+foreach my $message ( @{ $Attachments->{ $Parent || 0 } || [] } ) {
 
     if (RT->Config->Get('GnuPG')->{'Enable'}) {
         $m->comp( 'ShowGnuPGStatus', Attachment => $message, WarnUnsigned => $WarnUnsigned );
@@ -67,7 +67,13 @@ foreach my $message ( grep $_->__Value('Parent') == $Parent, @$Attachments ) {
  / <a href="<% $AttachPath %>/WithHeaders/<% $message->Id %>"><% loc('with headers') %></a>
 % }
 
-% $m->callback(CallbackName => 'AfterDownloadLinks', ARGSRef => \%ARGS, Ticket => $Ticket, Transaction => $Transaction, Attachment => $message);
+% $m->callback(
+%     CallbackName => 'AfterDownloadLinks',
+%     ARGSRef => \%ARGS,
+%     Ticket => $Ticket,
+%     Transaction => $Transaction,
+%     Attachment => $message,
+% );
 
 <br />
 <span class="downloadcontenttype"><% $message->ContentType %> <% $message->FriendlyContentLength %></span>
@@ -75,7 +81,7 @@ foreach my $message ( grep $_->__Value('Parent') == $Parent, @$Attachments ) {
 %   }
 
 %# If there is sub-messages, open a dedicated div
-% if ( scalar ( grep $_->__Value('Parent') == $message->id, @$Attachments ) ) {
+% if ( $Attachments->{ $message->id } ) {
 <div class="messageattachments">
 % } else {
 <div class="messagebody">

-----------------------------------------------------------------------


More information about the Rt-commit mailing list