%# 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, QueryString => $QueryString, BaseQuery => $BaseQuery, current_tab => $current_tab, &> <& /Elements/ListActions, actions => \@results &>
<%PERL> # XXX: cache result set to check if get empty results my $result_set = $m->scomp('/RTIR/Search/Elements/ShowResults', Queue => $Queue, BaseURL => $BaseURL, BaseQuery => $BaseQuery, Query => $Query, Format => '__RTIR_Check__,'. $Format, Rows => $Rows, OrderBy => $OrderBy, Order => $Order, Page => $Page, ); % if( $session{'tickets'}->Count ) { % $m->out( $result_set ); <&| /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 => $SubmitCaption, Label => loc("Reject"), CheckAll => 1, ClearAll => 1, CheckboxName => 'SelectedTickets', &> % } else { <% loc("no incidents") %> % }
<%INIT> my @CheckBox = ( { Value => 'Incident Reports', Title => loc("Reply to all reports") }, { Value => 'Investigations', Title => loc("Reply to all investigations") }, ); my $title = loc('Abandon Incidents'); my $SubmitCaption = loc("Abandon selected incidents"); my ( @results ); $m->comp( '/RTIR/Create.html:ProcessAttachments', %ARGS ); if ( $ARGS{'BulkAbandon'} ) { my @tempresults; foreach my $id ( @SelectedTickets ) { $m->out(''); $m->flush_buffer; 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( scalar @ReplyToAll ) { # XXX: why do we limit to open? my $query = "CF.{_RTIR_State} = 'open' AND MemberOf = $id"; $query .= " AND (". join(' OR ', map "Queue = '$_'", @ReplyToAll) .")"; my $members = new RT::Tickets( $t->CurrentUser ); $members->FromSQL( $query ); while( my $member = $members->Next ) { $ARGS{'UpdateAttachments'} = delete $session{'Attachments'} if $session{'Attachments'}; push @tempresults, ProcessUpdateMessage(TicketObj => $member, ARGSRef => \%ARGS ); } } # process status updates my @tmp; { my $query = "MemberOf = $id" ." AND ( ". join(" OR ", map "Status = '$_'", RT->Config->Get('ActiveStatus') ) ." )" ." AND ( Queue = 'Incident Reports' OR Queue = 'Blocks' OR Queue = 'Investigations' )"; my $members = new RT::Tickets( $t->CurrentUser ); $members->FromSQL( $query ); while( my $member = $members->Next ) { next if RT::IR::Ticket::IsLinkedToActiveIncidents( $member, $t ); push @tmp, $member; } } push @tmp, $t; foreach my $t( @tmp ) { my $oldstate = RT::IR::Ticket::FirstCustomFieldValue( $t, '_RTIR_State' ); push @tempresults, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $t ); my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $t, '_RTIR_State' ); if ( $newstate ne $oldstate ) { push @tempresults, [ $t->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 tickets $session{'tickets'}->RedoSearch if $session{'tickets'}; } # We can only reject new tickets, so set the states. my $QueryString = $m->comp( '/Elements/QueryString', Query => $Query, Format => $Format, Rows => $Rows, OrderBy => $OrderBy, Order => $Order, Page => $Page ); my $BaseURL = "RTIR/Incident/BulkAbandon.html?" . $m->comp('/Elements/QueryString', Queue => $Queue, Status => $Status); my $current_tab = $BaseURL ."&$QueryString"; <%ARGS> $Status => 'rejected' $Queue => 'Incidents' $BaseQuery => $m->comp( '/RTIR/Elements/BaseQuery', Queue => $Queue ); $Query => $m->comp( '/RTIR/Elements/NewQuery', Queue => $Queue ); $Format => RT->Config->Get('RTIRSearchResultFormats')->{'AbandonIncidents'}; $Rows => 50 $Page => 1 $OrderBy => 'id' $Order => 'ASC' @SelectedTickets => () @ReplyToAll => ()