[Rt-commit] rt branch, 4.0/web-attachs-processing, created. rt-4.0.5-155-g9e5c0fe
? sunnavy
sunnavy at bestpractical.com
Sat May 19 05:26:42 EDT 2012
The branch, 4.0/web-attachs-processing has been created
at 9e5c0fec98d8aab502659ed8eb7312f09104b90d (commit)
- Log -----------------------------------------------------------------
commit 5eb9973aa1c9515a847117607196a53ce7c16ae4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Jan 20 14:47:22 2011 +0300
add tokens to update/create actions to distinguish attachments
Conflicts:
share/html/SelfService/Display.html
share/html/Ticket/Display.html
share/html/Ticket/Elements/AddAttachments
diff --git a/share/html/Search/Bulk.html b/share/html/Search/Bulk.html
index d39c24c..21cf046 100755
--- a/share/html/Search/Bulk.html
+++ b/share/html/Search/Bulk.html
@@ -228,10 +228,12 @@ map ( $ARGS{$_} =~ /^$/ && ( delete $ARGS{$_} ), keys %ARGS );
my (@results);
+$ARGS{'Token'} ||= $Token ||= Digest::MD5::md5_hex( rand(1024) );
+
# deal with deleting uploaded attachments
foreach my $key (keys %ARGS) {
if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{$1};
+ delete $session{'Attachments'}{ $Token }{ $1 };
}
$session{'Attachments'} = { %{$session{'Attachments'} || {}} };
}
@@ -243,15 +245,14 @@ if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
);
my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- $session{'Attachments'} = {
- %{$session{'Attachments'} || {}},
- $file_path => $attachment,
- };
+ # force session save
+ $session{'Attachments'} = $session{'Attachments'} || {};
+ $session{'Attachments'}{ $Token }{ $file_path } = $attachment;
}
# delete temporary storage entry to make WebUI clean
-unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
- delete $session{'Attachments'};
+unless (keys %{$session{'Attachments'}{ $Token }} and $ARGS{'UpdateAttach'}) {
+ delete $session{'Attachments'}{ $Token };
}
$Page ||= 1;
@@ -310,7 +311,8 @@ my $cf_add_keys;
unless ( $ARGS{'AddMoreAttach'} ) {
# Add session attachments if any to be processed by ProcessUpdateMessage
- $ARGS{'UpdateAttachments'} = $session{'Attachments'} if ( $session{'Attachments'} );
+ $ARGS{'UpdateAttachments'} = $session{'Attachments'}{ $Token }
+ if $session{'Attachments'}{ $Token };
while ( my $Ticket = $Tickets->Next ) {
next unless ( $ARGS{ "UpdateTicket" . $Ticket->Id } );
@@ -416,7 +418,7 @@ unless ( $ARGS{'AddMoreAttach'} ) {
}
# Cleanup WebUI
- delete $session{'Attachments'};
+ delete $session{'Attachments'}{ $Token };
}
my $TxnCFs = RT::CustomFields->new( $session{CurrentUser} );
@@ -425,6 +427,7 @@ $TxnCFs->LimitToGlobalOrObjectId( sort keys %queues );
</%INIT>
<%args>
+$Token => undef
$Format => undef
$Page => 1
$Rows => undef
diff --git a/share/html/SelfService/Display.html b/share/html/SelfService/Display.html
index 23c7467..3c1b217 100755
--- a/share/html/SelfService/Display.html
+++ b/share/html/SelfService/Display.html
@@ -101,18 +101,15 @@ my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
# store the uploaded attachment in session
-if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
- $session{'Attachments'} = {} unless defined $session{'Attachments'};
-
+if ( $ARGS{'Attach'} ) { # attachment?
my $attachment = MakeMIMEEntity(
AttachmentFieldName => 'Attach'
);
my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- $session{'Attachments'} = {
- %{ $session{'Attachments'} || {} },
- $file_path => $attachment,
- };
+ # force session save
+ $session{'Attachments'} = $session{'Attachments'} || {};
+ $session{'Attachments'}{ $Token }{ $file_path } = $attachment;
}
if ( defined ($id[0]) && $id[0] eq 'new' ) {
@@ -134,7 +131,7 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
( $Ticket, @results ) =
- CreateTicket( Attachments => $session{'Attachments'}, %ARGS );
+ CreateTicket( Attachments => $session{'Attachments'}{$Token}, %ARGS );
unless ( $Ticket->id ) {
$m->comp( 'Error.html', Why => join( "\n", @results ));
@@ -143,8 +140,8 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
# delete temporary storage entry to make WebUI clean
- unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
- delete $session{'Attachments'};
+ unless ( keys %{ $session{'Attachments'}{ $Token } } and $ARGS{'UpdateAttach'} ) {
+ delete $session{'Attachments'}{ $Token };
}
}
@@ -159,24 +156,24 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
if (
- $session{'Attachments'}
+ $session{'Attachments'}{ $Token }
|| ( defined $ARGS{'UpdateContent'}
&& $ARGS{'UpdateContent'} ne ''
&& $ARGS{'UpdateContent'} ne "-- \n"
. $session{'CurrentUser'}->UserObj->Signature )
)
{
- $ARGS{UpdateAttachments} = $session{'Attachments'};
+ $ARGS{UpdateAttachments} = $session{'Attachments'}{ $Token };
}
push @results, ProcessUpdateMessage(
ARGSRef => \%ARGS,
TicketObj => $Ticket
);
- delete $session{'Attachments'};
+ delete $session{'Attachments'}{ $Token };
# delete temporary storage entry to make WebUI clean
- unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
- delete $session{'Attachments'};
+ unless ( keys %{ $session{'Attachments'}{ $Token } } and $ARGS{'UpdateAttach'} ) {
+ delete $session{'Attachments'}{ $Token };
}
my @cfupdates = ProcessObjectCustomFieldUpdates(Object => $Ticket, ARGSRef => \%ARGS);
@@ -228,4 +225,5 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
<%ARGS>
$id => undef
+$Token => ''
</%ARGS>
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index fcd34b1..db69b8b 100755
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -54,6 +54,7 @@
<form action="<% RT->Config->Get('WebPath') %>/Ticket/Create.html" method="post" enctype="multipart/form-data" name="TicketCreate">
<input type="hidden" class="hidden" name="id" value="new" />
+ <input type="hidden" class="hidden" name="Token" value="<% $Token %>" />
% $m->callback( CallbackName => 'FormStart', QueueObj => $QueueObj, ARGSRef => \%ARGS );
@@ -361,10 +362,12 @@ my $ValidCFs = $m->comp(
ARGSRef => \%ARGS
);
+$ARGS{'Token'} ||= $Token ||= Digest::MD5::md5_hex( rand(1024) );
+
# deal with deleting uploaded attachments
foreach my $key (keys %ARGS) {
if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{$1};
+ delete $session{'Attachments'}{ $Token }{$1};
}
$session{'Attachments'} = { %{$session{'Attachments'} || {}} };
}
@@ -376,15 +379,13 @@ if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
);
my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- $session{'Attachments'} = {
- %{$session{'Attachments'} || {}},
- $file_path => $attachment,
- };
+ $session{'Attachments'} = $session{'Attachments'} || {};
+ $session{'Attachments'}{ $Token }{ $file_path } = $attachment;
}
# delete temporary storage entry to make WebUI clean
-unless (keys %{$session{'Attachments'}} and $ARGS{'id'} eq 'new') {
- delete $session{'Attachments'};
+unless (keys %{$session{'Attachments'}{$Token}} and $ARGS{'id'} eq 'new') {
+ delete $session{'Attachments'}{$Token};
}
my $checks_failure = 0;
@@ -447,6 +448,7 @@ PageMenu->child( details => raw_html => q[<a href="#details" onclick="return sw
</%INIT>
<%ARGS>
+$Token => undef
$DependsOn => undef
$DependedOnBy => undef
$MemberOf => undef
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index 5e84a50..b5510f5 100755
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -128,7 +128,7 @@ if ($ARGS{'id'} eq 'new') {
}
($TicketObj, @Actions) = CreateTicket(
- Attachments => delete $session{'Attachments'},
+ Attachments => delete $session{'Attachments'}{ $ARGS{'Token'} || '' },
%ARGS,
);
unless ( $TicketObj->CurrentUserHasRight('ShowTicket') ) {
@@ -160,14 +160,13 @@ if ($ARGS{'id'} eq 'new') {
ARGSRef => \%ARGS,
Actions => \@Actions);
- $ARGS{UpdateAttachments} = $session{'Attachments'};
+ $ARGS{UpdateAttachments} = delete $session{'Attachments'}{ $ARGS{'Token'} || '' };
push @Actions,
ProcessUpdateMessage(
ARGSRef => \%ARGS,
Actions => \@Actions,
TicketObj => $TicketObj,
);
- delete $session{'Attachments'};
#Process status updates
push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $TicketObj );
diff --git a/share/html/Ticket/Elements/AddAttachments b/share/html/Ticket/Elements/AddAttachments
index 0086858..e22e8bb 100644
--- a/share/html/Ticket/Elements/AddAttachments
+++ b/share/html/Ticket/Elements/AddAttachments
@@ -45,11 +45,11 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-% if (exists $session{'Attachments'}) {
+% if ( $attachments ) {
<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 ( keys %$attachments ) {
<input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
% } # end of foreach
</td>
@@ -59,3 +59,13 @@
<tr><td class="label"><&|/l&>Attach</&>:</td><td><input name="Attach" type="file" /><input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" /><input type="hidden" class="hidden" name="UpdateAttach" value="1" />
</td></tr>
% $m->callback( %ARGS, CallbackName => 'End' );
+
+<%ARGS>
+$Token => ''
+</%ARGS>
+<%INIT>
+my $attachments;
+if ( exists $session{'Attachments'}{ $Token } && keys %{ $session{'Attachments'}{ $Token } } ) {
+ $attachments = $session{'Attachments'}{ $Token };
+}
+</%INIT>
diff --git a/share/html/Ticket/ModifyAll.html b/share/html/Ticket/ModifyAll.html
index 8619cd5..7caa706 100755
--- a/share/html/Ticket/ModifyAll.html
+++ b/share/html/Ticket/ModifyAll.html
@@ -152,10 +152,12 @@ $CanRespond = 1 if ( $Ticket->CurrentUserHasRight('ReplyToTicket') or
$CanComment = 1 if ( $Ticket->CurrentUserHasRight('CommentOnTicket') or
$Ticket->CurrentUserHasRight('ModifyTicket') );
+$ARGS{'Token'} ||= $Token ||= Digest::MD5::md5_hex( rand(1024) );
+
# deal with deleting uploaded attachments
foreach my $key (keys %ARGS) {
if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{$1};
+ delete $session{'Attachments'}{$Token}{$1};
}
$session{'Attachments'} = { %{$session{'Attachments'} || {}} };
}
@@ -167,15 +169,14 @@ if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
);
my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- $session{'Attachments'} = {
- %{$session{'Attachments'} || {}},
- $file_path => $attachment,
- };
+ # force session save
+ $session{'Attachments'} = $session{'Attachments'} || {};
+ $session{'Attachments'}{ $Token }{ $file_path } = $attachment;
}
# delete temporary storage entry to make WebUI clean
-unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
- delete $session{'Attachments'};
+unless (keys %{$session{'Attachments'}{$Token}} and $ARGS{'UpdateAttach'}) {
+ delete $session{'Attachments'}{ $Token };
}
@@ -203,10 +204,11 @@ unless ($OnlySearchForPeople or $OnlySearchForGroup or $ARGS{'AddMoreAttach'} )
push @results, ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS);
# Add session attachments if any to be processed by ProcessUpdateMessage
- $ARGS{'UpdateAttachments'} = $session{'Attachments'} if ( $session{'Attachments'} );
+ $ARGS{'UpdateAttachments'} = $session{'Attachments'}{ $Token }
+ if $session{'Attachments'}{ $Token };
push @results, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef=>\%ARGS );
# Cleanup WebUI
- delete $session{'Attachments'};
+ delete $session{'Attachments'}{ $Token };
push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
@@ -227,6 +229,7 @@ unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
<%ARGS>
+$Token => undef
$OnlySearchForPeople => undef
$OnlySearchForGroup => undef
$UserField => undef
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 672d8ab..8f6a3fe 100755
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -57,6 +57,7 @@
<input type="hidden" class="hidden" name="QuoteTransaction" value="<% $ARGS{QuoteTransaction}||'' %>" />
<input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus ||''%>" />
<input type="hidden" class="hidden" name="Action" value="<% $ARGS{Action}||'' %>" />
+<input type="hidden" class="hidden" name="Token" value="<% $Token %>" />
<& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
@@ -241,11 +242,12 @@ $CanRespond = 1 if ( $TicketObj->CurrentUserHasRight('ReplyToTicket') or
$CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
$TicketObj->CurrentUserHasRight('ModifyTicket') );
+$ARGS{'Token'} ||= $Token ||= Digest::MD5::md5_hex( rand(1024) );
# deal with deleting uploaded attachments
foreach my $key (keys %ARGS) {
if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{$1};
+ delete $session{'Attachments'}{$Token}{$1};
}
$session{'Attachments'} = { %{$session{'Attachments'} || {}} };
}
@@ -257,15 +259,14 @@ if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
);
my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- $session{'Attachments'} = {
- %{$session{'Attachments'} || {}},
- $file_path => $attachment,
- };
+ # force session save
+ $session{'Attachments'} = $session{'Attachments'} || {};
+ $session{'Attachments'}{ $Token }{ $file_path } = $attachment;
}
# delete temporary storage entry to make WebUI clean
-unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
- delete $session{'Attachments'};
+unless (keys %{$session{'Attachments'}{$Token}} and $ARGS{'UpdateAttach'}) {
+ delete $session{'Attachments'}{ $Token };
}
my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
@@ -333,4 +334,5 @@ if ( !$checks_failure && !$skip_update && exists $ARGS{SubmitTicket} ) {
$id => undef
$Action => undef
$DefaultStatus => undef
+$Token => undef
</%ARGS>
commit 54ef37d35bb59a383057427b78e088d778a9f159
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jan 22 02:34:55 2011 +0300
process attachments in CreateTicket and UpdateMessage
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 8e89ce8..76bcf07 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1338,18 +1338,21 @@ sub CreateTicket {
Type => $ARGS{'ContentType'},
);
- if ( $ARGS{'Attachments'} ) {
- my $rv = $MIMEObj->make_multipart;
- $RT::Logger->error("Couldn't make multipart message")
- if !$rv || $rv !~ /^(?:DONE|ALREADY)$/;
+ my @attachments;
+ if ( my $tmp = $session{'Attachments'}{ $ARGS{'Token'} || '' } ) {
+ push @attachments, grep $_, values %$tmp;
- foreach ( values %{ $ARGS{'Attachments'} } ) {
- unless ($_) {
- $RT::Logger->error("Couldn't add empty attachemnt");
- next;
- }
- $MIMEObj->add_part($_);
- }
+ delete $session{'Attachments'}{ $ARGS{'Token'} || '' }
+ unless $ARGS{'KeepAttachments'};
+ $session{'Attachment'} = $session{'Attachment'}
+ if @attachments;
+ }
+ if ( $ARGS{'Attachments'} ) {
+ push @attachments, grep $_, values %{ $ARGS{'Attachments'} };
+ }
+ if ( @attachments ) {
+ $MIMEObj->make_multipart;
+ $MIMEObj->add_part( $_ ) foreach @attachments;
}
foreach my $argument (qw(Encrypt Sign)) {
@@ -1573,9 +1576,21 @@ sub ProcessUpdateMessage {
);
}
- if ( $args{ARGSRef}->{'UpdateAttachments'} ) {
+ my @attachments;
+ if ( my $tmp = $session{'Attachments'}{ $args{'ARGSRef'}{'Token'} || '' } ) {
+ push @attachments, grep $_, values %$tmp;
+
+ delete $session{'Attachments'}{ $args{'ARGSRef'}{'Token'} || '' }
+ unless $args{'KeepAttachments'};
+ $session{'Attachment'} = $session{'Attachment'}
+ if @attachments;
+ }
+ if ( $args{ARGSRef}{'UpdateAttachments'} ) {
+ push @attachments, grep $_, values %{ $args{ARGSRef}{'UpdateAttachments'} };
+ }
+ if ( @attachments ) {
$Message->make_multipart;
- $Message->add_part($_) foreach values %{ $args{ARGSRef}->{'UpdateAttachments'} };
+ $Message->add_part( $_ ) foreach @attachments;
}
if ( $args{ARGSRef}->{'AttachTickets'} ) {
commit 3f45ed66e8fa82e268ce91042dee479874348e0e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jan 22 02:36:38 2011 +0300
ProcessAttachments function in ::Interface::Web
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 76bcf07..8897ccd 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1677,7 +1677,36 @@ sub _ProcessUpdateMessageRecipients {
}
}
+sub ProcessAttachments {
+ my %args = (
+ ARGSRef => {},
+ Token => '',
+ @_
+ );
+
+ my $token = $args{'Token'};
+
+ my $update_session = 0;
+
+ # deal with deleting uploaded attachments
+ if ( my $del = $args{'ARGSRef'}{'DeleteAttach'} ) {
+ delete $session{'Attachments'}{ $token }{ $_ }
+ foreach ref $del? @$del : ($del);
+ $update_session = 1;
+ }
+
+ # store the uploaded attachment in session
+ if ( my $new = $args{'ARGSRef'}{'Attach'} ) { # attachment?
+ my $attachment = MakeMIMEEntity(
+ AttachmentFieldName => 'Attach'
+ );
+
+ my $file_path = Encode::decode_utf8("$new");
+ $session{'Attachments'}{ $token }{ $file_path } = $attachment;
+ }
+ $session{'Attachments'} = $session{'Attachments'} if $update_session;
+}
=head2 MakeMIMEEntity PARAMHASH
commit 70301c8d93a3654d3b67e31a0d40821376aedbc5
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jan 22 02:37:38 2011 +0300
use ProcessAttachments and shrink repeated code
Conflicts:
share/html/Search/Bulk.html
share/html/Ticket/Create.html
share/html/Ticket/Display.html
share/html/Ticket/ModifyAll.html
share/html/Ticket/Update.html
diff --git a/share/html/Search/Bulk.html b/share/html/Search/Bulk.html
index 21cf046..943e7d1 100755
--- a/share/html/Search/Bulk.html
+++ b/share/html/Search/Bulk.html
@@ -230,30 +230,7 @@ my (@results);
$ARGS{'Token'} ||= $Token ||= Digest::MD5::md5_hex( rand(1024) );
-# deal with deleting uploaded attachments
-foreach my $key (keys %ARGS) {
- if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{ $Token }{ $1 };
- }
- $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
-}
-
-# store the uploaded attachment in session
-if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
- my $attachment = MakeMIMEEntity(
- AttachmentFieldName => 'Attach'
- );
-
- my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- # force session save
- $session{'Attachments'} = $session{'Attachments'} || {};
- $session{'Attachments'}{ $Token }{ $file_path } = $attachment;
-}
-
-# delete temporary storage entry to make WebUI clean
-unless (keys %{$session{'Attachments'}{ $Token }} and $ARGS{'UpdateAttach'}) {
- delete $session{'Attachments'}{ $Token };
-}
+ProcessAttachments( ARGSRef => \%ARGS, Token => $Token );
$Page ||= 1;
@@ -310,10 +287,6 @@ my $cf_add_keys;
@$cf_add_keys = grep { /^Bulk-Add-CustomField/ } keys %ARGS;
unless ( $ARGS{'AddMoreAttach'} ) {
- # Add session attachments if any to be processed by ProcessUpdateMessage
- $ARGS{'UpdateAttachments'} = $session{'Attachments'}{ $Token }
- if $session{'Attachments'}{ $Token };
-
while ( my $Ticket = $Tickets->Next ) {
next unless ( $ARGS{ "UpdateTicket" . $Ticket->Id } );
@@ -322,9 +295,10 @@ unless ( $ARGS{'AddMoreAttach'} ) {
$queues{ $Ticket->QueueObj->Id }++;
my @updateresults = ProcessUpdateMessage(
- TicketObj => $Ticket,
- ARGSRef => \%ARGS,
- );
+ TicketObj => $Ticket,
+ ARGSRef => \%ARGS,
+ KeepAttachments => 1,
+ );
#Update the basics.
my @basicresults =
@@ -417,7 +391,6 @@ unless ( $ARGS{'AddMoreAttach'} ) {
@results = ( @results, @tempresults );
}
- # Cleanup WebUI
delete $session{'Attachments'}{ $Token };
}
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index db69b8b..5996fa3 100755
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -364,29 +364,7 @@ my $ValidCFs = $m->comp(
$ARGS{'Token'} ||= $Token ||= Digest::MD5::md5_hex( rand(1024) );
-# deal with deleting uploaded attachments
-foreach my $key (keys %ARGS) {
- if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{ $Token }{$1};
- }
- $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
-}
-
-# store the uploaded attachment in session
-if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
- my $attachment = MakeMIMEEntity(
- AttachmentFieldName => 'Attach'
- );
-
- my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- $session{'Attachments'} = $session{'Attachments'} || {};
- $session{'Attachments'}{ $Token }{ $file_path } = $attachment;
-}
-
-# delete temporary storage entry to make WebUI clean
-unless (keys %{$session{'Attachments'}{$Token}} and $ARGS{'id'} eq 'new') {
- delete $session{'Attachments'}{$Token};
-}
+ProcessAttachments( ARGSRef => \%ARGS, Token => $Token );
my $checks_failure = 0;
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index b5510f5..3b9d863 100755
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -127,10 +127,7 @@ if ($ARGS{'id'} eq 'new') {
Abort('You have no permission to create tickets in that queue.');
}
- ($TicketObj, @Actions) = CreateTicket(
- Attachments => delete $session{'Attachments'}{ $ARGS{'Token'} || '' },
- %ARGS,
- );
+ ($TicketObj, @Actions) = CreateTicket( %ARGS );
unless ( $TicketObj->CurrentUserHasRight('ShowTicket') ) {
Abort("No permission to view newly created ticket #".$TicketObj->id.".");
}
@@ -160,7 +157,6 @@ if ($ARGS{'id'} eq 'new') {
ARGSRef => \%ARGS,
Actions => \@Actions);
- $ARGS{UpdateAttachments} = delete $session{'Attachments'}{ $ARGS{'Token'} || '' };
push @Actions,
ProcessUpdateMessage(
ARGSRef => \%ARGS,
diff --git a/share/html/Ticket/Elements/AddAttachments b/share/html/Ticket/Elements/AddAttachments
index e22e8bb..4b8f32d 100644
--- a/share/html/Ticket/Elements/AddAttachments
+++ b/share/html/Ticket/Elements/AddAttachments
@@ -50,7 +50,7 @@
<td>
<&|/l&>Check box to delete</&><br />
% foreach my $attach_name ( keys %$attachments ) {
-<input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
+<input type="checkbox" class="checkbox" name="DeleteAttach" value="<% $attach_name %>" /><% $attach_name %><br />
% } # end of foreach
</td>
</tr>
diff --git a/share/html/Ticket/ModifyAll.html b/share/html/Ticket/ModifyAll.html
index 7caa706..0f2c15c 100755
--- a/share/html/Ticket/ModifyAll.html
+++ b/share/html/Ticket/ModifyAll.html
@@ -154,31 +154,7 @@ $CanComment = 1 if ( $Ticket->CurrentUserHasRight('CommentOnTicket') or
$ARGS{'Token'} ||= $Token ||= Digest::MD5::md5_hex( rand(1024) );
-# deal with deleting uploaded attachments
-foreach my $key (keys %ARGS) {
- if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{$Token}{$1};
- }
- $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
-}
-
-# store the uploaded attachment in session
-if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
- my $attachment = MakeMIMEEntity(
- AttachmentFieldName => 'Attach'
- );
-
- my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- # force session save
- $session{'Attachments'} = $session{'Attachments'} || {};
- $session{'Attachments'}{ $Token }{ $file_path } = $attachment;
-}
-
-# delete temporary storage entry to make WebUI clean
-unless (keys %{$session{'Attachments'}{$Token}} and $ARGS{'UpdateAttach'}) {
- delete $session{'Attachments'}{ $Token };
-}
-
+ProcessAttachments( ARGSRef => \%ARGS, Token => $Token );
$m->callback( TicketObj => $Ticket, ARGSRef => \%ARGS );
my @results;
@@ -202,14 +178,7 @@ unless ($OnlySearchForPeople or $OnlySearchForGroup or $ARGS{'AddMoreAttach'} )
push @results, ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS);
push @results, ProcessObjectCustomFieldUpdates( Object => $Ticket, ARGSRef => \%ARGS);
push @results, ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS);
-
- # Add session attachments if any to be processed by ProcessUpdateMessage
- $ARGS{'UpdateAttachments'} = $session{'Attachments'}{ $Token }
- if $session{'Attachments'}{ $Token };
push @results, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef=>\%ARGS );
- # Cleanup WebUI
- delete $session{'Attachments'}{ $Token };
-
push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
}
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 8f6a3fe..079f7bd 100755
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -244,30 +244,7 @@ $CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
$ARGS{'Token'} ||= $Token ||= Digest::MD5::md5_hex( rand(1024) );
-# deal with deleting uploaded attachments
-foreach my $key (keys %ARGS) {
- if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{$Token}{$1};
- }
- $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
-}
-
-# store the uploaded attachment in session
-if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
- my $attachment = MakeMIMEEntity(
- AttachmentFieldName => 'Attach'
- );
-
- my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- # force session save
- $session{'Attachments'} = $session{'Attachments'} || {};
- $session{'Attachments'}{ $Token }{ $file_path } = $attachment;
-}
-
-# delete temporary storage entry to make WebUI clean
-unless (keys %{$session{'Attachments'}{$Token}} and $ARGS{'UpdateAttach'}) {
- delete $session{'Attachments'}{ $Token };
-}
+ProcessAttachments( ARGSRef => \%ARGS, Token => $Token );
my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
$m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
commit 70bd1007a6f2715c351679422be0922583148484
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jan 22 03:15:04 2011 +0300
indent
diff --git a/share/html/SelfService/Display.html b/share/html/SelfService/Display.html
index 3c1b217..5231094 100755
--- a/share/html/SelfService/Display.html
+++ b/share/html/SelfService/Display.html
@@ -112,9 +112,7 @@ if ( $ARGS{'Attach'} ) { # attachment?
$session{'Attachments'}{ $Token }{ $file_path } = $attachment;
}
-if ( defined ($id[0]) && $id[0] eq 'new' ) {
-
- # {{{ Create a new ticket
+if ( ($id[0]||'') eq 'new' ) {
my $Queue = RT::Queue->new( $session{'CurrentUser'} );
unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
@@ -135,22 +133,22 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
unless ( $Ticket->id ) {
$m->comp( 'Error.html', Why => join( "\n", @results ));
- $m->abort();
- }
+ $m->abort();
+ }
- # delete temporary storage entry to make WebUI clean
- unless ( keys %{ $session{'Attachments'}{ $Token } } and $ARGS{'UpdateAttach'} ) {
- delete $session{'Attachments'}{ $Token };
- }
+ # delete temporary storage entry to make WebUI clean
+ unless ( keys %{ $session{'Attachments'}{ $Token } } and $ARGS{'UpdateAttach'} ) {
+ delete $session{'Attachments'}{ $Token };
+ }
+}
+else {
+ unless ( $Ticket->Load( $id[0] ) ) {
+ $m->comp( 'Error.html',
+ Why => loc( "Couldn't load ticket '[_1]'", $id ) );
+ $m->abort();
}
- else {
- unless ( $Ticket->Load( $id[0] ) ) {
- $m->comp( 'Error.html',
- Why => loc( "Couldn't load ticket '[_1]'", $id ) );
- $m->abort();
- }
my ( $code, $msg );
@@ -190,36 +188,35 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
}
- }
+}
- # This code does automatic redirection if any updates happen.
+# This code does automatic redirection if any updates happen.
- unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
- $m->comp( 'Error.html',
- Why => loc("No permission to display that ticket") );
- # XXX: Why abort? then we loose footer //ruz
- $m->abort();
- }
+unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
+ $m->comp( 'Error.html',
+ Why => loc("No permission to display that ticket") );
+ # XXX: Why abort? then we loose footer //ruz
+ $m->abort();
+}
- if (@results) {
- # We've done something, so we need to clear the decks to avoid
- # resubmission on refresh.
- # But we need to store Actions somewhere too, so we don't lose them.
- my $key = Digest::MD5::md5_hex(rand(1024));
- push @{ $session{"Actions"}->{$key} ||= [] }, @results;
- $session{'i'}++;
- RT::Interface::Web::Redirect( RT->Config->Get('WebURL') ."SelfService/Display.html?id=". $Ticket->id."&results=".$key);
- }
+if (@results) {
+ # We've done something, so we need to clear the decks to avoid
+ # resubmission on refresh.
+ # But we need to store Actions somewhere too, so we don't lose them.
+ my $key = Digest::MD5::md5_hex(rand(1024));
+ push @{ $session{"Actions"}->{$key} ||= [] }, @results;
+ $session{'i'}++;
+ RT::Interface::Web::Redirect( RT->Config->Get('WebURL') ."SelfService/Display.html?id=". $Ticket->id."&results=".$key);
+}
- my $Transactions = $Ticket->Transactions;
+my $Transactions = $Ticket->Transactions;
- my $attachments =
- $m->comp( '/Ticket/Elements/FindAttachments', Ticket => $Ticket );
+my $attachments = $m->comp( '/Ticket/Elements/FindAttachments', Ticket => $Ticket );
- my $LinkBasicsTitle = $Ticket->CurrentUserHasRight('ModifyTicket')
- || $Ticket->CurrentUserHasRight('ReplyToTicket');
- my $title_box_link = RT->Config->Get('WebPath')."/SelfService/Update.html?id=".$Ticket->Id;
- $m->callback(CallbackName => 'BeforeDisplay', Ticket => \$Ticket, ARGSRef => \%ARGS, title_box_link => \$title_box_link);
+my $LinkBasicsTitle = $Ticket->CurrentUserHasRight('ModifyTicket')
+ || $Ticket->CurrentUserHasRight('ReplyToTicket');
+my $title_box_link = RT->Config->Get('WebPath')."/SelfService/Update.html?id=".$Ticket->Id;
+$m->callback(CallbackName => 'BeforeDisplay', Ticket => \$Ticket, ARGSRef => \%ARGS, title_box_link => \$title_box_link);
</%INIT>
commit 9b1858ab55b49945a07a195a16920529c0e188b6
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jan 22 03:20:49 2011 +0300
switch SelfService/Display.html over new attachments processing
Conflicts:
share/html/SelfService/Display.html
diff --git a/share/html/SelfService/Display.html b/share/html/SelfService/Display.html
index 5231094..71a9bc9 100755
--- a/share/html/SelfService/Display.html
+++ b/share/html/SelfService/Display.html
@@ -100,17 +100,7 @@ my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
-# store the uploaded attachment in session
-if ( $ARGS{'Attach'} ) { # attachment?
- my $attachment = MakeMIMEEntity(
- AttachmentFieldName => 'Attach'
- );
-
- my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- # force session save
- $session{'Attachments'} = $session{'Attachments'} || {};
- $session{'Attachments'}{ $Token }{ $file_path } = $attachment;
-}
+ProcessAttachments( Token => $Token, ARGSRef => \%ARGS );
if ( ($id[0]||'') eq 'new' ) {
@@ -128,20 +118,12 @@ if ( ($id[0]||'') eq 'new' ) {
}
- ( $Ticket, @results ) =
- CreateTicket( Attachments => $session{'Attachments'}{$Token}, %ARGS );
+ ( $Ticket, @results ) = CreateTicket( %ARGS );
unless ( $Ticket->id ) {
$m->comp( 'Error.html', Why => join( "\n", @results ));
$m->abort();
}
-
-
- # delete temporary storage entry to make WebUI clean
- unless ( keys %{ $session{'Attachments'}{ $Token } } and $ARGS{'UpdateAttach'} ) {
- delete $session{'Attachments'}{ $Token };
- }
-
}
else {
unless ( $Ticket->Load( $id[0] ) ) {
@@ -150,44 +132,23 @@ else {
$m->abort();
}
- my ( $code, $msg );
-
-
- if (
- $session{'Attachments'}{ $Token }
- || ( defined $ARGS{'UpdateContent'}
- && $ARGS{'UpdateContent'} ne ''
- && $ARGS{'UpdateContent'} ne "-- \n"
- . $session{'CurrentUser'}->UserObj->Signature )
- )
- {
- $ARGS{UpdateAttachments} = $session{'Attachments'}{ $Token };
- }
push @results, ProcessUpdateMessage(
ARGSRef => \%ARGS,
TicketObj => $Ticket
);
- delete $session{'Attachments'}{ $Token };
-
- # delete temporary storage entry to make WebUI clean
- unless ( keys %{ $session{'Attachments'}{ $Token } } and $ARGS{'UpdateAttach'} ) {
- delete $session{'Attachments'}{ $Token };
- }
my @cfupdates = ProcessObjectCustomFieldUpdates(Object => $Ticket, ARGSRef => \%ARGS);
push (@results, @cfupdates);
-
#Update the status
if ( ( defined $ARGS{'Status'} )
and $ARGS{'Status'}
and ( $ARGS{'Status'} ne $Ticket->Status ) )
{
- ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
+ my ($code, $msg) = $Ticket->SetStatus( $ARGS{'Status'} );
push @results, "$msg";
}
-
}
# This code does automatic redirection if any updates happen.
commit 5f44f6e3fcaf40c7d511d16afc7aadf932ce3de6
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jan 22 03:26:30 2011 +0300
use may be redirect
diff --git a/share/html/SelfService/Display.html b/share/html/SelfService/Display.html
index 71a9bc9..d5de889 100755
--- a/share/html/SelfService/Display.html
+++ b/share/html/SelfService/Display.html
@@ -160,15 +160,10 @@ unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
$m->abort();
}
-if (@results) {
- # We've done something, so we need to clear the decks to avoid
- # resubmission on refresh.
- # But we need to store Actions somewhere too, so we don't lose them.
- my $key = Digest::MD5::md5_hex(rand(1024));
- push @{ $session{"Actions"}->{$key} ||= [] }, @results;
- $session{'i'}++;
- RT::Interface::Web::Redirect( RT->Config->Get('WebURL') ."SelfService/Display.html?id=". $Ticket->id."&results=".$key);
-}
+MaybeRedirectForResults(
+ Actions => \@results,
+ Arguments => { 'id' => $Ticket->id },
+);
my $Transactions = $Ticket->Transactions;
commit 086e289005acc06dc05d552917efb50c6ccd6976
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jan 22 16:05:59 2011 +0300
use Abort()
diff --git a/share/html/SelfService/Display.html b/share/html/SelfService/Display.html
index d5de889..324c93c 100755
--- a/share/html/SelfService/Display.html
+++ b/share/html/SelfService/Display.html
@@ -106,30 +106,23 @@ if ( ($id[0]||'') eq 'new' ) {
my $Queue = RT::Queue->new( $session{'CurrentUser'} );
unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
- $m->comp( 'Error.html', Why => loc('Queue not found') );
- $m->abort;
+ Abort( loc('Queue not found') );
}
unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
- $m->comp( 'Error.html',
- Why =>
- loc('You have no permission to create tickets in that queue.') );
- $m->abort;
+ Abort( loc('You have no permission to create tickets in that queue.') );
}
( $Ticket, @results ) = CreateTicket( %ARGS );
unless ( $Ticket->id ) {
- $m->comp( 'Error.html', Why => join( "\n", @results ));
- $m->abort();
+ Abort( join "\n", @results );
}
}
else {
unless ( $Ticket->Load( $id[0] ) ) {
- $m->comp( 'Error.html',
- Why => loc( "Couldn't load ticket '[_1]'", $id ) );
- $m->abort();
+ Abort( loc( "Couldn't load ticket '[_1]'", $id ) );
}
push @results, ProcessUpdateMessage(
@@ -154,10 +147,7 @@ else {
# This code does automatic redirection if any updates happen.
unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
- $m->comp( 'Error.html',
- Why => loc("No permission to display that ticket") );
- # XXX: Why abort? then we loose footer //ruz
- $m->abort();
+ Abort( loc("No permission to display that ticket") );
}
MaybeRedirectForResults(
commit 6fbd990e464a47483fdbb4bffcda4f51c6effe5a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jan 22 16:17:49 2011 +0300
process attachments in mobile UI
Conflicts:
share/html/m/ticket/create
share/html/m/ticket/reply
diff --git a/share/html/m/ticket/create b/share/html/m/ticket/create
index 6232e87..db453ee 100644
--- a/share/html/m/ticket/create
+++ b/share/html/m/ticket/create
@@ -46,6 +46,7 @@
%#
%# END BPS TAGGED BLOCK }}}
<%ARGS>
+$Token => ''
$QuoteTransaction => undef
$CloneTicket => undef
</%ARGS>
@@ -154,31 +155,9 @@ my $ValidCFs = $m->comp(
ARGSRef => \%ARGS
);
-# deal with deleting uploaded attachments
-foreach my $key (keys %ARGS) {
- if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{$1};
- }
- $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
-}
+$ARGS{'Token'} ||= $Token ||= Digest::MD5::md5_hex( rand(1024) );
-# store the uploaded attachment in session
-if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
- my $attachment = MakeMIMEEntity(
- AttachmentFieldName => 'Attach'
- );
-
- my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- $session{'Attachments'} = {
- %{$session{'Attachments'} || {}},
- $file_path => $attachment,
- };
-}
-
-# delete temporary storage entry to make WebUI clean
-unless (keys %{$session{'Attachments'}} and $ARGS{'id'} eq 'new') {
- delete $session{'Attachments'};
-}
+ProcessAttachments( ARGSRef => \%ARGS, Token => $Token );
my $checks_failure = 0;
@@ -241,6 +220,7 @@ if ((!exists $ARGS{'AddMoreAttach'}) and (defined($ARGS{'id'}) and $ARGS{'id'} e
<& /Elements/ListActions, actions => \@results &>
<form action="<% RT->Config->Get('WebPath') %>/m/ticket/create" method="post" enctype="multipart/form-data" name="TicketCreate" id="ticket-create">
<input type="hidden" class="hidden" name="id" value="new" />
+<input type="hidden" class="hidden" name="Token" value="<% $Token %>" />
% $m->callback( CallbackName => 'FormStart', QueueObj => $QueueObj, ARGSRef => \%ARGS );
% if ($gnupg_widget) {
<& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
@@ -326,13 +306,14 @@ $showrows->(
<& /Ticket/Elements/EditCustomFields, %ARGS, QueueObj => $QueueObj &>
<& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj &>
-% if (exists $session{'Attachments'}) {
+</%perl>
+% if ( my $attachments = $session{'Attachments'}{'Token'}) {
<%loc("Attached file") %>
<%loc("Check box to delete")%><br />
-% foreach my $attach_name (keys %{$session{'Attachments'}}) {
-<input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
+% foreach my $attach_name ( keys %$attachments ) {
+<input type="checkbox" class="checkbox" name="DeleteAttach" value="<% $attach_name %>" /><%$attach_name%><br />
% } # end of foreach
diff --git a/share/html/m/ticket/reply b/share/html/m/ticket/reply
index 00c8e2b..cc494bd 100644
--- a/share/html/m/ticket/reply
+++ b/share/html/m/ticket/reply
@@ -189,34 +189,9 @@ $CanRespond = 1 if ( $t->CurrentUserHasRight('ReplyToTicket') or
$CanComment = 1 if ( $t->CurrentUserHasRight('CommentOnTicket') or
$t->CurrentUserHasRight('ModifyTicket') );
+$ARGS{'Token'} ||= $Token ||= Digest::MD5::md5_hex( rand(1024) );
-# deal with deleting uploaded attachments
-foreach my $key (keys %ARGS) {
- if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{$1};
- }
- $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
-}
-
-# store the uploaded attachment in session
-if ( defined $ARGS{'Attach'} && length $ARGS{'Attach'} ) { # attachment?
- my $attachment = MakeMIMEEntity(
- AttachmentFieldName => 'Attach'
- );
-
- my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- $session{'Attachments'} = {
- %{$session{'Attachments'} || {}},
- $file_path => $attachment,
- };
-}
-
-# delete temporary storage entry to make WebUI clean
-unless ( keys %{ $session{'Attachments'} }
- && ( exists $ARGS{'AddMoreAttach'} || exists $ARGS{'SubmitTicket'} ) )
-{
- delete $session{'Attachments'};
-}
+ProcessAttachments( ARGSRef => \%ARGS, Token => $Token );
# check email addresses for RT's
{
@@ -252,6 +227,7 @@ if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
<%ARGS>
$id => undef
+$Token => ''
$Action => 'Respond'
$DefaultStatus => undef
</%ARGS>
diff --git a/share/html/m/ticket/show b/share/html/m/ticket/show
index 2b45e90..ef4acb6 100644
--- a/share/html/m/ticket/show
+++ b/share/html/m/ticket/show
@@ -69,10 +69,7 @@ if ($ARGS{'id'} eq 'new') {
Abort('You have no permission to create tickets in that queue.');
}
- ($Ticket, @Actions) = CreateTicket(
- Attachments => delete $session{'Attachments'},
- %ARGS,
- );
+ ($Ticket, @Actions) = CreateTicket( %ARGS );
unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
Abort("No permission to view newly created ticket #".$Ticket->id.".");
}
@@ -95,14 +92,12 @@ if ($ARGS{'id'} eq 'new') {
ARGSRef => \%ARGS,
Actions => \@Actions);
- $ARGS{UpdateAttachments} = $session{'Attachments'};
push @Actions,
ProcessUpdateMessage(
ARGSRef => \%ARGS,
Actions => \@Actions,
TicketObj => $Ticket,
);
- delete $session{'Attachments'};
#Process status updates
push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $Ticket );
commit 344cc6d6ccb40c6ffafc3523b6cf059e101d033a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Mar 3 12:22:53 2011 +0300
minor: don't create more keys in the session
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 8897ccd..f02d17c 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1344,7 +1344,7 @@ sub CreateTicket {
delete $session{'Attachments'}{ $ARGS{'Token'} || '' }
unless $ARGS{'KeepAttachments'};
- $session{'Attachment'} = $session{'Attachment'}
+ $session{'Attachments'} = $session{'Attachments'}
if @attachments;
}
if ( $ARGS{'Attachments'} ) {
commit 750c0534de2be2a05375fe4568551a42c4f05d87
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Mar 3 12:23:43 2011 +0300
compile correct list of attachments earlier
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index f02d17c..4c45a52 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1523,10 +1523,17 @@ sub ProcessUpdateMessage {
@_
);
- if ( $args{ARGSRef}->{'UpdateAttachments'}
- && !keys %{ $args{ARGSRef}->{'UpdateAttachments'} } )
- {
- delete $args{ARGSRef}->{'UpdateAttachments'};
+ my @attachments;
+ if ( my $tmp = $session{'Attachments'}{ $args{'ARGSRef'}{'Token'} || '' } ) {
+ push @attachments, grep $_, values %$tmp;
+
+ delete $session{'Attachments'}{ $args{'ARGSRef'}{'Token'} || '' }
+ unless $args{'KeepAttachments'};
+ $session{'Attachments'} = $session{'Attachments'}
+ if @attachments;
+ }
+ if ( $args{ARGSRef}{'UpdateAttachments'} ) {
+ push @attachments, grep $_, values %{ $args{ARGSRef}{'UpdateAttachments'} };
}
# Strip the signature
@@ -1540,7 +1547,7 @@ sub ProcessUpdateMessage {
# If, after stripping the signature, we have no message, move the
# UpdateTimeWorked into adjusted TimeWorked, so that a later
# ProcessBasics can deal -- then bail out.
- if ( not $args{ARGSRef}->{'UpdateAttachments'}
+ if ( not @attachments
and not length $args{ARGSRef}->{'UpdateContent'} )
{
if ( $args{ARGSRef}->{'UpdateTimeWorked'} ) {
@@ -1576,18 +1583,6 @@ sub ProcessUpdateMessage {
);
}
- my @attachments;
- if ( my $tmp = $session{'Attachments'}{ $args{'ARGSRef'}{'Token'} || '' } ) {
- push @attachments, grep $_, values %$tmp;
-
- delete $session{'Attachments'}{ $args{'ARGSRef'}{'Token'} || '' }
- unless $args{'KeepAttachments'};
- $session{'Attachment'} = $session{'Attachment'}
- if @attachments;
- }
- if ( $args{ARGSRef}{'UpdateAttachments'} ) {
- push @attachments, grep $_, values %{ $args{ARGSRef}{'UpdateAttachments'} };
- }
if ( @attachments ) {
$Message->make_multipart;
$Message->add_part( $_ ) foreach @attachments;
commit 6eba202da335e8d5e69594637d3b480ddae619ce
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Mar 3 12:24:47 2011 +0300
don't forget to update session when we put attachments
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 4c45a52..c96f6ee 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1699,6 +1699,8 @@ sub ProcessAttachments {
my $file_path = Encode::decode_utf8("$new");
$session{'Attachments'}{ $token }{ $file_path } = $attachment;
+
+ $update_session = 1;
}
$session{'Attachments'} = $session{'Attachments'} if $update_session;
}
commit 81f1923be2d055711b9f5073107a2d516ff0dda0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Mar 4 11:35:19 2011 +0300
pass around Token in Bulk update
diff --git a/share/html/Search/Bulk.html b/share/html/Search/Bulk.html
index 943e7d1..a201d8c 100755
--- a/share/html/Search/Bulk.html
+++ b/share/html/Search/Bulk.html
@@ -50,7 +50,7 @@
<& /Elements/ListActions, actions => \@results &>
<form method="post" action="<% RT->Config->Get('WebPath') %>/Search/Bulk.html" enctype="multipart/form-data" name="BulkUpdate" id="BulkUpdate">
-% foreach my $var (qw(Query Format OrderBy Order Rows Page SavedChartSearchId)) {
+% foreach my $var (qw(Query Format OrderBy Order Rows Page SavedChartSearchId Token)) {
<input type="hidden" class="hidden" name="<%$var%>" value="<%$ARGS{$var} || ''%>" />
%}
<& /Elements/CollectionList,
commit 8f1d570c18da09face03bb22a3ca4eb1fdf6c929
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Mar 4 11:36:00 2011 +0300
name a few forms to easier test writing
Conflicts:
share/html/Ticket/ModifyAll.html
diff --git a/share/html/SelfService/Create.html b/share/html/SelfService/Create.html
index e28ab0f..048acb7 100755
--- a/share/html/SelfService/Create.html
+++ b/share/html/SelfService/Create.html
@@ -48,7 +48,7 @@
<& Elements/Header, Title => loc("Create a ticket") &>
<& /Elements/ListActions, actions => \@results &>
-<form action="Create.html" method="post" enctype="multipart/form-data">
+<form action="Create.html" method="post" enctype="multipart/form-data" name="TicketCreate">
<input type="hidden" class="hidden" name="id" value="new" />
<table width="100%">
diff --git a/share/html/SelfService/Update.html b/share/html/SelfService/Update.html
index 6525d3d..dcdc3ab 100755
--- a/share/html/SelfService/Update.html
+++ b/share/html/SelfService/Update.html
@@ -51,7 +51,7 @@
% $m->callback(CallbackName => 'BeforeForm', %ARGS, ARGSRef => \%ARGS, Ticket => $Ticket );
-<form action="Display.html" method="post" enctype="multipart/form-data">
+<form action="Display.html" method="post" enctype="multipart/form-data" name="TicketUpdate">
<input type="hidden" class="hidden" name="UpdateType" value="response" />
<input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
<table width="100%">
commit d03a4d74921fc25a0ca85bf600c71e8877840e32
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Mar 4 11:36:52 2011 +0300
Display.html may be called from another component
diff --git a/share/html/SelfService/Display.html b/share/html/SelfService/Display.html
index 324c93c..01d4c54 100755
--- a/share/html/SelfService/Display.html
+++ b/share/html/SelfService/Display.html
@@ -151,7 +151,8 @@ unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
}
MaybeRedirectForResults(
- Actions => \@results,
+ Actions => \@results,
+ Path => '/SelfService/Display.html',
Arguments => { 'id' => $Ticket->id },
);
commit 0c4ad3f82bf1607f72ca84b1fbd0477fdd8f9510
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Mar 4 11:37:52 2011 +0300
SingleFile argument in AddAttachments for SelfService
Conflicts:
share/html/SelfService/Update.html
diff --git a/share/html/SelfService/Update.html b/share/html/SelfService/Update.html
index dcdc3ab..07c21a7 100755
--- a/share/html/SelfService/Update.html
+++ b/share/html/SelfService/Update.html
@@ -72,7 +72,7 @@
</td>
</tr>
- <& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $Ticket &>
+ <& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $Ticket, SingleFile => 1 &>
<tr><td colspan="2"><& /Ticket/Elements/EditCustomFields, TicketObj => $Ticket &></td></tr>
</table>
<& /Elements/MessageBox,
diff --git a/share/html/Ticket/Elements/AddAttachments b/share/html/Ticket/Elements/AddAttachments
index 4b8f32d..6baa684 100644
--- a/share/html/Ticket/Elements/AddAttachments
+++ b/share/html/Ticket/Elements/AddAttachments
@@ -56,12 +56,17 @@
</tr>
% } # end of if
-<tr><td class="label"><&|/l&>Attach</&>:</td><td><input name="Attach" type="file" /><input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" /><input type="hidden" class="hidden" name="UpdateAttach" value="1" />
+<tr><td class="label"><&|/l&>Attach</&>:</td><td><input name="Attach" type="file" />
+% unless ( $SingleFile ) {
+<input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" />
+% }
+<input type="hidden" class="hidden" name="UpdateAttach" value="1" />
</td></tr>
% $m->callback( %ARGS, CallbackName => 'End' );
<%ARGS>
$Token => ''
+$SingleFile => 0
</%ARGS>
<%INIT>
my $attachments;
commit 7bc717c3e27c5ea81382a3e300b8b403b2e8e2e8
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Mar 4 11:38:36 2011 +0300
pass token in a hidden field
diff --git a/share/html/Ticket/ModifyAll.html b/share/html/Ticket/ModifyAll.html
index 0f2c15c..2bfa0d6 100755
--- a/share/html/Ticket/ModifyAll.html
+++ b/share/html/Ticket/ModifyAll.html
@@ -54,6 +54,7 @@
<form method="post" action="ModifyAll.html" name="TicketModifyAll" enctype="multipart/form-data">
% $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS );
<input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
+<input type="hidden" class="hidden" name="Token" value="<% $Token %>" />
<&| /Widgets/TitleBox, title => loc('Modify ticket # [_1]', $Ticket->Id), class=>'ticket-info-basics' &>
<& Elements/EditBasics, TicketObj => $Ticket &>
commit 11ab101e9813dddc62b1998b9a694294326f14d2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Mar 4 11:39:02 2011 +0300
get rid of unint warning (self service hits the case)
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index c96f6ee..18eac1c 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1556,7 +1556,7 @@ sub ProcessUpdateMessage {
return;
}
- if ( $args{ARGSRef}->{'UpdateSubject'} eq ($args{'TicketObj'}->Subject || '') ) {
+ if ( ($args{ARGSRef}->{'UpdateSubject'}||'') eq ($args{'TicketObj'}->Subject || '') ) {
$args{ARGSRef}->{'UpdateSubject'} = undef;
}
commit 9797be49a687651501e5584257b9dde14d570b7b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Mar 4 11:39:51 2011 +0300
more tests to cover attachments uploading through the web UI
Conflicts:
t/web/attachments.t
diff --git a/t/web/attachments.t b/t/web/attachments.t
index 8c75f6c..70ca784 100644
--- a/t/web/attachments.t
+++ b/t/web/attachments.t
@@ -1,23 +1,19 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test tests => 25;
+use RT::Test tests => 134;
use constant LogoFile => $RT::MasonComponentRoot .'/NoAuth/images/bpslogo.png';
use constant FaviconFile => $RT::MasonComponentRoot .'/NoAuth/images/favicon.png';
-my ($baseurl, $m) = RT::Test->started_ok;
+my ($url, $m) = RT::Test->started_ok;
ok $m->login, 'logged in';
-my $queue = RT::Queue->new(RT->Nobody);
-my $qid = $queue->Load('General');
-ok( $qid, "Loaded General queue" );
+my $queue = RT::Test->load_or_create_queue( Name => 'General' );
+ok( $queue && $queue->id, "Loaded General queue" );
-$m->form_name('CreateTicketInQueue');
-$m->field('Queue', $qid);
-$m->submit;
-is($m->status, 200, "request successful");
-$m->content_contains("Create a new ticket", 'ticket create page');
+diag "test mobile ui";
+$m->get_ok( $url . '/m/ticket/create?Queue=' . $queue->id );
$m->form_name('TicketCreate');
$m->field('Subject', 'Attachments test');
@@ -27,8 +23,7 @@ $m->submit;
is($m->status, 200, "request successful");
$m->content_contains('Attachments test', 'we have subject on the page');
-$m->content_contains('Some content', 'and content');
-$m->content_contains('Download bpslogo.png', 'page has file name');
+$m->content_contains('bpslogo.png', 'page has file name');
$m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
$m->form_name('TicketUpdate');
@@ -42,34 +37,388 @@ $m->field('UpdateContent', 'Message');
$m->click('SubmitTicket');
is($m->status, 200, "request successful");
-$m->content_contains('Download bpslogo.png', 'page has file name');
-$m->content_contains('Download favicon.png', 'page has file name');
+$m->content_contains('bpslogo.png', 'page has file name');
+$m->content_contains('favicon.png', 'page has file name');
+diag "create a ticket in full interface";
+diag "w/o attachments";
+{
+ $m->goto_create_ticket( $queue );
+ is($m->status, 200, "request successful");
-diag "test mobile ui";
-$m->get_ok( $baseurl . '/m/ticket/create?Queue=' . $qid );
+ $m->form_name('TicketCreate');
+ $m->content_contains("Create a new ticket", 'ticket create page');
+ $m->submit;
+ is($m->status, 200, "request successful");
+}
-$m->form_name('TicketCreate');
-$m->field('Subject', 'Attachments test');
-$m->field('Attach', LogoFile);
-$m->field('Content', 'Some content');
-$m->submit;
-is($m->status, 200, "request successful");
+diag "with one attachment";
+{
+ $m->goto_create_ticket( $queue );
-$m->content_contains('Attachments test', 'we have subject on the page');
-$m->content_contains('bpslogo.png', 'page has file name');
+ $m->form_name('TicketCreate');
+ $m->field('Subject', 'Attachments test');
+ $m->field('Attach', LogoFile);
+ $m->field('Content', 'Some content');
-$m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
-$m->form_name('TicketUpdate');
-$m->field('Attach', LogoFile);
-$m->click('AddMoreAttach');
-is($m->status, 200, "request successful");
+ $m->submit;
+ is($m->status, 200, "request successful");
-$m->form_name('TicketUpdate');
-$m->field('Attach', FaviconFile);
-$m->field('UpdateContent', 'Message');
-$m->click('SubmitTicket');
-is($m->status, 200, "request successful");
+ $m->content_contains('Attachments test', 'we have subject on the page');
+ $m->content_contains('Some content', 'and content');
+ $m->content_contains('Download bpslogo.png', 'page has file name');
+}
-$m->content_contains('bpslogo.png', 'page has file name');
-$m->content_contains('favicon.png', 'page has file name');
+diag "with two attachments";
+{
+ $m->goto_create_ticket( $queue );
+
+ $m->form_name('TicketCreate');
+ $m->field('Attach', LogoFile);
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('TicketCreate');
+ $m->field('Attach', FaviconFile);
+ $m->field('Subject', 'Attachments test');
+ $m->field('Content', 'Some content');
+
+ $m->submit;
+ is($m->status, 200, "request successful");
+
+ $m->content_contains('Attachments test', 'we have subject on the page');
+ $m->content_contains('Some content', 'and content');
+ $m->content_contains('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "with one attachment, but delete one along the way";
+{
+ $m->goto_create_ticket( $queue );
+
+ $m->form_name('TicketCreate');
+ $m->field('Attach', LogoFile);
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('TicketCreate');
+ $m->field('Attach', FaviconFile);
+ $m->tick( 'DeleteAttach', LogoFile );
+ $m->field('Subject', 'Attachments test');
+ $m->field('Content', 'Some content');
+
+ $m->submit;
+ is($m->status, 200, "request successful");
+
+ $m->content_contains('Attachments test', 'we have subject on the page');
+ $m->content_contains('Some content', 'and content');
+ $m->content_lacks('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "with one attachment, but delete one along the way";
+{
+ $m->goto_create_ticket( $queue );
+
+ $m->form_name('TicketCreate');
+ $m->field('Attach', LogoFile);
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('TicketCreate');
+ $m->tick( 'DeleteAttach', LogoFile );
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('TicketCreate');
+ $m->field('Attach', FaviconFile);
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('TicketCreate');
+ $m->field('Subject', 'Attachments test');
+ $m->field('Content', 'Some content');
+
+ $m->submit;
+ is($m->status, 200, "request successful");
+
+ $m->content_contains('Attachments test', 'we have subject on the page');
+ $m->content_contains('Some content', 'and content');
+ $m->content_lacks('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "reply to a ticket in full interface";
+diag "with one attachment";
+{
+ my $ticket = RT::Test->create_ticket(
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ );
+
+ $m->goto_ticket( $ticket->id );
+ $m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
+ $m->form_name('TicketUpdate');
+ $m->field('Attach', LogoFile);
+ $m->field('UpdateContent', 'Message');
+ $m->click('SubmitTicket');
+ is($m->status, 200, "request successful");
+
+ $m->content_contains('Download bpslogo.png', 'page has file name');
+}
+
+diag "with two attachments";
+{
+ my $ticket = RT::Test->create_ticket(
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ );
+
+ $m->goto_ticket( $ticket->id );
+ $m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
+ $m->form_name('TicketUpdate');
+ $m->field('Attach', LogoFile);
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('TicketUpdate');
+ $m->field('Attach', FaviconFile);
+ $m->field('UpdateContent', 'Message');
+ $m->click('SubmitTicket');
+ is($m->status, 200, "request successful");
+
+ $m->content_contains('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "with one attachment, delete one along the way";
+{
+ my $ticket = RT::Test->create_ticket(
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ );
+
+ $m->goto_ticket( $ticket->id );
+ $m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
+ $m->form_name('TicketUpdate');
+ $m->field('Attach', LogoFile);
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('TicketUpdate');
+ $m->tick('DeleteAttach', LogoFile);
+ $m->field('Attach', FaviconFile);
+ $m->field('UpdateContent', 'Message');
+ $m->click('SubmitTicket');
+ is($m->status, 200, "request successful");
+
+ $m->content_lacks('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "jumbo interface";
+diag "with one attachment";
+{
+ my $ticket = RT::Test->create_ticket(
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ );
+
+ $m->goto_ticket( $ticket->id );
+ $m->follow_link_ok({text => 'Jumbo'}, "jumbo the ticket");
+ $m->form_name('TicketModifyAll');
+ $m->field('Attach', LogoFile);
+ $m->field('UpdateContent', 'Message');
+ $m->click('SubmitTicket');
+ is($m->status, 200, "request successful");
+
+ $m->goto_ticket( $ticket->id );
+ $m->content_contains('Download bpslogo.png', 'page has file name');
+}
+
+diag "with two attachments";
+{
+ my $ticket = RT::Test->create_ticket(
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ );
+
+ $m->goto_ticket( $ticket->id );
+ $m->follow_link_ok({text => 'Jumbo'}, "jumbo the ticket");
+ $m->form_name('TicketModifyAll');
+ $m->field('Attach', LogoFile);
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('TicketModifyAll');
+ $m->field('Attach', FaviconFile);
+ $m->field('UpdateContent', 'Message');
+ $m->click('SubmitTicket');
+ is($m->status, 200, "request successful");
+
+ $m->goto_ticket( $ticket->id );
+ $m->content_contains('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "with one attachment, delete one along the way";
+{
+ my $ticket = RT::Test->create_ticket(
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ );
+
+ $m->goto_ticket( $ticket->id );
+ $m->follow_link_ok({text => 'Jumbo'}, "jumbo the ticket");
+ $m->form_name('TicketModifyAll');
+ $m->field('Attach', LogoFile);
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('TicketModifyAll');
+ $m->tick('DeleteAttach', LogoFile);
+ $m->field('Attach', FaviconFile);
+ $m->field('UpdateContent', 'Message');
+ $m->click('SubmitTicket');
+ is($m->status, 200, "request successful");
+
+ $m->goto_ticket( $ticket->id );
+ $m->content_lacks('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "bulk update";
+diag "one attachment";
+{
+ my @tickets = RT::Test->create_tickets(
+ {
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ },
+ {},
+ {},
+ );
+ my $query = join ' OR ', map "id=$_", map $_->id, @tickets;
+ $query =~ s/ /%20/g;
+ $m->get_ok( $url . "/Search/Bulk.html?Query=$query&Rows=10" );
+
+ $m->form_name('BulkUpdate');
+ $m->field('Attach', FaviconFile);
+ $m->field('UpdateContent', 'Message');
+ $m->submit;
+ is($m->status, 200, "request successful");
+
+ foreach my $ticket ( @tickets ) {
+ $m->goto_ticket( $ticket->id );
+ $m->content_lacks('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+ }
+}
+
+diag "two attachments";
+{
+ my @tickets = RT::Test->create_tickets(
+ {
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ },
+ {},
+ {},
+ );
+ my $query = join ' OR ', map "id=$_", map $_->id, @tickets;
+ $query =~ s/ /%20/g;
+ $m->get_ok( $url . "/Search/Bulk.html?Query=$query&Rows=10" );
+
+ $m->form_name('BulkUpdate');
+ $m->field('Attach', LogoFile);
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('BulkUpdate');
+ $m->field('Attach', FaviconFile);
+ $m->field('UpdateContent', 'Message');
+ $m->submit;
+ is($m->status, 200, "request successful");
+
+ foreach my $ticket ( @tickets ) {
+ $m->goto_ticket( $ticket->id );
+ $m->content_contains('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+ }
+}
+
+diag "one attachment, delete one along the way";
+{
+ my @tickets = RT::Test->create_tickets(
+ {
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ },
+ {},
+ {},
+ );
+ my $query = join ' OR ', map "id=$_", map $_->id, @tickets;
+ $query =~ s/ /%20/g;
+ $m->get_ok( $url . "/Search/Bulk.html?Query=$query&Rows=10" );
+
+ $m->form_name('BulkUpdate');
+ $m->field('Attach', LogoFile);
+ $m->click('AddMoreAttach');
+ is($m->status, 200, "request successful");
+
+ $m->form_name('BulkUpdate');
+ $m->tick('DeleteAttach', LogoFile);
+ $m->field('Attach', FaviconFile);
+ $m->field('UpdateContent', 'Message');
+ $m->submit;
+ is($m->status, 200, "request successful");
+
+ foreach my $ticket ( @tickets ) {
+ $m->goto_ticket( $ticket->id );
+ $m->content_lacks('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+ }
+}
+
+diag "self service";
+diag "create with attachment";
+{
+ $m->get_ok( $url . "/SelfService/Create.html?Queue=". $queue->id );
+
+ $m->form_name('TicketCreate');
+ $m->field('Attach', FaviconFile);
+ $m->field('Content', 'Message');
+ ok(!$m->current_form->find_input('AddMoreAttach'), "one attachment only");
+ $m->submit;
+ is($m->status, 200, "request successful");
+
+ $m->content_contains('Download favicon.png', 'page has file name');
+}
+
+diag "update with attachment";
+{
+ my $ticket = RT::Test->create_ticket(
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ );
+
+ $m->get_ok( $url . "/SelfService/Update.html?id=". $ticket->id );
+ $m->form_name('TicketUpdate');
+ $m->field('Attach', FaviconFile);
+ $m->field('UpdateContent', 'Message');
+ ok(!$m->current_form->find_input('AddMoreAttach'), "one attachment only");
+ $m->submit;
+ is($m->status, 200, "request successful");
+
+ $m->content_contains('Download favicon.png', 'page has file name');
+}
commit e3c8054903035af0ed02255c43e1fde9fc5a52ba
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Mar 4 14:15:42 2011 +0300
test attachments uploads into several actions simultanously
Conflicts:
t/web/attachments.t
diff --git a/t/web/attachments.t b/t/web/attachments.t
index 70ca784..42d1618 100644
--- a/t/web/attachments.t
+++ b/t/web/attachments.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test tests => 134;
+use RT::Test tests => 145;
use constant LogoFile => $RT::MasonComponentRoot .'/NoAuth/images/bpslogo.png';
use constant FaviconFile => $RT::MasonComponentRoot .'/NoAuth/images/favicon.png';
@@ -422,3 +422,41 @@ diag "update with attachment";
$m->content_contains('Download favicon.png', 'page has file name');
}
+
+
+my $m2 = RT::Test::Web->new;
+ok $m2->login, 'second login';
+
+diag "update and create";
+{
+ my $ticket = RT::Test->create_ticket(
+ Queue => $queue,
+ Subject => 'Attachments test',
+ Content => 'Some content',
+ );
+
+ $m2->goto_ticket( $ticket->id );
+ $m2->follow_link_ok({text => 'Reply'}, "reply to the ticket");
+ $m2->form_name('TicketUpdate');
+ $m2->field('Attach', LogoFile);
+ $m2->click('AddMoreAttach');
+ is($m2->status, 200, "request successful");
+
+ $m->goto_create_ticket( $queue );
+
+ $m->form_name('TicketCreate');
+ $m->field('Attach', FaviconFile);
+ $m->field('Subject', 'Attachments test');
+ $m->field('Content', 'Some content');
+ $m->submit;
+ is($m->status, 200, "request successful");
+
+ $m->content_lacks('Download bpslogo.png', 'page has file name');
+ $m->content_contains('Download favicon.png', 'page has file name');
+
+ $m2->form_name('TicketUpdate');
+ $m2->click('SubmitTicket');
+ $m2->content_contains('Download bpslogo.png', 'page has file name');
+ $m2->content_lacks('Download favicon.png', 'page has no file name');
+}
+
commit 9e5c0fec98d8aab502659ed8eb7312f09104b90d
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat May 19 17:19:16 2012 +0800
allow to specify queue object in RT::Test::create_ticket, as t/web/attachments use that way
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 7d69dd6..9b28360 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -735,7 +735,7 @@ sub create_ticket {
if ($args{Queue} && $args{Queue} =~ /\D/) {
my $queue = RT::Queue->new(RT->SystemUser);
- if (my $id = $queue->Load($args{Queue}) ) {
+ if (my $id = ref $args{Queue} ? $args{Queue}->id : $queue->Load($args{Queue}) ) {
$args{Queue} = $id;
} else {
die ("Error: Invalid queue $args{Queue}");
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list