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

30 lines
706 B
Perl
Raw Normal View History

2018-04-27 18:18:17 +00:00
package RT::Condition::CheckTransactionFlags;
use strict;
use warnings;
use base qw(RT::Condition);
sub IsApplicable {
my $self = shift;
my $txn = $self->TransactionObj;
my @flags = split(" ", $self->Argument || "");
foreach my $flag (@flags) {
unless ($flag =~ /^(!?)(\w+)$/) {
$RT::Logger->Error("Argument '$flag' is malformed");
return 0;
}
my $method = $txn->can($2);
unless (defined($method)) {
$RT::Logger->Error("Argument '$flag' refers to nonexistent transaction method");
return 0;
}
return 0 unless (!!$txn->$method == !$1);
}
return 1;
}
RT::Base->_ImportOverlays();
1;