diff options
Diffstat (limited to 'rt/share/html/Ticket/Display.html')
-rwxr-xr-x | rt/share/html/Ticket/Display.html | 177 |
1 files changed, 97 insertions, 80 deletions
diff --git a/rt/share/html/Ticket/Display.html b/rt/share/html/Ticket/Display.html index 59adbd68d..6deb65cac 100755 --- a/rt/share/html/Ticket/Display.html +++ b/rt/share/html/Ticket/Display.html @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -46,12 +46,9 @@ %# %# END BPS TAGGED BLOCK }}} <& /Elements/Header, - Title => loc("Ticket #[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject), + Title => $title, LinkRel => \%link_rel &> -<& /Ticket/Elements/Tabs, - Ticket => $TicketObj, - current_tab => 'Ticket/Display.html?id='.$TicketObj->id, - Title => loc("Ticket #[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject) &> +<& /Elements/Tabs &> % $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@Actions, ARGSRef => \%ARGS, Ticket => $TicketObj); @@ -68,18 +65,24 @@ % $m->callback( Ticket => $TicketObj, %ARGS, CallbackName => 'BeforeShowHistory' ); -<& /Ticket/Elements/ShowHistory , - Ticket => $TicketObj, - Tickets => $Tickets, - Collapsed => $ARGS{'Collapsed'}, - ShowHeaders => $ARGS{'ShowHeaders'}, - Attachments => $attachments, - AttachmentContent => $attachment_content -&> +% if (not $ForceShowHistory and RT->Config->Get( 'DeferTransactionLoading', $session{'CurrentUser'} )) { + <& /Ticket/Elements/ClickToShowHistory, + Ticket => $TicketObj, + &> +% } else { + <& /Ticket/Elements/ShowHistory , + Ticket => $TicketObj, + Tickets => $Tickets, + Transactions => $transactions, + Collapsed => $ARGS{'Collapsed'}, + ShowHeaders => $ARGS{'ShowHeaders'}, + Attachments => $attachments, + AttachmentContent => $attachment_content + &> +% } % $m->callback( %ARGS, % Ticket => $TicketObj, -% current_tab => 'Ticket/Display.html?id=' . $TicketObj->id, % CallbackName => 'AfterShowHistory', % ); @@ -88,13 +91,21 @@ $id => undef $TicketObj => undef $ShowHeaders => 0 $Collapsed => undef +$ForceShowHistory => 0 </%ARGS> <%INIT> $m->callback( TicketObj => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'Initial' ); -my (@Actions, $Tickets); +if ( ! $ARGS{'NoRedirect'} && RT::Interface::Web->MobileClient()) { + $id ||= $TicketObj->id if $TicketObj; + RT::Interface::Web::Redirect(RT->Config->Get('WebURL').'m/ticket/show?id='.$id); + $m->abort; +} + + +my (@Actions, $Tickets, $title); unless ($id || $TicketObj) { @@ -112,7 +123,7 @@ if ($ARGS{'id'} eq 'new') { $ARGS{'new-MemberOf'} = join(' ', $ARGS{'new-MemberOf'}, @cust_uris); - my $Queue = new RT::Queue( $session{'CurrentUser'} ); + my $Queue = RT::Queue->new( $session{'CurrentUser'} ); $Queue->Load($ARGS{'Queue'}); unless ( $Queue->id ) { Abort('Queue not found'); @@ -129,89 +140,95 @@ if ($ARGS{'id'} eq 'new') { unless ( $TicketObj->CurrentUserHasRight('ShowTicket') ) { Abort("No permission to view newly created ticket #".$TicketObj->id."."); } - # }}} } else { $TicketObj ||= LoadTicket($ARGS{'id'}); + $TicketObj->CurrentUser->PrincipalObj->HasRights( Object => $TicketObj ); + + my $SkipProcessing; + $m->callback( CallbackName => 'BeforeProcessArguments', TicketObj => $TicketObj, Tickets => $Tickets, - ActionsRef => \@Actions, ARGSRef => \%ARGS ); - if ( defined $ARGS{'Action'} ) { - if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) { - my $action = $1; - my ($res, $msg) = $TicketObj->$action(); - push(@Actions, $msg); + ActionsRef => \@Actions, ARGSRef => \%ARGS, + SkipProcessing => \$SkipProcessing ); + + if ( !$SkipProcessing ) { + if ( defined $ARGS{'Action'} ) { + if ($ARGS{'Action'} =~ /^(Steal|Delete|Take|SetTold)$/) { + my $action = $1; + my ($res, $msg) = $TicketObj->$action(); + push(@Actions, $msg); + } } - } - $m->callback(CallbackName => 'ProcessArguments', - Ticket => $TicketObj, - ARGSRef => \%ARGS, - Actions => \@Actions); - - $ARGS{UpdateAttachments} = $session{'Attachments'}; - push @Actions, - ProcessUpdateMessage( - ARGSRef => \%ARGS, - Actions => \@Actions, - TicketObj => $TicketObj, - ); - delete $session{'Attachments'}; - - #Process status updates - push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $TicketObj ); - push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $TicketObj ); - push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $TicketObj ); - push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $TicketObj ); - push @Actions, ProcessTicketCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $TicketObj ); - # If this fails due to required fields being empty, it will set - # notes('RedirectToBasics'). - push @Actions, ProcessTicketStatus( ARGSRef => \%ARGS, TicketObj => $TicketObj ); - - # XXX: we shouldn't block actions here if user has no right to see the - # ticket, but we should allow him to see actions he has done - unless ($TicketObj->CurrentUserHasRight('ShowTicket')) { - Abort("No permission to view ticket"); - } - if ( $ARGS{'MarkAsSeen'} ) { - $TicketObj->SetAttribute( - Name => 'User-'. $TicketObj->CurrentUser->id .'-SeenUpTo', - Content => $TicketObj->LastUpdated, - ); - push @Actions, loc('Marked all messages as seen'); + $m->callback(CallbackName => 'ProcessArguments', + Ticket => $TicketObj, + ARGSRef => \%ARGS, + Actions => \@Actions); + + $ARGS{UpdateAttachments} = $session{'Attachments'}; + push @Actions, + ProcessUpdateMessage( + ARGSRef => \%ARGS, + Actions => \@Actions, + TicketObj => $TicketObj, + ); + delete $session{'Attachments'}; + + #Process status updates + push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $TicketObj ); + push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $TicketObj ); + push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $TicketObj ); + push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $TicketObj ); + push @Actions, ProcessTicketCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $TicketObj ); + # If this fails due to required fields being empty, it will set + # notes('RedirectToBasics'). + push @Actions, ProcessTicketStatus( ARGSRef => \%ARGS, TicketObj => $TicketObj ); + + push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $TicketObj ); + + # XXX: we shouldn't block actions here if user has no right to see the ticket, + # but we should allow him to see actions he has done + unless ($TicketObj->CurrentUserHasRight('ShowTicket')) { + Abort("No permission to view ticket"); + } + if ( $ARGS{'MarkAsSeen'} ) { + $TicketObj->SetAttribute( + Name => 'User-'. $TicketObj->CurrentUser->id .'-SeenUpTo', + Content => $TicketObj->LastUpdated, + ); + push @Actions, loc('Marked all messages as seen'); + } } } + +$title = loc("Ticket #[_1]: [_2]", $TicketObj->Id, $TicketObj->Subject || ''); + $m->callback( CallbackName => 'BeforeDisplay', TicketObj => \$TicketObj, Tickets => \$Tickets, Actions => \@Actions, + title => \$title, ARGSRef => \%ARGS, ); # This code does automatic redirection if any updates happen. +my $path = '/Ticket/'. ( $m->notes('RedirectToBasics') ? 'Modify.html' + : 'Display.html' ); +MaybeRedirectForResults( + Actions => \@Actions, + $TicketObj->Type eq 'approval' && RT->Config->Get('ForceApprovalsView') + ? (Path => "/Approvals/Display.html", Force => 1) + : (Path => $path) + , + Anchor => $ARGS{'Anchor'}, + Arguments => { id => $TicketObj->id }, +); -if (@Actions) { - - # 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} ||= [] }, @Actions; - $session{'i'}++; - my $url = RT->Config->Get('WebURL'); - if ( $m->notes('RedirectToBasics') ) { - $url .= 'Ticket/Modify.html'; - } - else { - $url .= 'Ticket/Display.html'; - } - $url .= '?id=' . $TicketObj->id . "&results=" . $key; - $url .= '#' . $ARGS{Anchor} if $ARGS{Anchor}; - RT::Interface::Web::Redirect($url); -} - +# Get the transactoins before the attachments, for great ACL justice +my $transactions = $m->comp('Elements/FindTransactions',Ticket => $TicketObj, Tickets => $Tickets || undef); my $attachments = $m->comp('Elements/FindAttachments', Ticket => $TicketObj, Tickets => $Tickets); my $attachment_content = $m->comp('Elements/LoadTextAttachments', Ticket => $TicketObj); |