%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2020 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) %# %# %# LICENSE: %# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org. %# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA %# 02110-1301 or visit their web page on the internet at %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: %# %# (The following paragraph is not intended to limit the rights granted %# to you to modify and distribute this software under the terms of %# the GNU General Public License and is only of importance to you if %# you choose to contribute your changes and enhancements to the %# community by submitting them to Best Practical Solutions, LLC.) %# %# By intentionally submitting any modifications, corrections or %# derivatives to this work, or any other work intended for use with %# Request Tracker, to Best Practical Solutions, LLC, you confirm that %# you are the copyright holder for those contributions and you grant %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, %# royalty-free, perpetual, license to use, copy, create derivative %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# %# END BPS TAGGED BLOCK }}} <& /Elements/Header, Title => $title, Refresh => $session{'tickets_refresh_interval'} &> <& /Elements/Tabs, SearchArgs => { %defaults, Query => $Query } &> % $m->callback(CallbackName => 'BeforeActionList', Actions => \@results, ARGSRef => \%ARGS, Ticket => $Ticket); <& /Elements/ListActions, actions => \@results &>
" method="post"> % if ( $siblings_query ) { <& /RTIR/Elements/MergeWith, %defaults, %ARGS, Title => loc('Other children of the parent incident(s) of #[_1]', $id), Ticket => $Ticket, Query => $siblings_query, Rows => 0, Page => 1, &> % } <& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => $Ticket->QueueObj->Lifecycle, Ticket => $Ticket &> % if ( RT::IR->IsReportQueue($Ticket->QueueObj)) { <& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => RT::IR->lifecycle_investigation, Ticket => $Ticket &> % } elsif ( RT::IR->IsInvestigationQueue($Ticket->QueueObj)) { <& /RTIR/Elements/MergeWith, %defaults, %ARGS, Lifecycle => RT::IR->lifecycle_report, Ticket => $Ticket &> % }
<& /Elements/Submit, Caption=> loc('Merge into selected Ticket'), Label => loc("Merge") &>
<%INIT> my $Ticket = LoadTicket($id); $id = $ARGS{'id'} = $Ticket->id; $m->callback(CallbackName => 'Initial', %ARGS, Ticket => $Ticket); my $MergeTicket; $MergeTicket = LoadTicket( $SelectedTicket ) if $SelectedTicket; my (@results); my $checks_failure = 0; if ( $MergeTicket ) { my @lifecycles = sort map $_->Lifecycle, $Ticket->QueueObj, $MergeTicket->QueueObj; unless ( $lifecycles[0] eq $lifecycles[1] or ($lifecycles[0] eq RT::IR->lifecycle_report and $lifecycles[1] eq RT::IR->lifecycle_investigation) ) { push @results, loc("Merge failed: Ticket #[_1] is not the right type", $MergeTicket->Id ); $checks_failure = 1; } if (RT::IR->StrictConstituencyLinking) { if ( (RT::IR->ConstituencyFor($Ticket) // '') ne (RT::IR->ConstituencyFor($MergeTicket) // '') ) { push @results, loc("Merge failed: Ticket #[_1] is associated with a different constituency", $MergeTicket->Id ); $checks_failure = 1; } } } if ( $MergeTicket && !$checks_failure ) { my @lifecycles = sort map $_->Lifecycle, $Ticket->QueueObj, $MergeTicket->QueueObj; if ( $lifecycles[0] ne $lifecycles[1] && $lifecycles[1] eq RT::IR->lifecycle_report ) { # We always want to merge into the Investigation ($Ticket, $MergeTicket) = ($MergeTicket, $Ticket); } $m->callback(CallbackName => 'MergeTicketSelected', MergeFrom => $Ticket, MergeTo => $MergeTicket); $ARGS{ $Ticket->id .'-MergeInto' } = $MergeTicket->id; for my $t ( $Ticket, $MergeTicket ) { next if $t->Owner == $t->CurrentUser->Id; my ($status, $msg) = $t->SetOwner($t->CurrentUser->Id, 'Force'); push @results, $msg if $msg; } push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS); $Ticket = LoadTicket($id); MaybeRedirectForResults( Actions => \@results, Path => RT::IR->HREFTo("Display.html", IncludeWebPath => 0), Arguments => { id => $Ticket->id }, ); } my $Lifecycle = $Ticket->QueueObj->Lifecycle; my $title = loc("Merge [_1] #[_2]: [_3]", RT::IR::TicketType( Ticket => $Ticket), $id, $Ticket->Subject); $Query ||= RT::IR->ActiveQuery( Lifecycle => $Lifecycle ); my $BaseQuery = RT::IR->Query( Lifecycle => $Lifecycle, Exclude => $id); my %defaults = ( Format => $Format, Rows => $Rows, Page => $Page, OrderBy => $OrderBy, Order => $Order, ); my $siblings_query = ''; if ( !RT::IR->IsIncidentQueue($Ticket->QueueObj)) { my @parents = @{ RT::IR->Incidents( $Ticket )->ItemsArrayRef || [] }; if ( @parents ) { my @lifecycles = ($Lifecycle); push @lifecycles, RT::IR->lifecycle_investigation if $Lifecycle eq RT::IR->lifecycle_report; push @lifecycles, RT::IR->lifecycle_report if $Lifecycle eq RT::IR->lifecycle_investigation; $siblings_query = RT::IR->Query( Lifecycle => \@lifecycles, MemberOf => \@parents, Exclude => $id ); } } <%ARGS> $id => undef $Query => undef $Format => RT->Config->Get('RTIRSearchResultFormats')->{'Merge'} $Rows => 50 $Page => 1 $OrderBy => RT->Config->Get('DefaultSearchResultOrderBy') $Order => RT->Config->Get('DefaultSearchResultOrder') $SelectedTicket => undef