%# BEGIN LICENSE BLOCK %# %# Copyright (c) 1996-2003 Jesse Vincent %# %# (Except where explictly superceded by other copyright notices) %# %# 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. %# %# %# Unless otherwise specified, all modifications, corrections or %# extensions to this work which alter its source code become the %# property of Best Practical Solutions, LLC when submitted for %# inclusion in the work. %# %# %# END LICENSE BLOCK <& /Elements/Header, Title => $title, Refresh => $session{'tickets_refresh_interval'} &> <& /Elements/Tabs &> % $m->callback(CallbackName => 'BeforeActionList', Actions => \@results, ARGSRef => \%ARGS, Ticket => $Ticket); <& /Elements/ListActions, actions => \@results &>
% 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, Queue => $Ticket->QueueObj->Name, Ticket => $Ticket &> % if ( $Type eq 'Report' ) { <& /RTIR/Elements/MergeWith, %defaults, %ARGS, Queue => "Investigations", Ticket => $Ticket &> % } elsif ( $Type eq 'Investigation' ) { <& /RTIR/Elements/MergeWith, %defaults, %ARGS, Queue => "Incident Reports", 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 @queues = sort map $_->Name, $Ticket->QueueObj, $MergeTicket->QueueObj; unless ( $queues[0] eq $queues[1] or ($queues[0] eq "Incident Reports" and $queues[1] eq "Investigations") ) { push @results, loc("Merge failed: Ticket #[_1] is not the right type", $MergeTicket->Id ); $checks_failure = 1; } } if ( $MergeTicket && RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject' ) { if ( lc $MergeTicket->FirstCustomFieldValue('Constituency') ne lc $Ticket->FirstCustomFieldValue('Constituency') ) { push @results, loc("Merge failed: Tickets have different constituencies" ); $checks_failure = 1; } } if ( $MergeTicket && !$checks_failure ) { my @queues = sort map $_->Name, $Ticket->QueueObj, $MergeTicket->QueueObj; if ( $queues[0] ne $queues[1] && $queues[1] eq "Incident Reports" ) { # 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 => "/RTIR/Display.html", Arguments => { id => $Ticket->id }, ); } my $Type = RT::IR::TicketType( Ticket => $Ticket ); my $Queue = $Ticket->QueueObj->Name; my $title = loc("Merge [_1] #[_2]: [_3]", $Type, $id, $Ticket->Subject); $Query ||= RT::IR->ActiveQuery( Queue => $Queue ); my $BaseQuery = RT::IR->Query( Queue => $Queue, Exclude => $id, Constituency => $Ticket ); my %defaults = ( Format => $Format, Rows => $Rows, Page => $Page, OrderBy => $OrderBy, Order => $Order, ); my $siblings_query = ''; if ( $Type ne 'Incident' ) { my @parents = @{ RT::IR->Incidents( $Ticket )->ItemsArrayRef || [] }; if ( @parents ) { my @queues = ($Queue); push @queues, 'Investigations' if $Type eq 'Report'; push @queues, 'Incident Reports' if $Type eq 'Investigation'; $siblings_query = RT::IR->Query( Queue => \@queues, MemberOf => \@parents, Exclude => $id ); } } <%ARGS> $id => undef $Query => undef $Format => RT->Config->Get('RTIRSearchResultFormats')->{'Merge'} $Rows => 50 $Page => 1 $OrderBy => 'id' $Order => 'ASC' $SelectedTicket => undef