summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Scrips_Overlay.pm
diff options
context:
space:
mode:
authorivan <ivan>2004-03-11 02:05:38 +0000
committerivan <ivan>2004-03-11 02:05:38 +0000
commit289340780927b5bac2c7604d7317c3063c6dd8cc (patch)
treec4100ab9857ae00c330213af8a46e66c208580e6 /rt/lib/RT/Scrips_Overlay.pm
parent945721f48f74d5cfffef7c7cf3a3d6bc2521f5dd (diff)
import of rt 3.0.9RT_3_0_9
Diffstat (limited to 'rt/lib/RT/Scrips_Overlay.pm')
-rw-r--r--rt/lib/RT/Scrips_Overlay.pm75
1 files changed, 75 insertions, 0 deletions
diff --git a/rt/lib/RT/Scrips_Overlay.pm b/rt/lib/RT/Scrips_Overlay.pm
index 46e31c2..d201480 100644
--- a/rt/lib/RT/Scrips_Overlay.pm
+++ b/rt/lib/RT/Scrips_Overlay.pm
@@ -129,5 +129,80 @@ sub Next {
}
# }}}
+sub Apply {
+ my ($self, %args) = @_;
+
+ #We're really going to need a non-acled ticket for the scrips to work
+ my ($TicketObj, $TransactionObj);
+
+ if ( ($TicketObj = $args{'TicketObj'}) ) {
+ $TicketObj->CurrentUser($self->CurrentUser);
+ }
+ else {
+ $TicketObj = RT::Ticket->new($self->CurrentUser);
+ $TicketObj->Load( $args{'Ticket'} )
+ || $RT::Logger->err("$self couldn't load ticket $args{'Ticket'}\n");
+ }
+
+ if ( ($TransactionObj = $args{'TransactionObj'}) ) {
+ $TransactionObj->CurrentUser($self->CurrentUser);
+ }
+ else {
+ $TransactionObj = RT::Transaction->new($self->CurrentUser);
+ $TransactionObj->Load( $args{'Transaction'} )
+ || $RT::Logger->err("$self couldn't load transaction $args{'Transaction'}\n");
+ }
+
+ # {{{ Deal with Scrips
+
+ $self->LimitToQueue( $TicketObj->QueueObj->Id )
+ ; #Limit it to $Ticket->QueueObj->Id
+ $self->LimitToGlobal()
+ unless $TicketObj->QueueObj->Disabled; # or to "global"
+
+
+ $self->Limit(FIELD => "Stage", VALUE => $args{'Stage'});
+
+
+ my $ConditionsAlias = $self->NewAlias('ScripConditions');
+
+ $self->Join(
+ ALIAS1 => 'main',
+ FIELD1 => 'ScripCondition',
+ ALIAS2 => $ConditionsAlias,
+ FIELD2 => 'id'
+ );
+
+ #We only want things where the scrip applies to this sort of transaction
+ $self->Limit(
+ ALIAS => $ConditionsAlias,
+ FIELD => 'ApplicableTransTypes',
+ OPERATOR => 'LIKE',
+ VALUE => $args{'Type'},
+ ENTRYAGGREGATOR => 'OR',
+ ) if $args{'Type'};
+
+ # Or where the scrip applies to any transaction
+ $self->Limit(
+ ALIAS => $ConditionsAlias,
+ FIELD => 'ApplicableTransTypes',
+ OPERATOR => 'LIKE',
+ VALUE => "Any",
+ ENTRYAGGREGATOR => 'OR',
+ );
+
+ #Iterate through each script and check it's applicability.
+ while ( my $Scrip = $self->Next() ) {
+ $Scrip->Apply (TicketObj => $TicketObj,
+ TransactionObj => $TransactionObj);
+ }
+
+ $TicketObj->CurrentUser( $TicketObj->OriginalUser );
+ $TransactionObj->CurrentUser( $TransactionObj->OriginalUser );
+
+ # }}}
+}
+
+
1;