+ my %args = ( TicketObj => undef,
+ Ticket => undef,
+ Transaction => undef,
+ TransactionObj => undef,
+ Stage => undef,
+ Type => undef,
+ @_ );
+
+ # RT::Scrips->_SetupSourceObjects will clobber
+ # the CurrentUser, but we need to keep this ticket
+ # so that the _TransactionBatch cache is maintained
+ # and doesn't run twice. sigh.
+ $self->_StashCurrentUser( TicketObj => $args{TicketObj} ) if $args{TicketObj};
+
+ #We're really going to need a non-acled ticket for the scrips to work
+ $self->_SetupSourceObjects( TicketObj => $args{'TicketObj'},
+ Ticket => $args{'Ticket'},
+ TransactionObj => $args{'TransactionObj'},
+ Transaction => $args{'Transaction'} );
+
+
+ $self->_FindScrips( Stage => $args{'Stage'}, Type => $args{'Type'} );
+
+
+ #Iterate through each script and check it's applicability.
+ while ( my $scrip = $self->Next() ) {
+
+ unless ( $scrip->IsApplicable(
+ TicketObj => $self->{'TicketObj'},
+ TransactionObj => $self->{'TransactionObj'}
+ ) ) {
+ $RT::Logger->debug("Skipping Scrip #".$scrip->Id." because it isn't applicable");
+ next;
+ }
+
+ #If it's applicable, prepare and commit it
+ unless ( $scrip->Prepare( TicketObj => $self->{'TicketObj'},
+ TransactionObj => $self->{'TransactionObj'}
+ ) ) {
+ $RT::Logger->debug("Skipping Scrip #".$scrip->Id." because it didn't Prepare");
+ next;
+ }
+ push @{$self->{'prepared_scrips'}}, $scrip;
+
+ }
+
+ # Apply the bandaid.
+ $self->_RestoreCurrentUser( TicketObj => $args{TicketObj} ) if $args{TicketObj};
+
+
+ return (@{$self->Prepared});
+
+};
+
+=head2 Prepared
+
+Returns an arrayref of the scrips this object has prepared
+
+
+=cut
+
+sub Prepared {
+ my $self = shift;
+ return ($self->{'prepared_scrips'} || []);