%# BEGIN LICENSE BLOCK %# %# Copyright (c) 1996-2002 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 => loc('Abandon Incidents') &> <& /Elements/Tabs &> <& /Elements/ListActions, actions => \@results &>
% foreach my $arg (qw(Query Format Rows Page OrderBy Order) ) { % next unless defined $ARGS{ $arg } && length $ARGS{ $arg }; % } <%PERL> my $found = $m->comp('/RTIR/Search/Elements/ShowResults', Queue => 'Incidents', BaseURL => 'RTIR/Incident/BulkAbandon.html', BaseQuery => RT::IR->ActiveQuery( Queue => 'Incidents' ), Query => $Query, DisplayFormat => "__CheckBox__, $Format", Format => $Format, Rows => $Rows, OrderBy => $OrderBy, Order => $Order, Page => $Page, EmptyLabel => loc("no incidents"), ShowNavigation => 1, UpdateSession => 1, ); % if ( $found ) { <&| /Widgets/TitleBox, title => loc("Select recipients") &> % foreach my $box( @CheckBox ) { % my $checked = (scalar grep $_ && $box->{'Value'}, @ReplyToAll )? ' checked' : ''; " /> <% $box->{'Title'} %>
% }
<& Elements/ReplyForm &> <& /Elements/Submit, Name => "BulkAbandon", Caption => loc("Abandon selected incidents"), Label => loc("Abandon"), CheckAll => 1, ClearAll => 1, CheckboxName => 'SelectedTickets', &> % }
<%INIT> my @CheckBox = ( { Value => 'Incident Reports', Title => loc("Reply to all reports") }, { Value => 'Investigations', Title => loc("Reply to all investigations") }, ); my $Status = 'abandoned'; my ( @results ); $m->comp( '/RTIR/Create.html:ProcessAttachments', %ARGS ); if ( $ARGS{'BulkAbandon'} ) { $ARGS{'UpdateAttachments'} = delete $session{'Attachments'}; my @tempresults; foreach my $id ( @SelectedTickets ) { my $t = RT::Ticket->new( $session{'CurrentUser'} ); $t->Load( $id ); unless( $t->id ) { push @tempresults, [ $id, loc("Couldn't load ticket.") ]; next; } $id = $t->id; unless( $t->QueueObj->Name eq 'Incidents' ) { push @tempresults, [ $id, loc("Is not incident.") ]; next; } # process replies if ( @ReplyToAll ) { my $children = RT::IR->IncidentChildren( $t, Queue => \@ReplyToAll, Initial => 1, Active => 1, ); while ( my $child = $children->Next ) { push @tempresults, ProcessUpdateMessage( TicketObj => $child, ARGSRef => \%ARGS, ); } } # process status updates { my $children = RT::IR->IncidentChildren( $t, Initial => 1, Active => 1, ); while ( my $child = $children->Next ) { next if RT::IR->IsLinkedToActiveIncidents( $child, $t ); push @tempresults, ProcessTicketBasics( TicketObj => $child, ARGSRef => { %ARGS, Status => RT::IR->MapStatus( $Status, $t => $child ), }, ); } } unless ( RT::IR->IncidentHasActiveChildren( $t ) ) { push @tempresults, ProcessTicketBasics( TicketObj => $t, ARGSRef => { %ARGS, Status => $Status }, ); } else { push @tempresults, [$t->id, loc("Status of the Incident left unchanged; not all children were updated")]; } } push @results, map { ref($_)? loc( "Ticket [_1]: [_2]", $_->[0], $_->[1] ): $_ } @tempresults; MaybeRedirectForResults( Actions => \@results, Arguments => { map { $_ => $ARGS{ $_ } } grep defined $ARGS{ $_ } && length $ARGS{ $_ }, qw(Query Format Rows Page OrderBy Order) }, ); } <%ARGS> $Query => '' $Format => RT->Config->Get('RTIRSearchResultFormats')->{'AbandonIncidents'} $Rows => 50 $Page => 1 $OrderBy => 'id' $Order => 'ASC' @SelectedTickets => () @ReplyToAll => ()