%# 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'} &> <& /RTIR/Search/Elements/RefineTabs, Title => $title, Queue => 'Incident Reports', Ticket => $IncidentObj, BaseQuery => $BaseQuery, QueryString => $QueryString, current_tab => $current_tab, current_subtab => "RTIR/Search/Refine.html", &> % $m->callback(CallbackName => 'BeforeActionList', Actions => \@results, ARGSRef => \%ARGS, Ticket => $IncidentObj); <& /Elements/ListActions, actions => \@results &>
<& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &> % my $recipients = 0;

<&|/l&>Reporters

<& /RTIR/Search/Elements/ShowResults, Queue => 'Incident Reports', BaseURL => $current_tab, BaseQuery => $BaseQuery{'Incident Reports'}, Query => $Query, DisplayFormat => "__CheckBox.{SelectedReports}__, $Format", Format => $Format, Rows => $Rows, Page => $Page, OrderBy => $OrderBy, Order => $Order, &> % $recipients += $session{'tickets'}->CountAll; % if ( $All ) {

<&|/l&>Investigation Correspondents

<& /RTIR/Search/Elements/ShowResults, Queue => 'Investigations', BaseURL => $current_tab, BaseQuery => $BaseQuery{'Investigations'}, Query => $Query, DisplayFormat => "__CheckBox.{SelectedInvestigations}__, $Format", Format => $Format, Rows => $Rows, Page => $Page, OrderBy => $OrderBy, Order => $Order, &> % $recipients += $session{'tickets'}->CountAll; % unless( RT->Config->Get('RTIR_DisableBlocksQueue') ) {

<&|/l&>Blocks Correspondents

<& /RTIR/Search/Elements/ShowResults, Queue => 'Investigations', BaseURL => $current_tab, BaseQuery => $BaseQuery{'Blocks'}, Query => $Query, DisplayFormat => "__CheckBox.{SelectedBlocks}__, $Format", Format => $Format, Rows => $Rows, Page => $Page, OrderBy => $OrderBy, Order => $Order, &> % $recipients += $session{'tickets'}->CountAll; % } % } % if ($recipients == 0) {

Warning: no recipients!

% } <& Elements/ReplyForm, %ARGS, TicketObj => $IncidentObj, Status => $Status, GnuPGWidget => $gnupg_widget, &> <& /Elements/Submit, Name => "SubmitTicket", Caption => $SubmitCaption, Label => $SubmitLabel &>
<%INIT> my (@results); my $IncidentObj = LoadTicket( $id ); $id = $ARGS{'id'} = $IncidentObj->id; $m->callback( %ARGS, CallbackName => 'Initial', Ticket => $IncidentObj ); # XXX: we should get rid of DefaultStatus argument at all. use Status $Status ||= $DefaultStatus; $DefaultStatus ||= $Status; my ($title, $SubmitCaption, $SubmitLabel); if ($DefaultStatus eq 'resolved') { $title = loc("Resolve Incident #[_1] (including children)", $id); $SubmitCaption = loc("Resolve Incident"); $SubmitLabel = loc("Resolve"); } elsif ($DefaultStatus eq 'rejected') { $title = loc("Abandon Incident #[_1] (including children)", $id); $SubmitCaption = loc("Abandon Incident"); $SubmitLabel = loc("Abandon"); } else { $SubmitCaption = loc("Reply to selected correspondents"); $SubmitLabel = loc("Reply"); if ($All) { $title = loc("Incident #[_1]: Reply to All", $id); } else { $title = loc("Incident #[_1]: Reply to Reporters", $id); } } my @queues = ('Incident Reports', 'Investigations'); push @queues, 'Blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue'); my $ActiveStatesQuery = join ' OR ', map "CF.{State} = '$_'", RT::IR::States( Queue => \@queues ); $Query ||= "( $ActiveStatesQuery )"; my $ActiveChildrenQuery = join ' AND ', map "( $_ )", grep $_, "MemberOf = $id", $ActiveStatesQuery, join ' OR ', map "Queue = '$_'", @queues; $m->comp( '/RTIR/Create.html:ProcessAttachments', %ARGS ); my $checks_failure = 0; my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS ); $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process', self => $gnupg_widget, QueueObj => $IncidentObj->QueueObj, ); if ( $SubmitTicket && $gnupg_widget ) { foreach my $id( @SelectedReports, @SelectedInvestigations, @SelectedBlocks ) { my $Ticket = RT::Ticket->new( $session{'CurrentUser'} ); $Ticket->Load( $id ); unless( $Ticket->id ) { push @results, loc( "Ticket [_1]: Couldn't load ticket.", $id ); next; } my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check', self => $gnupg_widget, TicketObj => $Ticket, ); $checks_failure = 1 unless $status; } } if ( $SubmitTicket && !$checks_failure ) { foreach my $id( @SelectedReports, @SelectedInvestigations, @SelectedBlocks ) { my $Ticket = RT::Ticket->new( $session{'CurrentUser'} ); $Ticket->Load( $id ); unless( $Ticket->id ) { push @results, loc( "Ticket [_1]: Couldn't load ticket.", $id ); next; } $id = $Ticket->id; my $oldstate = RT::IR::Ticket::FirstCustomFieldValue( $Ticket, 'State' ); my @tempresults; $ARGS{'UpdateAttachments'} = delete $session{'Attachments'}; push @tempresults, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef => \%ARGS ); unless ( RT::IR::Ticket::IsLinkedToActiveIncidents( $Ticket, $IncidentObj ) ) { # XXX: we push into results directly cuz ProcessTicketBasics returns results # with leading 'Ticket XX:' string push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS ); } my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $Ticket, 'State' ); if ($newstate ne $oldstate) { push (@tempresults, loc("State changed from [_1] to [_2]", $oldstate, $newstate)); } push @results, map { loc("Ticket [_1]: [_2]", $id, $_) } @tempresults; } my $update_incident_state = 1; if ( $DefaultStatus =~ /^(rejected|resolved)$/) { # if we are going to resolve/reject incident then do it only when we've # rejected all children that are not linked to another active incident(s) my $children = RT::Tickets->new( $session{'CurrentUser'} ); $children->FromSQL( $ActiveChildrenQuery ); while ( my $child = $children->Next ) { next if RT::IR::Ticket::IsLinkedToActiveIncidents( $child, $IncidentObj ); $update_incident_state = 0; last; } } if ( $update_incident_state ) { my $oldstate = RT::IR::Ticket::FirstCustomFieldValue( $IncidentObj, 'State' ); push @results, ProcessObjectCustomFieldUpdates( Object => $IncidentObj, ARGSRef => \%ARGS); push @results, ProcessTicketBasics( TicketObj => $IncidentObj, ARGSRef => \%ARGS ); my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $IncidentObj, 'State' ); if ($newstate ne $oldstate) { push @results, loc("State changed from [_1] to [_2]", $oldstate, $newstate); } } else { push @results, loc("State of the Incident left unchanged; not all children were updated"); } my $pass = {}; $m->callback( CallbackName => 'BeforeDisplay', ARGSRef => \%ARGS, PassArguments => $pass, Ticket => $IncidentObj ); push @{ $session{'Actions'}{''} ||= [] }, @results; # NOTE: don't pass %ARGS further as we've done everything we need here return $m->comp("Display.html", %$pass, id => $id); } # XXX, BLOODY-DIRTY-EVIL HACK: when we load the page first time we should # select all children by default, but we have no way to do that right now # without something like this foreach (qw(SelectedReports SelectedInvestigations SelectedBlocks)) { if ( !exists $ARGS{ $_ } && !exists $ARGS{ $_ .'All'} ) { push @{ $m->{'request_args'} }, $_ .'All' => 1; } } my ($BaseQuery, %BaseQuery) = ( '', () ); foreach my $queue ( @queues ) { my $tmp = $m->comp('/RTIR/Elements/BaseQuery', Queue => $queue); $BaseQuery .= ' OR ' if $BaseQuery; $BaseQuery .= "( $tmp )"; $BaseQuery{ $queue } = join ' AND ', map "( $_ )", grep $_, $tmp, "MemberOf = $id"; } $BaseQuery = join ' AND ', map "( $_ )", grep $_, $BaseQuery, "MemberOf = $id"; my $QueryString = $m->comp( '/Elements/QueryString', Query => $Query, Format => $Format, Rows => $Rows, OrderBy => $OrderBy, Order => $Order, Page => $Page); my $current_tab = "RTIR/Incident/Reply.html?". $m->comp('/Elements/QueryString', id => $id, All => $All, DefaultStatus => $DefaultStatus, Action => $Action, ); <%ARGS> $id => undef $All => 0 $DefaultStatus => '' $Status => $DefaultStatus, $Action => 'Correspond' $Query => '' $Format => RT->Config->Get('RTIRSearchResultFormats')->{'BulkReply'} $Rows => 0 $Page => 1 $OrderBy => 'id' $Order => 'ASC' @SelectedReports => () @SelectedInvestigations => () @SelectedBlocks => () $SubmitTicket => 0