%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2013 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 &>
% 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