[Rt-commit] rt branch, 4.0/attachment-ordering, created. rt-4.0.12-12-g8dea116
Thomas Sibley
trs at bestpractical.com
Wed May 15 19:26:16 EDT 2013
The branch, 4.0/attachment-ordering has been created
at 8dea1161afae6b5822c002abe5e7e04f4cf3e993 (commit)
- Log -----------------------------------------------------------------
commit 8dea1161afae6b5822c002abe5e7e04f4cf3e993
Author: Thomas Sibley <trs at bestpractical.com>
Date: Tue May 14 16:34:59 2013 -0700
Display and add attachments in alphabetical order by name
Without any sorting, the ordering is random and determined by Perl's
internal hash key/value ordering. While preserving upload order would
probably be best for the cases touched in this commit, it would require
a more invasive or hackish change not suitable for the 4.0 series.
We already display attachments in alphabetical order in the ticket
metadata. Extend that same consistent ordering to the attachments list
during ticket create/update and when adding the attachments to the
create/update MIME entity.
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index ba7b56d..dce1117 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1754,7 +1754,7 @@ sub CreateTicket {
$RT::Logger->error("Couldn't make multipart message")
if !$rv || $rv !~ /^(?:DONE|ALREADY)$/;
- foreach ( values %{ $ARGS{'Attachments'} } ) {
+ foreach ( map $ARGS{Attachments}->{$_}, sort keys %{ $ARGS{'Attachments'} } ) {
unless ($_) {
$RT::Logger->error("Couldn't add empty attachemnt");
next;
@@ -1987,7 +1987,8 @@ sub ProcessUpdateMessage {
if ( $args{ARGSRef}->{'UpdateAttachments'} ) {
$Message->make_multipart;
- $Message->add_part($_) foreach values %{ $args{ARGSRef}->{'UpdateAttachments'} };
+ $Message->add_part($_) foreach map $args{ARGSRef}->{UpdateAttachments}{$_},
+ sort keys %{ $args{ARGSRef}->{'UpdateAttachments'} };
}
if ( $args{ARGSRef}->{'AttachTickets'} ) {
diff --git a/share/html/Ticket/Elements/AddAttachments b/share/html/Ticket/Elements/AddAttachments
index d00a021..cdf6281 100644
--- a/share/html/Ticket/Elements/AddAttachments
+++ b/share/html/Ticket/Elements/AddAttachments
@@ -49,7 +49,7 @@
<tr><td class="label"><&|/l&>Attached file</&>:</td>
<td>
<&|/l&>Check box to delete</&><br />
-% foreach my $attach_name (keys %{$session{'Attachments'}}) {
+% foreach my $attach_name (sort keys %{$session{'Attachments'}}) {
<input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
% } # end of foreach
</td>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list