%# 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 &> <& '/RTIR/Search/Elements/RefineTabs', Title => $title, Queue => $Queue, BaseQuery => $BaseQuery, QueryString => $QueryString, current_tab => $current_tab, &> <& /Elements/ListActions, actions => \@results &>
<& /RTIR/Search/Elements/ShowResults, Queue => $Queue, BaseURL => $BaseURL, BaseQuery => $BaseQuery, Query => $Query, DisplayFormat => "__CheckBox__, $Format", Format => $Format, Rows => $Rows, Page => $Page, OrderBy => $OrderBy, Order => $Order, ShowNavigation => 1, ShowListActions => 0, &> % if ( $session{'tickets'}->Count ) { <& /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; } # warn if this IR has any incidents my $query = "Queue = 'Incidents' AND HasMember = " . $t->Id . " AND CF.{State} != 'rejected'"; my $incidents = new RT::Tickets($session{'CurrentUser'}); $incidents->FromSQL($query); if ($incidents->Count > 0) { push( @tempresults, [ $id, loc("Warning: already has incident") ] ); } my $oldstate = RT::IR::Ticket::FirstCustomFieldValue( $t, 'State' ) ||''; 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 ); my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $t, 'State' ) ||''; if ( $newstate ne $oldstate ) { push @tempresults, [ $id, loc("State changed from [_1] to [_2]", $oldstate, $newstate ) ]; } } push @results, map { ref($_)? loc( "Ticket [_1]: [_2]", $_->[0], $_->[1] ): $_ } @tempresults; # force redo search if we changed state $session{'tickets'}->RedoSearch if $session{'tickets'}; if ( $BulkRejectAndReturn ) { my $key = Digest::MD5::md5_hex( rand(1024) ); push @{ $session{"Actions"}{ $key } ||= [] }, @results; $session{'i'}++; return RT::Interface::Web::Redirect( RT->Config->Get('WebURL') ."/RTIR/index.html?results=".$key ); } } my $QueryString = $m->comp('/Elements/QueryString', Query => $Query, Format => $Format, Rows => $Rows, Page => $Page, OrderBy => $OrderBy, Order => $Order, ); my $BaseURL = "RTIR/Report/BulkReject.html?" . $m->comp('/Elements/QueryString', Queue => $Queue); my $current_tab = "$BaseURL&$QueryString"; <%ARGS> $Status => 'rejected' $Queue => 'Incident Reports' $BaseQuery => $m->comp( '/RTIR/Elements/BaseQuery', Queue => $Queue ) $Query => $m->comp( '/RTIR/Elements/NewQuery', Queue => $Queue ) $Format => RT->Config->Get('RTIRSearchResultFormats')->{'RejectReports'} $Rows => 50 $Page => 1 $OrderBy => 'id' $Order => 'ASC' @SelectedTickets => () $BulkRejectAndReturn => 0 $BulkReject => $BulkRejectAndReturn? 1: 0