->NotAddedTo( Scrip => $self );
}
+=head2 AddToObject
+
+Adds (applies) the current scrip to the provided queue (ObjectId).
+
+Accepts a param hash of:
+
+=over
+
+=item C<ObjectId>
+
+Queue name or id. 0 makes the scrip global.
+
+=item C<Stage>
+
+Stage to run in. Valid stages are TransactionCreate or
+TransactionBatch. Defaults to TransactionCreate. As of RT 4.2, Disabled
+is no longer a stage.
+
+=item C<Template>
+
+Name of global or queue-specific template for the scrip. Use 'Blank' for
+non-notification scrips.
+
+=item C<SortOrder>
+
+Number indicating the relative order the scrip should run in.
+
+=back
+
+Returns (val, message). If val is false, the message contains an error
+message.
+
+=cut
+
sub AddToObject {
my $self = shift;
my %args = @_%2? (ObjectId => @_) : (@_);
+ # Default Stage explicitly rather than in %args assignment to handle
+ # Stage coming in set to undef.
+ $args{'Stage'} //= 'TransactionCreate';
+
my $queue;
if ( $args{'ObjectId'} ) {
$queue = RT::Queue->new( $self->CurrentUser );
return $rec->Add( %args, Scrip => $self );
}
+=head2 RemoveFromObject
+
+Removes the current scrip to the provided queue (ObjectId).
+
+Accepts a param hash of:
+
+=over
+
+=item C<ObjectId>
+
+Queue name or id. 0 makes the scrip global.
+
+=back
+
+Returns (val, message). If val is false, the message contains an error
+message.
+
+=cut
+
sub RemoveFromObject {
my $self = shift;
my %args = @_%2? (ObjectId => @_) : (@_);
return undef;
}
+=head2 FriendlyStage($Stage)
+
+Helper function that returns a localized human-readable version of the
+C<$Stage> argument.
+
+=cut
+
+sub FriendlyStage {
+ my ( $class, $stage ) = @_;
+ my $stage_i18n_lookup = {
+ TransactionCreate => 'Normal', # loc
+ TransactionBatch => 'Batch', # loc
+ TransactionBatchDisabled => 'Batch (disabled by config)', # loc
+ };
+ $stage = 'TransactionBatchDisabled'
+ if $stage eq 'TransactionBatch'
+ and not RT->Config->Get('UseTransactionBatch');
+ return $stage_i18n_lookup->{$stage};
+}
=head2 Apply { TicketObj => undef, TransactionObj => undef}
sub _Value {
my $self = shift;
- unless ( $self->CurrentUserHasRight('ShowScrips') ) {
- $RT::Logger->debug( "CurrentUser can't see scrip #". $self->__Value('id') );
- return (undef);
- }
+ return unless $self->CurrentUserHasRight('ShowScrips');
return $self->__Value(@_);
}