%# 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 => $title &> <& /Elements/Tabs &> <& /Elements/ListActions, actions => \@results &>
<%PERL> my $found = $m->comp( '/RTIR/Search/Elements/ShowResults', Queue => $Queue, BaseURL => $BaseURL, BaseQuery => RT::IR->ActiveQuery( Queue => $Queue ), Query => $Query, DisplayFormat => "__CheckBox__, $Format", Format => $Format, Rows => $Rows, Page => $Page, OrderBy => $OrderBy, Order => $Order, ShowNavigation => 1, UpdateSession => 1, ); % if ( $found ) { <& /Elements/Submit, Name => "BulkReject", Caption => loc("Reject selected incident reports"), Label => loc("Reject"), CheckAll => 1, ClearAll => 1, CheckboxName => 'SelectedTickets', &> <& /Elements/Submit, Name => "BulkRejectAndReturn", Caption => loc("Reject selected incident reports and return to reports list"), Label => loc("Reject and return"), &> % }
<%INIT> my $title = loc("Reject Incident Reports"); my ( @results ); if ( $BulkReject ) { my @tempresults; #Iterate through each ticket we've been handed 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.") ]; push @tempresults, [ $id, loc("Skipped.") ]; next; } $id = $t->id; # If we don't own the thing we're linking to, change the owner if ( $t->Owner != $session{'CurrentUser'}->id && $t->Owner != $RT::Nobody->id ) { push @tempresults, [ $id, loc("You may not reject tickets that belong to another user."), ]; push @tempresults, [ $id, loc("Skipped.") ]; next; } if ( RT::IR->RelevantIncidents( $t )->Count ) { # warn if this IR has any incidents push( @tempresults, [ $id, loc("Warning: already has incident") ] ); } if ( $t->Owner != $session{'CurrentUser'}->id && $t->Owner == $RT::Nobody->id ) { my ( $res, $msg ) = $t->Take; unless( $res ) { push( @tempresults, [ $id, loc("Couldn't take ticket: [_1]", $msg) ] ); } else { push( @tempresults, [ $id, loc("Took ticket. [_1]", $msg) ] ); } } push @tempresults, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $t ); } push @results, map { ref($_)? loc( "Ticket [_1]: [_2]", $_->[0], $_->[1] ): $_ } @tempresults; if ( $BulkRejectAndReturn ) { MaybeRedirectForResults( Actions => \@results, Path => '/RTIR/', Force => 1, ); } MaybeRedirectForResults( Actions => \@results, Arguments => { map { $_ => $ARGS{ $_ } } grep defined $ARGS{ $_ } && length $ARGS{ $_ }, qw(Status Queue Query Format Rows Page OrderBy Order) }, ); } my $BaseURL = "RTIR/Report/BulkReject.html?" . $m->comp('/Elements/QueryString', Queue => $Queue); <%ARGS> $Status => 'rejected' $Queue => 'Incident Reports' $Query => '' $Format => RT->Config->Get('RTIRSearchResultFormats')->{'RejectReports'} $Rows => 50 $Page => 1 $OrderBy => 'id' $Order => 'ASC' @SelectedTickets => () $BulkRejectAndReturn => 0 $BulkReject => $BulkRejectAndReturn? 1: 0