RT-Extension-Conservancy/lib/RT/Condition/StatusChangeWithDependents.pm

35 lines
875 B
Perl
Raw Normal View History

package RT::Condition::StatusChangeWithDependents;
use strict;
use warnings;
use base qw(RT::Condition::StatusChange);
sub Argument {
# Take the dependents setting out of the argument, so StatusChange gets
# everything else.
my $self = shift;
$self->SUPER::Argument =~ s/^\s*dependents\s*(<|>|[=!<>]=)\s*(\d+)\s*;?//r;
}
sub IsApplicable {
my $self = shift;
my $argument = $self->SUPER::Argument;
my ($op, $operand);
if ($argument =~ /^\s*dependents\s*(<|>|[=!<>]=)\s*(\d+)\s*;?/) {
$op = $1;
$operand = $2;
} else {
$RT::Logger->error("Argument '$argument' is incorrect");
return 0;
}
return 0 unless $self->SUPER::IsApplicable;
my $dep_count = $self->TicketObj->DependedOnBy->Count;
return 0 unless (eval "\$dep_count $op $operand;");
return 1;
}
RT::Base->_ImportOverlays();
1;