CheckTransactionFlags: New Condition.

This commit is contained in:
Brett Smith 2018-04-27 14:18:17 -04:00
parent 8514ae62d5
commit 8216ff4071
3 changed files with 64 additions and 1 deletions

28
etc/upgrade/0.6/content Normal file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env perl
@ScripConditions = (
{ Name => 'On Create Inbound',
Description => 'When a ticket is created by its requestor',
ApplicableTransTypes => 'Create',
ExecModule => 'CheckTransactionFlags',
Argument => 'IsInbound',
},
{ Name => 'On Create Not Inbound',
Description => 'When a ticket is created for the requestor by someone else',
ApplicableTransTypes => 'Create',
ExecModule => 'CheckTransactionFlags',
Argument => '!IsInbound',
},
{ Name => 'On Create Not Inbound With Content',
Description => 'When a ticket with content is created for the requestor by someone else',
ApplicableTransTypes => 'Create',
ExecModule => 'CheckTransactionFlags',
Argument => '!IsInbound HasContent',
},
{ Name => 'On Create Not Inbound Without Content',
Description => 'When an empty ticket is created for the requestor by someone else',
ApplicableTransTypes => 'Create',
ExecModule => 'CheckTransactionFlags',
Argument => '!IsInbound !HasContent',
},
);

View file

@ -0,0 +1,29 @@
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;

View file

@ -2,7 +2,7 @@ use strict;
use warnings; use warnings;
package RT::Extension::Conservancy; package RT::Extension::Conservancy;
our $VERSION = '0.5'; our $VERSION = '0.6';
=pod =pod
@ -22,6 +22,12 @@ this is different from the built-in "Notify Owner or AdminCCs".
A variant of the above to send notice from the comment address. A variant of the above to send notice from the comment address.
=head3 RT::Condition::CheckTransactionFlags
A Scrip condition that calls configured boolean methods on the transaction
object and passes or fails depending on whether they match the configured
state.
=head3 RT::Condition::StatusChangeWithDependents =head3 RT::Condition::StatusChangeWithDependents
A Scrip condition that extends RT::Condition::StatusChange. The affected A Scrip condition that extends RT::Condition::StatusChange. The affected