[Rt-commit] r4796 - in rtir/branches/1.9-EXPERIMENTAL: html/RTIR
html/RTIR/Incident lib/RT/Action lib/RT/IR
ruz at bestpractical.com
ruz at bestpractical.com
Wed Mar 22 15:25:16 EST 2006
Author: ruz
Date: Wed Mar 22 15:25:14 2006
New Revision: 4796
Modified:
rtir/branches/1.9-EXPERIMENTAL/ (props changed)
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/BulkAbandon.html
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Reply.html
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Update.html
rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_ResolveChildren.pm
rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetBlockState.pm
rtir/branches/1.9-EXPERIMENTAL/lib/RT/IR/Ticket.pm
Log:
r993 at cubic-pc: cubic | 2006-03-22 23:32:11 +0300
* when we abandon a ticket, all the IRs are rejected, but this action
should be care about IRs which are linked to other incidents, because
those one shouldn't be rejected.
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/BulkAbandon.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/BulkAbandon.html (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/BulkAbandon.html Wed Mar 22 15:25:14 2006
@@ -120,11 +120,17 @@
# process status updates
my @tmp;
- my $members = new RT::Tickets( $t->CurrentUser );
- # XXX: do we want limit queues?
- $members->FromSQL( "MemberOf = $id" );
- while( my $member = $members->Next ) {
- push @tmp, $member;
+ {
+ 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;
@@ -169,7 +175,7 @@
$Queue => 'Incidents'
$BaseQuery => $m->comp( '/RTIR/Elements/BaseQuery', Queue => $Queue );
-$Query => $m->comp( '/RTIR/Elements/NewQuery', Queue => $Queue, Inactive => 1 );
+$Query => $m->comp( '/RTIR/Elements/NewQuery', Queue => $Queue );
$Format => RT->Config->Get('RTIRSearchResultFormats')->{'AbandonIncidents'};
$Rows => 50
$Page => 1
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Reply.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Reply.html (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Incident/Reply.html Wed Mar 22 15:25:14 2006
@@ -125,7 +125,10 @@
my @tempresults;
push @tempresults, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef => \%ARGS );
- push @tempresults, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
+
+ unless ( RT::IR::Ticket::IsLinkedToActiveIncidents( $Ticket, $IncidentObj ) ) {
+ push @tempresults, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
+ }
my $newstate = RT::IR::Ticket::FirstCustomFieldValue( $Ticket, '_RTIR_State' );
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Update.html
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Update.html (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Update.html Wed Mar 22 15:25:14 2006
@@ -109,28 +109,23 @@
my $name;
if ($Type eq 'Report') {
- $name = "Incident Report";
+ $name = "Incident Report";
} else {
- $name = $Type;
+ $name = $Type;
}
-unless($DefaultStatus){
- $DefaultStatus=($ARGS{'Status'} ||$Ticket->Status());
-}
-
-if ($DefaultStatus =~ '^new$'){
- $DefaultStatus='open';
-}
+$DefaultStatus ||= $ARGS{'Status'} || $Ticket->Status;
+$DefaultStatus = 'open' if $DefaultStatus eq 'new';
-if ($DefaultStatus eq 'resolved') {
+if ( $DefaultStatus eq 'resolved' ) {
$title = loc("Resolve [_1] #[_2] ([_3])", $name, $Ticket->id, $Ticket->Subject);
-} elsif ($DefaultStatus eq 'rejected') {
- if ($Type eq 'Incident') {
- $title = loc("Abandon [_1] #[_2] ([_3])", $name, $Ticket->id, $Ticket->Subject);
- } else {
- $title = loc("Reject [_1] #[_2] ([_3])", $name, $Ticket->id, $Ticket->Subject);
- }
+} elsif ( $DefaultStatus eq 'rejected' ) {
+ if ( $Type eq 'Incident' ) {
+ $title = loc("Abandon [_1] #[_2] ([_3])", $name, $Ticket->id, $Ticket->Subject);
+ } else {
+ $title = loc("Reject [_1] #[_2] ([_3])", $name, $Ticket->id, $Ticket->Subject);
+ }
} else {
$title = loc("Update [_1] #[_2] ([_3])", $name, $Ticket->id, $Ticket->Subject);
}
@@ -143,23 +138,24 @@
my ($CommentDefault, $ResponseDefault);
if (($Action eq 'Comment') or ($ARGS{'UpdateType'} eq 'private')) {
- $CommentDefault = "SELECTED";
+ $CommentDefault = "SELECTED";
} else {
$ResponseDefault = "SELECTED";
}
my $Subject;
if ($ARGS{'UpdateSubject'}) {
- $Subject = $ARGS{'UpdateSubject'};
+ $Subject = $ARGS{'UpdateSubject'};
} elsif ($Ticket) {
- $Subject = $Ticket->Subject;
+ $Subject = $Ticket->Subject;
}
my $replystring = lc(RT->Config->Get('ReplyString'));
if ( $Action eq 'Respond' &&
$replystring &&
- lc(substr($Subject, 0, length($replystring))) ne $replystring) {
- $Subject = RT->Config->Get('ReplyString') . " " . $Subject;
+ lc(substr($Subject, 0, length($replystring))) ne $replystring)
+{
+ $Subject = RT->Config->Get('ReplyString') . " " . $Subject;
}
$CanRespond = 1 if ( $Ticket->CurrentUserHasRight('ReplyToTicket') or
@@ -172,13 +168,13 @@
# {{{ deal with deleting uploaded attachments
foreach my $key (keys %ARGS) {
if ($key =~ m/^DeleteAttach-(.+)$/) {
- delete $session{'Attachments'}{$1};
+ delete $session{'Attachments'}{$1};
}
$session{'Attachments'} = { %{$session{'Attachments'} || {}} };
}
# {{{ store the uploaded attachment in session
-if ($ARGS{'Attach'}) { # attachment?
+if ($ARGS{'Attach'}) { # attachment?
$session{'Attachments'} = {} unless defined $session{'Attachments'};
# strip leading directories
@@ -189,8 +185,10 @@
Body => "",
AttachmentFieldName => 'Attach'
);
- $session{'Attachments'} = { %{$session{'Attachments'} || {}},
- $ARGS{'Attach'} => $attachment };
+ $session{'Attachments'} = {
+ %{$session{'Attachments'} || {}},
+ $ARGS{'Attach'} => $attachment,
+ };
}
# }}}
Modified: rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_ResolveChildren.pm
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_ResolveChildren.pm (original)
+++ rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_ResolveChildren.pm Wed Mar 22 15:25:14 2006
@@ -48,6 +48,8 @@
use strict;
use base 'RT::Action::RTIR';
+use RT::IR::Ticket;
+
=head2 Prepare
Check if the Incident is being closed.
@@ -88,7 +90,7 @@
my $members = new RT::Tickets( $self->TransactionObj->CurrentUser );
$members->FromSQL( $query );
while ( my $member = $members->Next ) {
- if ( $self->HasOtherUnresolvedParents( $member ) ) {
+ if ( RT::IR::Ticket::IsLinkedToActiveIncidents( $member, $self->TicketObj ) ) {
$member->Comment(Content => <<END);
Linked Incident \#$id was resolved, but ticket still has unresolved linked Incidents.
@@ -102,20 +104,6 @@
return 1;
}
-sub HasOtherUnresolvedParents {
- my $self = shift;
- my $child = shift;
-
- my $query = "Queue = 'Incidents'"
- ." AND id != ". $self->TicketObj->Id
- ." AND HasMember = ". $child->id
- ." AND ( ". join(" OR ", map "Status = '$_'", RT->Config->Get('ActiveStatus') ) ." ) ";
-
- my $tickets = new RT::Tickets( $self->TransactionObj->CurrentUser );
- $tickets->FromSQL( $query );
- return $tickets->Count;
-}
-
# }}}
eval "require RT::Action::RTIR_ResolveChildren_Vendor";
Modified: rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetBlockState.pm
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetBlockState.pm (original)
+++ rtir/branches/1.9-EXPERIMENTAL/lib/RT/Action/RTIR_SetBlockState.pm Wed Mar 22 15:25:14 2006
@@ -62,6 +62,7 @@
open => 'active',
stalled => 'pending removal',
resolved => 'removed',
+ rejected => 'removed',
);
return $state{ $self->TicketObj->Status } || '';
}
Modified: rtir/branches/1.9-EXPERIMENTAL/lib/RT/IR/Ticket.pm
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/lib/RT/IR/Ticket.pm (original)
+++ rtir/branches/1.9-EXPERIMENTAL/lib/RT/IR/Ticket.pm Wed Mar 22 15:25:14 2006
@@ -24,4 +24,31 @@
return $ticket->FirstCustomFieldValue( $field );
}
+=head2 IsLinkedToActiveIncidents $ChildObj [$IncidentObj]
+
+Returns number of active incedents linked to child ticket
+(IR, Investigation, Block or other). If second argument provided
+then it's excluded from count.
+
+When function return zero that means that object has no active
+parent incidents.
+
+=cut
+
+sub IsLinkedToActiveIncidents {
+ my $child = shift;
+ my $parent = shift;
+
+ my $query = "Queue = 'Incidents'"
+ ." AND HasMember = ". $child->id
+ ." AND ( ". join(" OR ", map "Status = '$_'", RT->Config->Get('ActiveStatus') ) ." ) ";
+
+ $query .= " AND id != ". $parent->Id if $parent;
+
+ my $tickets = new RT::Tickets( $child->CurrentUser );
+ $tickets->FromSQL( $query );
+ return $tickets->Count;
+}
+
+
1;
More information about the Rt-commit
mailing list