%# 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, Refresh => $session{'tickets_refresh_interval'} &> <& Elements/Tabs, current_tab => 'RTIR/Report/BulkReject.html?ClearRestrictions=1', Title => $title &> <& /RTIR/Elements/ListActions, actions => \@results &>
> <& /RTIR/Elements/Listing, Type => 'Incident', Queue => 'Incidents', check => $check, %ARGS &> [Select All] [Unselect All] <& /Elements/Submit, Name => "SubmitTicket", Caption => $SubmitCaption, Label => loc("Reject") &>

<& /RTIR/Elements/SearchFields, Path => 'BulkReject.html', Queue => $QueueObj->Name, %ARGS &> <%INIT> my $title = loc("Reject Incident Reports"); my $SubmitCaption = loc("Reject selected incident reports"); my $QueueObj = RT::Queue->new($session{'CurrentUser'}); $QueueObj->Load("Incident Reports"); 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 => $QueueObj->Name); my $CustomFields = $QueueObj->CustomFields(); $CustomFields->{'find_disabled_rows'} = 1; while (my $CustomField = $CustomFields->Next()) { if ($CustomField->Name eq '_RTIR_State') { $session{'tickets'}->LimitCustomField(CUSTOMFIELD => $CustomField->Id, VALUE => 'new'); } } } } 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); Abort(loc("No search to operate on.")) unless ($session{'tickets'}); my (@tempresults, @results); if ($ARGS{'BulkReject'}) { #Iterate through each ticket we've been handed while (my $t = $session{'tickets'}->Next) { $RT::Logger->debug( "Checking Ticket ".$t->Id ."\n"); next unless ($ARGS{"UpdateTicket".$t->Id}); my $State = $m->scomp("/RTIR/Elements/ShowRTIRField", Ticket => $t, Name => 'State'); $State =~ s/\s+$//; if ($State eq 'new') { # If we don't own the thing we're linking to, change the owner if ($t->OwnerObj->id != $session{'CurrentUser'}->id && $t->OwnerObj->id != $RT::Nobody->id) { @tempresults = loc("You may not reject tickets that belong to another user."); } else { @tempresults = (); if ($t->OwnerObj->id != $session{'CurrentUser'}->id && $t->OwnerObj->id == $RT::Nobody->id) { $ARGS{'Action'} = 'Take'; my $action = $ARGS{'Action'}; push @tempresults, "Action: ".$ARGS{'Action'}; my ($res, $msg)=$t->$action(); push (@tempresults, $msg); } my ($oldstate, $newstate); $oldstate = $t->FirstCustomFieldValue('_RTIR_State'); push @tempresults, ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$t); $newstate = $t->FirstCustomFieldValue('_RTIR_State'); if ($newstate ne $oldstate) { push (@tempresults, loc("State changed from [_1] to [_2]", $oldstate, $newstate)); } } } else { push @tempresults, loc("Cannot reject Incident Report #[_1]. Only new reports may be rejected.", $t->id); } @tempresults = map { loc("Ticket [_1]: [_2]",$t->Id,$_) } @tempresults; @results = (@results, @tempresults); } } <%ARGS> $Status => 'rejected' $check => 'uncheck'