%# 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 <& /RTIR/Elements/Header, Title => $Title &> <& '/RTIR/'.$Type.'/Elements/Tabs', Ticket => $Ticket, current_tab => "RTIR/Merge.html?NewSearch=1&id=".$Ticket->Id, current_subtab => "RTIR/Merge.html?NewSearch=1&id=".$Ticket->Id, Title => $Title &> <& /RTIR/Elements/ListActions, actions => \@results &> % if (!$Ticket->CurrentUserHasRight('ModifyTicket')) { <%loc("You are not allowed to merge this [_1].", $Type)%> % $m->abort(); % }
<& /RTIR/Elements/Listing, Type => $Type, Queue => $Ticket->QueueObj->Name, check => 'radio', %ARGS &>
<& /Elements/Submit, Caption=> loc('Merge into selected Ticket'), Label => loc("Merge") &>
<& /RTIR/Elements/SearchFields, Path => '/RTIR/Merge.html', Queue => $Ticket->QueueObj->Name, %ARGS &> <%INIT> my $Ticket = LoadTicket($id); my $Type = $m->scomp('Elements/Type', Ticket => $Ticket->Id); $Type =~ s/\s+$//; my @states; my $name = $Type; if ($Type eq "Incident") { @states = ('open'); } elsif ($Type eq "Report") { @states = ('new', 'open'); $name = 'Incident Report'; } elsif ($Type eq "Investigation") { @states = ('open'); } elsif ($Type eq "Block") { @states = ('pending activation', 'active', 'pending removal'); } if (! $session{'tickets'}) { # Init a new search $session{'tickets'} = RT::Tickets->new( $session{'CurrentUser'} ); } my $ticketcount; $session{'i'}++; if ($session{'tickets'}) { if ($ARGS{'DeleteRestriction'}) { $session{'tickets'}->DeleteRestriction($ARGS{'DeleteRestriction'}); } if ( ($ARGS{'ClearRestrictions'}) || ($ARGS{'NewSearch'}) ) { $session{'tickets'}->ClearRestrictions; $session{'tickets'}->LimitQueue(VALUE => $Ticket->QueueObj->Name); # we can't merge with ourself $session{'tickets'}->LimitId(VALUE => $Ticket->Id, OPERATOR => '!='); my $cf = RT::CustomField->new($session{'CurrentUser'}); $cf->LoadByNameAndQueue(Queue => 'Incidents', Name => '_RTIR_State'); foreach my $state (@states) { $session{'tickets'}->LimitCustomField(CUSTOMFIELD => $cf->Id, VALUE => $state); } } } ProcessSearchQuery(ARGS=>\%ARGS); $session{'tickets'}->RedoSearch(); if ( $session{'tickets'}->DescribeRestrictions()) { $ticketcount = $session{tickets}->Count(); } # Iterate through the ARGS hash and remove anything with a null value. map ($ARGS{$_} =~ /^$/ && (delete $ARGS{$_}), keys %ARGS); my $merge = $ARGS{'SelectedTicket'}; my ($MergeTicket, @results); if ($merge) { $ARGS{$id.'-MergeInto'} = $merge; $MergeTicket = LoadTicket($merge); if ($MergeTicket->QueueObj->id ne $Ticket->QueueObj->id) { push @results, loc("Merge failed: Ticket #[_1] is not the right type", $MergeTicket->Id); } else { @results = ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS); } } my $Title = loc("Merge [_1] #[_2]: [_3]", $name, $id, $Ticket->Subject); <%ARGS> $id => undef