1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
6 # <sales@bestpractical.com>
8 # (Except where explicitly superseded by other copyright notices)
13 # This work is made available to you under the terms of Version 2 of
14 # the GNU General Public License. A copy of that license should have
15 # been provided with this software, but in any event can be snarfed
18 # This work is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 # 02110-1301 or visit their web page on the internet at
27 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 # CONTRIBUTION SUBMISSION POLICY:
32 # (The following paragraph is not intended to limit the rights granted
33 # to you to modify and distribute this software under the terms of
34 # the GNU General Public License and is only of importance to you if
35 # you choose to contribute your changes and enhancements to the
36 # community by submitting them to Best Practical Solutions, LLC.)
38 # By intentionally submitting any modifications, corrections or
39 # derivatives to this work, or any other work intended for use with
40 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 # you are the copyright holder for those contributions and you grant
42 # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 # royalty-free, perpetual, license to use, copy, create derivative
44 # works based on those contributions, and sublicense and distribute
45 # those contributions and any derivatives thereof.
47 # END BPS TAGGED BLOCK }}}
51 RT::Scrip - an RT Scrip object
70 use base 'RT::Record';
74 use RT::ScripCondition;
85 Creates a new entry in the Scrips table. Takes a paramhash with:
91 ScripCondition => undef,
92 CustomPrepareCode => undef,
93 CustomCommitCode => undef,
94 CustomIsApplicableCode => undef,
99 Returns (retval, msg);
100 retval is 0 for failure or scrip id. msg is a textual description of what happened.
108 Template => undef, # name or id
109 ScripAction => 0, # name or id
110 ScripCondition => 0, # name or id
111 Stage => 'TransactionCreate',
112 Description => undef,
113 CustomPrepareCode => undef,
114 CustomCommitCode => undef,
115 CustomIsApplicableCode => undef,
116 ConditionRules => undef,
117 ActionRules => undef,
121 if ($args{CustomPrepareCode} || $args{CustomCommitCode} || $args{CustomIsApplicableCode}) {
122 unless ( $self->CurrentUser->HasRight( Object => $RT::System,
123 Right => 'ExecuteCode' ) )
125 return ( 0, $self->loc('Permission Denied') );
129 unless ( $args{'Queue'} ) {
130 unless ( $self->CurrentUser->HasRight( Object => $RT::System,
131 Right => 'ModifyScrips' ) )
133 return ( 0, $self->loc('Permission Denied') );
135 $args{'Queue'} = 0; # avoid undef sneaking in
138 my $QueueObj = RT::Queue->new( $self->CurrentUser );
139 $QueueObj->Load( $args{'Queue'} );
140 unless ( $QueueObj->id ) {
141 return ( 0, $self->loc('Invalid queue') );
143 unless ( $QueueObj->CurrentUserHasRight('ModifyScrips') ) {
144 return ( 0, $self->loc('Permission Denied') );
146 $args{'Queue'} = $QueueObj->id;
149 #TODO +++ validate input
151 return ( 0, $self->loc("Action is mandatory argument") )
152 unless $args{'ScripAction'};
153 my $action = RT::ScripAction->new( $self->CurrentUser );
154 $action->Load( $args{'ScripAction'} );
155 return ( 0, $self->loc( "Action '[_1]' not found", $args{'ScripAction'} ) )
158 return ( 0, $self->loc("Template is mandatory argument") )
159 unless $args{'Template'};
160 my $template = RT::Template->new( $self->CurrentUser );
161 if ( $args{'Template'} =~ /\D/ ) {
162 $template->LoadByName( Name => $args{'Template'}, Queue => $args{'Queue'} );
163 return ( 0, $self->loc( "Global template '[_1]' not found", $args{'Template'} ) )
164 if !$template->Id && !$args{'Queue'};
165 return ( 0, $self->loc( "Global or queue specific template '[_1]' not found", $args{'Template'} ) )
168 $template->Load( $args{'Template'} );
169 return ( 0, $self->loc( "Template '[_1]' not found", $args{'Template'} ) )
170 unless $template->Id;
172 return (0, $self->loc( "Template '[_1]' is not global" ))
173 if !$args{'Queue'} && $template->Queue;
174 return (0, $self->loc( "Template '[_1]' is not global nor queue specific" ))
175 if $args{'Queue'} && $template->Queue && $template->Queue != $args{'Queue'};
178 return ( 0, $self->loc("Condition is mandatory argument") )
179 unless $args{'ScripCondition'};
180 my $condition = RT::ScripCondition->new( $self->CurrentUser );
181 $condition->Load( $args{'ScripCondition'} );
182 return ( 0, $self->loc( "Condition '[_1]' not found", $args{'ScripCondition'} ) )
183 unless $condition->Id;
185 if ( $args{'Stage'} eq 'Disabled' ) {
186 $RT::Logger->warning("Disabled Stage is deprecated");
187 $args{'Stage'} = 'TransactionCreate';
188 $args{'Disabled'} = 1;
190 $args{'Disabled'} ||= 0;
192 my ( $id, $msg ) = $self->SUPER::Create(
193 Template => $template->Name,
194 ScripCondition => $condition->id,
195 ScripAction => $action->Id,
196 Disabled => $args{'Disabled'},
197 Description => $args{'Description'},
198 CustomPrepareCode => $args{'CustomPrepareCode'},
199 CustomCommitCode => $args{'CustomCommitCode'},
200 CustomIsApplicableCode => $args{'CustomIsApplicableCode'},
201 ConditionRules => $args{'ConditionRules'},
202 ActionRules => $args{'ActionRules'},
204 return ( $id, $msg ) unless $id;
206 (my $status, $msg) = RT::ObjectScrip->new( $self->CurrentUser )->Add(
208 Stage => $args{'Stage'},
209 ObjectId => $args{'Queue'},
211 $RT::Logger->error( "Couldn't add scrip: $msg" ) unless $status;
213 return ( $id, $self->loc('Scrip Created') );
227 unless ( $self->CurrentUserHasRight('ModifyScrips') ) {
228 return ( 0, $self->loc('Permission Denied') );
231 RT::ObjectScrip->new( $self->CurrentUser )->DeleteAll( Scrip => $self );
233 return ( $self->SUPER::Delete(@_) );
236 sub IsGlobal { return shift->IsAdded(0) }
240 my $record = RT::ObjectScrip->new( $self->CurrentUser );
241 $record->LoadByCols( Scrip => $self->id, ObjectId => shift || 0 );
242 return undef unless $record->id;
248 my $record = RT::ObjectScrip->new( $self->CurrentUser );
249 $record->LoadByCols( Scrip => $self->id );
250 return $record->id ? 1 : 0;
255 return RT::ObjectScrip->new( $self->CurrentUser )
256 ->AddedTo( Scrip => $self );
261 return RT::ObjectScrip->new( $self->CurrentUser )
262 ->NotAddedTo( Scrip => $self );
267 Adds (applies) the current scrip to the provided queue (ObjectId).
269 Accepts a param hash of:
275 Queue name or id. 0 makes the scrip global.
279 Stage to run in. Valid stages are TransactionCreate or
280 TransactionBatch. Defaults to TransactionCreate. As of RT 4.2, Disabled
281 is no longer a stage.
285 Name of global or queue-specific template for the scrip. Use 'Blank' for
286 non-notification scrips.
290 Number indicating the relative order the scrip should run in.
294 Returns (val, message). If val is false, the message contains an error
301 my %args = @_%2? (ObjectId => @_) : (@_);
303 # Default Stage explicitly rather than in %args assignment to handle
304 # Stage coming in set to undef.
305 $args{'Stage'} //= 'TransactionCreate';
308 if ( $args{'ObjectId'} ) {
309 $queue = RT::Queue->new( $self->CurrentUser );
310 $queue->Load( $args{'ObjectId'} );
311 return (0, $self->loc('Invalid queue'))
314 $args{'ObjectId'} = $queue->id;
316 return ( 0, $self->loc('Permission Denied') )
317 unless $self->CurrentUser->PrincipalObj->HasRight(
318 Object => $queue || $RT::System, Right => 'ModifyScrips',
322 my $tname = $self->Template;
323 my $template = RT::Template->new( $self->CurrentUser );
324 $template->LoadByName( Queue => $queue? $queue->id : 0, Name => $tname );
325 unless ( $template->id ) {
327 return (0, $self->loc('No template [_1] in queue [_2] or global',
328 $tname, $queue->Name||$queue->id));
330 return (0, $self->loc('No global template [_1]', $tname));
334 my $rec = RT::ObjectScrip->new( $self->CurrentUser );
335 return $rec->Add( %args, Scrip => $self );
338 =head2 RemoveFromObject
340 Removes the current scrip to the provided queue (ObjectId).
342 Accepts a param hash of:
348 Queue name or id. 0 makes the scrip global.
352 Returns (val, message). If val is false, the message contains an error
357 sub RemoveFromObject {
359 my %args = @_%2? (ObjectId => @_) : (@_);
362 if ( $args{'ObjectId'} ) {
363 $queue = RT::Queue->new( $self->CurrentUser );
364 $queue->Load( $args{'ObjectId'} );
365 return (0, $self->loc('Invalid queue id'))
368 return ( 0, $self->loc('Permission Denied') )
369 unless $self->CurrentUser->PrincipalObj->HasRight(
370 Object => $queue || $RT::System, Right => 'ModifyScrips',
374 my $rec = RT::ObjectScrip->new( $self->CurrentUser );
375 $rec->LoadByCols( Scrip => $self->id, ObjectId => $args{'ObjectId'} );
376 return (0, $self->loc('Scrip is not added') ) unless $rec->id;
382 Retuns an RT::Action object with this Scrip's Action
389 unless ( defined $self->{'ScripActionObj'} ) {
390 require RT::ScripAction;
391 $self->{'ScripActionObj'} = RT::ScripAction->new( $self->CurrentUser );
392 $self->{'ScripActionObj'}->Load( $self->ScripAction );
394 return ( $self->{'ScripActionObj'} );
401 Retuns an L<RT::ScripCondition> object with this Scrip's IsApplicable
408 my $res = RT::ScripCondition->new( $self->CurrentUser );
409 $res->Load( $self->ScripCondition );
416 Loads scrip's condition and action modules.
423 $self->ConditionObj->LoadCondition;
424 $self->ActionObj->LoadAction;
430 Retuns an RT::Template object with this Scrip's Template
438 my $res = RT::Template->new( $self->CurrentUser );
439 $res->LoadByName( Queue => $queue, Name => $self->Template );
445 Takes TicketObj named argument and returns scrip's stage when
446 added to ticket's queue.
452 my %args = ( TicketObj => undef, @_ );
454 my $queue = $args{'TicketObj'}->Queue;
455 my $rec = RT::ObjectScrip->new( $self->CurrentUser );
456 $rec->LoadByCols( Scrip => $self->id, ObjectId => $queue );
457 return $rec->Stage if $rec->id;
459 $rec->LoadByCols( Scrip => $self->id, ObjectId => 0 );
460 return $rec->Stage if $rec->id;
465 =head2 FriendlyStage($Stage)
467 Helper function that returns a localized human-readable version of the
473 my ( $class, $stage ) = @_;
474 my $stage_i18n_lookup = {
475 TransactionCreate => 'Normal', # loc
476 TransactionBatch => 'Batch', # loc
477 TransactionBatchDisabled => 'Batch (disabled by config)', # loc
479 $stage = 'TransactionBatchDisabled'
480 if $stage eq 'TransactionBatch'
481 and not RT->Config->Get('UseTransactionBatch');
482 return $stage_i18n_lookup->{$stage};
485 =head2 Apply { TicketObj => undef, TransactionObj => undef}
487 This method instantiates the ScripCondition and ScripAction objects for a
488 single execution of this scrip. it then calls the IsApplicable method of the
490 If that succeeds, it calls the Prepare method of the
491 ScripAction. If that succeeds, it calls the Commit method of the ScripAction.
493 Usually, the ticket and transaction objects passed to this method
494 should be loaded by the SuperUser role
499 # XXX TODO : This code appears to be obsoleted in favor of similar code in Scrips->Apply.
500 # Why is this here? Is it still called?
504 my %args = ( TicketObj => undef,
505 TransactionObj => undef,
508 $RT::Logger->debug("Now applying scrip ".$self->Id . " for transaction ".$args{'TransactionObj'}->id);
510 my $ApplicableTransactionObj = $self->IsApplicable( TicketObj => $args{'TicketObj'},
511 TransactionObj => $args{'TransactionObj'} );
512 unless ( $ApplicableTransactionObj ) {
516 if ( $ApplicableTransactionObj->id != $args{'TransactionObj'}->id ) {
517 $RT::Logger->debug("Found an applicable transaction ".$ApplicableTransactionObj->Id . " in the same batch with transaction ".$args{'TransactionObj'}->id);
520 #If it's applicable, prepare and commit it
521 $RT::Logger->debug("Now preparing scrip ".$self->Id . " for transaction ".$ApplicableTransactionObj->id);
522 unless ( $self->Prepare( TicketObj => $args{'TicketObj'},
523 TransactionObj => $ApplicableTransactionObj )
528 $RT::Logger->debug("Now commiting scrip ".$self->Id . " for transaction ".$ApplicableTransactionObj->id);
529 unless ( $self->Commit( TicketObj => $args{'TicketObj'},
530 TransactionObj => $ApplicableTransactionObj)
535 $RT::Logger->debug("We actually finished scrip ".$self->Id . " for transaction ".$ApplicableTransactionObj->id);
544 Calls the Condition object's IsApplicable method
546 Upon success, returns the applicable Transaction object.
547 Otherwise, undef is returned.
549 If the Scrip is in the TransactionCreate Stage (the usual case), only test
550 the associated Transaction object to see if it is applicable.
552 For Scrips in the TransactionBatch Stage, test all Transaction objects
553 created during the Ticket object's lifetime, and returns the first one
560 my %args = ( TicketObj => undef,
561 TransactionObj => undef,
569 my $stage = $self->Stage( TicketObj => $args{'TicketObj'} );
572 "Scrip #". $self->id ." is not applied to"
573 ." queue #". $args{'TicketObj'}->Queue
577 elsif ( $stage eq 'TransactionCreate') {
578 # Only look at our current Transaction
579 @Transactions = ( $args{'TransactionObj'} );
581 elsif ( $stage eq 'TransactionBatch') {
582 # Look at all Transactions in this Batch
583 @Transactions = @{ $args{'TicketObj'}->TransactionBatch || [] };
586 $RT::Logger->error( "Unknown Scrip stage: '$stage'" );
589 my $ConditionObj = $self->ConditionObj;
590 foreach my $TransactionObj ( @Transactions ) {
591 # in TxnBatch stage we can select scrips that are not applicable to all txns
592 my $txn_type = $TransactionObj->Type;
593 next unless( $ConditionObj->ApplicableTransTypes =~ /(?:^|,)(?:Any|\Q$txn_type\E)(?:,|$)/i );
594 # Load the scrip's Condition object
595 $ConditionObj->LoadCondition(
597 TicketObj => $args{'TicketObj'},
598 TransactionObj => $TransactionObj,
601 if ( $ConditionObj->IsApplicable() ) {
602 # We found an application Transaction -- return it
603 $return = $TransactionObj;
610 $RT::Logger->error( "Scrip IsApplicable " . $self->Id . " died. - " . $@ );
622 Calls the action object's prepare method
628 my %args = ( TicketObj => undef,
629 TransactionObj => undef,
634 $self->ActionObj->LoadAction(
636 TicketObj => $args{'TicketObj'},
637 TransactionObj => $args{'TransactionObj'},
638 TemplateObj => $self->TemplateObj( $args{'TicketObj'}->Queue ),
641 $return = $self->ActionObj->Prepare();
644 $RT::Logger->error( "Scrip Prepare " . $self->Id . " died. - " . $@ );
656 Calls the action object's commit method
662 my %args = ( TicketObj => undef,
663 TransactionObj => undef,
668 $return = $self->ActionObj->Commit();
671 #Searchbuilder caching isn't perfectly coherent. got to reload the ticket object, since it
673 $args{'TicketObj'}->Load( $args{'TicketObj'}->Id );
676 $RT::Logger->error( "Scrip Commit " . $self->Id . " died. - " . $@ );
680 # Not destroying or weakening hte Action and Condition here could cause a
690 # does an acl check and then passes off the call
699 unless ( $self->CurrentUserHasRight('ModifyScrips') ) {
700 $RT::Logger->debug( "CurrentUser can't modify Scrips" );
701 return ( 0, $self->loc('Permission Denied') );
705 if (exists $args{Value}) {
706 if ($args{Field} eq 'CustomIsApplicableCode' || $args{Field} eq 'CustomPrepareCode' || $args{Field} eq 'CustomCommitCode') {
707 unless ( $self->CurrentUser->HasRight( Object => $RT::System,
708 Right => 'ExecuteCode' ) ) {
709 return ( 0, $self->loc('Permission Denied') );
712 elsif ($args{Field} eq 'Queue') {
714 # moving to another queue
715 my $queue = RT::Queue->new( $self->CurrentUser );
716 $queue->Load($args{Value});
717 unless ($queue->Id and $queue->CurrentUserHasRight('ModifyScrips')) {
718 return ( 0, $self->loc('Permission Denied') );
722 unless ($self->CurrentUser->HasRight( Object => RT->System, Right => 'ModifyScrips' )) {
723 return ( 0, $self->loc('Permission Denied') );
727 elsif ($args{Field} eq 'Template') {
728 my $template = RT::Template->new( $self->CurrentUser );
729 $template->Load($args{Value});
730 unless ($template->Id and $template->CurrentUserCanRead) {
731 return ( 0, $self->loc('Permission Denied') );
736 return $self->SUPER::_Set(@_);
740 # does an acl check and then passes off the call
744 return unless $self->CurrentUserHasRight('ShowScrips');
746 return $self->__Value(@_);
749 =head2 ACLEquivalenceObjects
751 Having rights on any of the queues the scrip applies to is equivalent to
752 having rights on the scrip.
756 sub ACLEquivalenceObjects {
758 return unless $self->id;
759 return @{ $self->AddedTo->ItemsArrayRef };
766 This routine compile-checks the custom prepare, commit, and is-applicable code
767 to see if they are syntactically valid Perl. We eval them in a codeblock to
768 avoid actually executing the code.
770 If one of the fields has a compile error, only the first is reported.
772 Returns an (ok, message) pair.
779 for my $method (qw/CustomPrepareCode CustomCommitCode CustomIsApplicableCode/) {
780 my $code = $self->$method;
781 next if !defined($code);
785 eval "sub { $code \n }";
790 return (0, $self->loc("Couldn't compile [_1] codeblock '[_2]': [_3]", $method, $code, $error));
795 =head2 SetScripAction
803 return ( 0, $self->loc("Action is mandatory argument") ) unless $value;
805 require RT::ScripAction;
806 my $action = RT::ScripAction->new( $self->CurrentUser );
807 $action->Load($value);
808 return ( 0, $self->loc( "Action '[_1]' not found", $value ) )
811 return $self->_Set( Field => 'ScripAction', Value => $action->Id );
814 =head2 SetScripCondition
818 sub SetScripCondition {
822 return ( 0, $self->loc("Condition is mandatory argument") )
825 require RT::ScripCondition;
826 my $condition = RT::ScripCondition->new( $self->CurrentUser );
827 $condition->Load($value);
829 return ( 0, $self->loc( "Condition '[_1]' not found", $value ) )
830 unless $condition->Id;
832 return $self->_Set( Field => 'ScripCondition', Value => $condition->Id );
843 return ( 0, $self->loc("Template is mandatory argument") ) unless $value;
845 require RT::Template;
846 my $template = RT::Template->new( $self->CurrentUser );
847 $template->Load($value);
848 return ( 0, $self->loc( "Template '[_1]' not found", $value ) )
849 unless $template->Id;
851 return $self->_Set( Field => 'Template', Value => $template->Name );
863 Returns the current value of id.
864 (In the database, id is stored as int(11).)
872 Returns the current value of Description.
873 (In the database, Description is stored as varchar(255).)
877 =head2 SetDescription VALUE
880 Set Description to VALUE.
881 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
882 (In the database, Description will be stored as a varchar(255).)
888 =head2 ScripCondition
890 Returns the current value of ScripCondition.
891 (In the database, ScripCondition is stored as int(11).)
895 =head2 SetScripCondition VALUE
898 Set ScripCondition to VALUE.
899 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
900 (In the database, ScripCondition will be stored as a int(11).)
906 =head2 ScripConditionObj
908 Returns the ScripCondition Object which has the id returned by ScripCondition
913 sub ScripConditionObj {
915 my $ScripCondition = RT::ScripCondition->new($self->CurrentUser);
916 $ScripCondition->Load($self->__Value('ScripCondition'));
917 return($ScripCondition);
922 Returns the current value of ScripAction.
923 (In the database, ScripAction is stored as int(11).)
927 =head2 SetScripAction VALUE
930 Set ScripAction to VALUE.
931 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
932 (In the database, ScripAction will be stored as a int(11).)
938 =head2 ScripActionObj
940 Returns the ScripAction Object which has the id returned by ScripAction
947 my $ScripAction = RT::ScripAction->new($self->CurrentUser);
948 $ScripAction->Load($self->__Value('ScripAction'));
949 return($ScripAction);
952 =head2 CustomIsApplicableCode
954 Returns the current value of CustomIsApplicableCode.
955 (In the database, CustomIsApplicableCode is stored as text.)
959 =head2 SetCustomIsApplicableCode VALUE
962 Set CustomIsApplicableCode to VALUE.
963 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
964 (In the database, CustomIsApplicableCode will be stored as a text.)
970 =head2 CustomPrepareCode
972 Returns the current value of CustomPrepareCode.
973 (In the database, CustomPrepareCode is stored as text.)
977 =head2 SetCustomPrepareCode VALUE
980 Set CustomPrepareCode to VALUE.
981 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
982 (In the database, CustomPrepareCode will be stored as a text.)
988 =head2 CustomCommitCode
990 Returns the current value of CustomCommitCode.
991 (In the database, CustomCommitCode is stored as text.)
995 =head2 SetCustomCommitCode VALUE
998 Set CustomCommitCode to VALUE.
999 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
1000 (In the database, CustomCommitCode will be stored as a text.)
1008 Returns the current value of Disabled.
1009 (In the database, Disabled is stored as smallint(6).)
1013 =head2 SetDisabled VALUE
1016 Set Disabled to VALUE.
1017 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
1018 (In the database, Disabled will be stored as a smallint(6).)
1026 Returns the current value of Template.
1027 (In the database, Template is stored as varchar(200).)
1031 =head2 SetTemplate VALUE
1034 Set Template to VALUE.
1035 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
1036 (In the database, Template will be stored as a varchar(200).)
1044 Returns the current value of Creator.
1045 (In the database, Creator is stored as int(11).)
1053 Returns the current value of Created.
1054 (In the database, Created is stored as datetime.)
1060 =head2 LastUpdatedBy
1062 Returns the current value of LastUpdatedBy.
1063 (In the database, LastUpdatedBy is stored as int(11).)
1071 Returns the current value of LastUpdated.
1072 (In the database, LastUpdated is stored as datetime.)
1079 sub _CoreAccessible {
1083 {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
1085 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
1087 {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
1089 {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
1090 CustomIsApplicableCode =>
1091 {read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => ''},
1092 CustomPrepareCode =>
1093 {read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => ''},
1095 {read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => ''},
1097 {read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
1099 {read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => 'Blank'},
1101 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
1103 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
1105 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
1107 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
1112 sub FindDependencies {
1114 my ($walker, $deps) = @_;
1116 $self->SUPER::FindDependencies($walker, $deps);
1118 my $applied = RT::ObjectScrips->new( $self->CurrentUser );
1119 $applied->LimitToScrip( $self->id );
1120 $deps->Add( in => $applied );
1122 $deps->Add( out => $self->ScripConditionObj );
1123 $deps->Add( out => $self->ScripActionObj );
1124 $deps->Add( out => $self->TemplateObj );
1131 Dependencies => undef,
1134 my $deps = $args{'Dependencies'};
1137 my $objs = RT::ObjectScrips->new( $self->CurrentUser );
1138 $objs->LimitToScrip( $self->Id );
1141 $deps->_PushDependencies(
1142 BaseObject => $self,
1143 Flags => RT::Shredder::Constants::DEPENDS_ON,
1144 TargetObjects => $list,
1145 Shredder => $args{'Shredder'}
1148 return $self->SUPER::__DependsOn( %args );
1154 my %store = $self->SUPER::Serialize(@_);
1156 # Store the string, not a reference to the object
1157 $store{Template} = $self->Template;
1162 RT::Base->_ImportOverlays();