diff options
Diffstat (limited to 'rt/lib/RT/Condition')
| -rw-r--r-- | rt/lib/RT/Condition/AnyTransaction.pm | 69 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/BeforeDue.pm | 83 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/CloseTicket.pm | 81 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/CustomFieldChange.pm | 56 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/CustomFieldTransaction.pm | 86 | ||||
| -rwxr-xr-x | rt/lib/RT/Condition/Generic.pm | 74 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/Overdue.pm | 84 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/OwnerChange.pm | 75 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/PriorityChange.pm | 74 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/PriorityExceeds.pm | 72 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/QueueChange.pm | 72 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/ReopenTicket.pm | 86 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/StatusChange.pm | 75 | ||||
| -rw-r--r-- | rt/lib/RT/Condition/UserDefined.pm | 74 |
14 files changed, 1061 insertions, 0 deletions
diff --git a/rt/lib/RT/Condition/AnyTransaction.pm b/rt/lib/RT/Condition/AnyTransaction.pm new file mode 100644 index 000000000..755879479 --- /dev/null +++ b/rt/lib/RT/Condition/AnyTransaction.pm @@ -0,0 +1,69 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +package RT::Condition::AnyTransaction; +use base 'RT::Condition'; + +use strict; + + +=head2 IsApplicable + +This happens on every transaction. it's always applicable + +=cut + +sub IsApplicable { + my $self = shift; + return(1); +} + +RT::Base->_ImportOverlays(); + +1; + diff --git a/rt/lib/RT/Condition/BeforeDue.pm b/rt/lib/RT/Condition/BeforeDue.pm new file mode 100644 index 000000000..d119ff018 --- /dev/null +++ b/rt/lib/RT/Condition/BeforeDue.pm @@ -0,0 +1,83 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +package RT::Condition::BeforeDue; +use base 'RT::Condition'; + +use RT::Date; + +use strict; + +sub IsApplicable { + my $self = shift; + + # Parse date string. Format is "1d2h3m4s" for 1 day and 2 hours + # and 3 minutes and 4 seconds. + my %e; + foreach (qw(d h m s)) { + my @vals = $self->Argument =~ m/(\d+)$_/; + $e{$_} = pop @vals || 0; + } + my $elapse = $e{'d'} * 24*60*60 + $e{'h'} * 60*60 + $e{'m'} * 60 + $e{'s'}; + + my $cur = new RT::Date( $RT::SystemUser ); + $cur->SetToNow(); + my $due = $self->TicketObj->DueObj; + return (undef) if $due->Unix <= 0; + + my $diff = $due->Diff($cur); + if ( $diff >= 0 and $diff <= $elapse ) { + return(1); + } else { + return(undef); + } +} + +RT::Base->_ImportOverlays(); + +1; diff --git a/rt/lib/RT/Condition/CloseTicket.pm b/rt/lib/RT/Condition/CloseTicket.pm new file mode 100644 index 000000000..ec3c24f6f --- /dev/null +++ b/rt/lib/RT/Condition/CloseTicket.pm @@ -0,0 +1,81 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +package RT::Condition::CloseTicket; + +use strict; +use warnings; + +use base 'RT::Condition'; + + +=head2 IsApplicable + +If the ticket was closed, ie status was changed from any active status to +an inactive. See F<RT_Config.pm> for C<ActiveStatuses> and C<InactiveStatuses> +options. + +=cut + +sub IsApplicable { + my $self = shift; + + my $txn = $self->TransactionObj; + return 0 unless $txn->Type eq "Status" || + ( $txn->Type eq "Set" && $txn->Field eq "Status" ); + + my $queue = $self->TicketObj->QueueObj; + return 0 unless $queue->IsActiveStatus( $txn->OldValue ); + return 0 unless $queue->IsInactiveStatus( $txn->NewValue ); + + return 1; +} + +RT::Base->_ImportOverlays(); + +1; diff --git a/rt/lib/RT/Condition/CustomFieldChange.pm b/rt/lib/RT/Condition/CustomFieldChange.pm new file mode 100644 index 000000000..b9228a50f --- /dev/null +++ b/rt/lib/RT/Condition/CustomFieldChange.pm @@ -0,0 +1,56 @@ +package RT::Condition::CustomFieldChange; +use base 'RT::Condition'; +use strict; + +=head2 IsApplicable + +If a custom field has a particular value. + +=cut + +# Based on Chuck Boeheim's code posted on the RT Wiki 3/13/06 + +sub IsApplicable { + my $self = shift; + my $trans = $self->TransactionObj; + my $scrip = $self->ScripObj; + my %Rules = $self->Rules; + my ($field, $value) = @Rules{'field', 'value'}; + return if !defined($field) or !defined($value); + + if ($trans->Type eq 'Create') { + return 1 if $trans->TicketObj->FirstCustomFieldValue($field) eq $value; + } + if ($trans->Type eq 'CustomField') { + my $cf = RT::CustomField->new($self->CurrentUser); + $cf->Load($field); + return 1 if $trans->Field == $cf->Id and $trans->NewValue eq $value; + } + return undef; +} + +sub Options { + my $self = shift; + my %args = ( 'QueueObj' => undef, @_ ); + my $QueueObj = $args{'QueueObj'}; + my $cfs = $QueueObj->TicketCustomFields(); + my @fieldnames; + while ( my $cf = $cfs->Next ) { + push @fieldnames, $cf->Name, $cf->Name; + } + return ( + { + 'name' => 'field', + 'label' => 'Custom Field', + 'type' => 'select', + 'options' => \@fieldnames, + }, + { + 'name' => 'value', + 'label' => 'Value', + 'type' => 'text', + }, + ); +} +1; + diff --git a/rt/lib/RT/Condition/CustomFieldTransaction.pm b/rt/lib/RT/Condition/CustomFieldTransaction.pm new file mode 100644 index 000000000..137f74aa6 --- /dev/null +++ b/rt/lib/RT/Condition/CustomFieldTransaction.pm @@ -0,0 +1,86 @@ +package RT::Condition::CustomFieldTransaction; +use base 'RT::Condition'; +use strict; + +=head1 NAME + +RT::Condition::CustomFieldTransaction + +=head1 DESCRIPTION + +Returns true if a transaction changed the value of a custom field. Unlike +CustomFieldChange, this condition doesn't care what the value was, only that +it changed. + +=head2 Parameters + +=over 4 + +=item field (string) + +Only return true if the transaction changed a custom field with this name. +If empty, returns true for any CustomField-type transaction. + +=item include_create (boolean) - Also return true for Create-type transactions. +If 'field' is specified, return true if that field is non-empty in the newly +created object. + +=back + +=head2 IsApplicable + +If the transaction has changed the value of a custom field. + +=head1 BUGS + +Probably interacts badly with multiple custom fields with the same name. + +=cut + +sub IsApplicable { + my $self = shift; + my $trans = $self->TransactionObj; + my $scrip = $self->ScripObj; + my %Rules = $self->Rules; + my ($field, $include_create) = @Rules{'field', 'include_create'}; + + if ( $include_create and $trans->Type eq 'Create' ) { + return 1 if !defined($field); + return 1 if defined($trans->TicketObj->FirstCustomFieldValue($field)); + } + if ($trans->Type eq 'CustomField') { + return 1 if !defined($field); + my $cf = RT::CustomField->new($self->CurrentUser); + $cf->Load($field); + return 1 if defined($cf->Id) and $trans->Field == $cf->Id; + } + return undef; +} + +sub Options { + my $self = shift; + my %args = ( 'QueueObj' => undef, @_ ); + my $cfs = RT::CustomFields->new($self->CurrentUser); + # Allow any ticket custom field to be selected; if it doesn't apply to the + # ticket, it will never contain a value and that's fine. + $cfs->LimitToLookupType('RT::Queue-RT::Ticket'); + my @fieldnames = ('', '(any field)'); + while ( my $cf = $cfs->Next ) { + push @fieldnames, $cf->Name, $cf->Name; + } + return ( + { + 'name' => 'field', + 'label' => 'Custom Field', + 'type' => 'select', + 'options' => \@fieldnames, + }, + { + 'name' => 'include_create', + 'label' => 'Trigger on ticket creation', + 'type' => 'checkbox', + }, + ); +} +1; + diff --git a/rt/lib/RT/Condition/Generic.pm b/rt/lib/RT/Condition/Generic.pm new file mode 100755 index 000000000..a3bfa7585 --- /dev/null +++ b/rt/lib/RT/Condition/Generic.pm @@ -0,0 +1,74 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +=head1 NAME + + RT::Condition::Generic - deprecated, see RT::Condition + +=head1 SYNOPSIS + + use RT::Condition::Generic; + +=head1 DESCRIPTION + +This module is provided only for backwards compatibility. + +=head1 METHODS + + +=cut + +use strict; +use warnings; +package RT::Condition::Generic; +use base 'RT::Condition'; + +RT::Base->_ImportOverlays(); + +1; + diff --git a/rt/lib/RT/Condition/Overdue.pm b/rt/lib/RT/Condition/Overdue.pm new file mode 100644 index 000000000..17f71f546 --- /dev/null +++ b/rt/lib/RT/Condition/Overdue.pm @@ -0,0 +1,84 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +=head1 NAME + +RT::Condition::Overdue + +=head1 DESCRIPTION + +Returns true if the ticket we're operating on is overdue + +=cut + +package RT::Condition::Overdue; +use base 'RT::Condition'; +use strict; + + +=head2 IsApplicable + +If the due date is before "now" return true + +=cut + +sub IsApplicable { + my $self = shift; + if ($self->TicketObj->DueObj->Unix > 0 and + $self->TicketObj->DueObj->Unix < time()) { + return(1); + } + else { + return(undef); + } +} + +RT::Base->_ImportOverlays(); + +1; + diff --git a/rt/lib/RT/Condition/OwnerChange.pm b/rt/lib/RT/Condition/OwnerChange.pm new file mode 100644 index 000000000..42048cd01 --- /dev/null +++ b/rt/lib/RT/Condition/OwnerChange.pm @@ -0,0 +1,75 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +package RT::Condition::OwnerChange; +use base 'RT::Condition'; +use strict; + + +=head2 IsApplicable + +If we're changing the owner return true, otherwise return false + + + +=cut + +sub IsApplicable { + my $self = shift; + if ( ( $self->TransactionObj->Field || '' ) eq 'Owner' ) { + return(1); + } + else { + return(undef); + } +} + +RT::Base->_ImportOverlays(); + +1; + diff --git a/rt/lib/RT/Condition/PriorityChange.pm b/rt/lib/RT/Condition/PriorityChange.pm new file mode 100644 index 000000000..b13b48dac --- /dev/null +++ b/rt/lib/RT/Condition/PriorityChange.pm @@ -0,0 +1,74 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +package RT::Condition::PriorityChange; +use base 'RT::Condition'; +use strict; + + +=head2 IsApplicable + +If the argument passed in is equivalent to the new value of +the Priority Obj + +=cut + +sub IsApplicable { + my $self = shift; + if ($self->TransactionObj->Field eq 'Priority') { + return(1); + } + else { + return(undef); + } +} + +RT::Base->_ImportOverlays(); + +1; + diff --git a/rt/lib/RT/Condition/PriorityExceeds.pm b/rt/lib/RT/Condition/PriorityExceeds.pm new file mode 100644 index 000000000..916b71d8a --- /dev/null +++ b/rt/lib/RT/Condition/PriorityExceeds.pm @@ -0,0 +1,72 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +package RT::Condition::PriorityExceeds; +use base 'RT::Condition'; +use strict; + +=head2 IsApplicable + +If the priority exceeds the argument value + +=cut + +sub IsApplicable { + my $self = shift; + if ($self->TicketObj->Priority > $self->Argument) { + return(1); + } + else { + return(undef); + } +} + +RT::Base->_ImportOverlays(); + +1; + diff --git a/rt/lib/RT/Condition/QueueChange.pm b/rt/lib/RT/Condition/QueueChange.pm new file mode 100644 index 000000000..dab4299ad --- /dev/null +++ b/rt/lib/RT/Condition/QueueChange.pm @@ -0,0 +1,72 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +package RT::Condition::QueueChange; +use base 'RT::Condition'; +use strict; + +=head2 IsApplicable + +If the queue has changed. + +=cut + +sub IsApplicable { + my $self = shift; + if ($self->TransactionObj->Field eq 'Queue') { + return(1); + } + else { + return(undef); + } +} + +RT::Base->_ImportOverlays(); + +1; + diff --git a/rt/lib/RT/Condition/ReopenTicket.pm b/rt/lib/RT/Condition/ReopenTicket.pm new file mode 100644 index 000000000..cf1b91ff4 --- /dev/null +++ b/rt/lib/RT/Condition/ReopenTicket.pm @@ -0,0 +1,86 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +package RT::Condition::ReopenTicket; + +use strict; +use warnings; + +use base 'RT::Condition'; + + +=head2 IsApplicable + +If the ticket was repopened, ie status was changed from any inactive status to +an active. See F<RT_Config.pm> for C<ActiveStatuses> and C<InactiveStatuses> +options. + +=cut + +sub IsApplicable { + my $self = shift; + + my $txn = $self->TransactionObj; + return 0 unless $txn->Type eq "Status" || + ( $txn->Type eq "Set" && $txn->Field eq "Status" ); + + my $queue = $self->TicketObj->QueueObj; + return 0 unless $queue->IsInactiveStatus( $txn->OldValue ); + return 0 unless $queue->IsActiveStatus( $txn->NewValue ); + + $RT::Logger->debug("Condition 'On Reopen' triggered " + ."for ticket #". $self->TicketObj->id + ." transaction #". $txn->id + ); + + return 1; +} + +RT::Base->_ImportOverlays(); + +1; diff --git a/rt/lib/RT/Condition/StatusChange.pm b/rt/lib/RT/Condition/StatusChange.pm new file mode 100644 index 000000000..b20a5ac25 --- /dev/null +++ b/rt/lib/RT/Condition/StatusChange.pm @@ -0,0 +1,75 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +package RT::Condition::StatusChange; +use base 'RT::Condition'; +use strict; + + +=head2 IsApplicable + +If the argument passed in is equivalent to the new value of +the Status Obj + +=cut + +sub IsApplicable { + my $self = shift; + if (($self->TransactionObj->Field eq 'Status') and + ($self->Argument eq $self->TransactionObj->NewValue())) { + return(1); + } + else { + return(undef); + } +} + +RT::Base->_ImportOverlays(); + +1; + diff --git a/rt/lib/RT/Condition/UserDefined.pm b/rt/lib/RT/Condition/UserDefined.pm new file mode 100644 index 000000000..fac339456 --- /dev/null +++ b/rt/lib/RT/Condition/UserDefined.pm @@ -0,0 +1,74 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# <sales@bestpractical.com> +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + +package RT::Condition::UserDefined; +use base 'RT::Condition'; +use strict; + + +=head2 IsApplicable + +This happens on every transaction. it's always applicable + +=cut + +sub IsApplicable { + my $self = shift; + local $@; + my $retval = eval $self->ScripObj->CustomIsApplicableCode; + if ($@) { + $RT::Logger->error("Scrip ".$self->ScripObj->Id. " IsApplicable failed: ".$@); + return (undef); + } + return ($retval); +} + +RT::Base->_ImportOverlays(); + +1; + |
