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