Merge branch 'master' of https://github.com/jgoodman/Freeside
[freeside.git] / rt / share / html / SelfService / Display.html
index 23c7467..9f51e33 100755 (executable)
@@ -2,7 +2,7 @@
 %#
 %# COPYRIGHT:
 %#
-%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
 %#                                          <sales@bestpractical.com>
 %#
 %# (Except where explicitly superseded by other copyright notices)
@@ -50,6 +50,7 @@
 % $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@results, ARGSRef => \%ARGS, Ticket => $Ticket );
 
 <& /Elements/ListActions, actions => \@results &>
+<& /Ticket/Elements/ShowUpdateStatus, Ticket => $Ticket &>
 
   <table width="100%" class="ticketsummary" >
       <tr>
@@ -100,21 +101,6 @@ 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'};
-
-    my $attachment = MakeMIMEEntity(
-        AttachmentFieldName => 'Attach'
-    );
-
-    my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
-    $session{'Attachments'} = {
-        %{ $session{'Attachments'} || {} },
-        $file_path => $attachment,
-    };
-}
-
 if ( defined ($id[0]) && $id[0] eq 'new' ) {
 
     # {{{ Create a new ticket
@@ -134,19 +120,12 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
 
 
     ( $Ticket, @results ) =
-    CreateTicket( Attachments => $session{'Attachments'}, %ARGS );
+    CreateTicket( Attachments => delete $session{'Attachments'}, %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'} } and $ARGS{'UpdateAttach'} ) {
-            delete $session{'Attachments'};
-        }
-
     }
     else {
         unless ( $Ticket->Load( $id[0] ) ) {
@@ -172,12 +151,7 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
         ARGSRef   => \%ARGS,
         TicketObj => $Ticket
     );
-            delete $session{'Attachments'};
-
-    # delete temporary storage entry to make WebUI clean
-    unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
-        delete $session{'Attachments'};
-    }
+    delete $session{'Attachments'};
 
     my @cfupdates = ProcessObjectCustomFieldUpdates(Object => $Ticket, ARGSRef => \%ARGS);
     push (@results, @cfupdates);
@@ -204,16 +178,22 @@ if ( defined ($id[0]) && $id[0] eq 'new' ) {
         $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 ( $ARGS{'MarkAsSeen'} ) {
+        $Ticket->SetAttribute(
+            Name    => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo',
+            Content => $Ticket->LastUpdated,
+        );
+        push @results, loc('Marked all messages as seen');
     }
 
+    # This code does automatic redirection if any updates happen.
+    MaybeRedirectForResults(
+        Actions   => \@results,
+        Path      => '/SelfService/Display.html',
+        Anchor    => $ARGS{'Anchor'},
+        Arguments => { id => $Ticket->id },
+    );
+
     my $Transactions = $Ticket->Transactions;
 
     my $attachments =