rt 4.0.23
[freeside.git] / rt / lib / RT / Scrip.pm
1 # BEGIN BPS TAGGED BLOCK {{{
2 #
3 # COPYRIGHT:
4 #
5 # This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
6 #                                          <sales@bestpractical.com>
7 #
8 # (Except where explicitly superseded by other copyright notices)
9 #
10 #
11 # LICENSE:
12 #
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
16 # from www.gnu.org.
17 #
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.
22 #
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.
28 #
29 #
30 # CONTRIBUTION SUBMISSION POLICY:
31 #
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.)
37 #
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.
46 #
47 # END BPS TAGGED BLOCK }}}
48
49 =head1 NAME
50
51   RT::Scrip - an RT Scrip object
52
53 =head1 SYNOPSIS
54
55   use RT::Scrip;
56
57 =head1 DESCRIPTION
58
59
60 =head1 METHODS
61
62
63 =cut
64
65
66 package RT::Scrip;
67
68 use strict;
69 use warnings;
70
71
72 use RT::Queue;
73 use RT::Template;
74 use RT::ScripCondition;
75 use RT::ScripAction;
76 use base 'RT::Record';
77
78 sub Table {'Scrips'}
79
80 # {{{ sub Create
81
82 =head2 Create
83
84 Creates a new entry in the Scrips table. Takes a paramhash with:
85
86         Queue                  => 0,
87         Description            => undef,
88         Template               => undef,
89         ScripAction            => undef,
90         ScripCondition         => undef,
91         CustomPrepareCode      => undef,
92         CustomCommitCode       => undef,
93         CustomIsApplicableCode => undef,
94
95
96
97
98 Returns (retval, msg);
99 retval is 0 for failure or scrip id.  msg is a textual description of what happened.
100
101 =cut
102
103 sub Create {
104     my $self = shift;
105     my %args = (
106         Queue                  => 0,
107         Template               => 0,                     # name or id
108         ScripAction            => 0,                     # name or id
109         ScripCondition         => 0,                     # name or id
110         Stage                  => 'TransactionCreate',
111         Description            => undef,
112         CustomPrepareCode      => undef,
113         CustomCommitCode       => undef,
114         CustomIsApplicableCode => undef,
115         ConditionRules         => undef,
116         ActionRules            => undef,
117         @_
118     );
119
120     if ($args{CustomPrepareCode} || $args{CustomCommitCode} || $args{CustomIsApplicableCode}) {
121         unless ( $self->CurrentUser->HasRight( Object => $RT::System,
122                                                Right  => 'ExecuteCode' ) )
123         {
124             return ( 0, $self->loc('Permission Denied') );
125         }
126     }
127
128     unless ( $args{'Queue'} ) {
129         unless ( $self->CurrentUser->HasRight( Object => $RT::System,
130                                                Right  => 'ModifyScrips' ) )
131         {
132             return ( 0, $self->loc('Permission Denied') );
133         }
134         $args{'Queue'} = 0;    # avoid undef sneaking in
135     }
136     else {
137         my $QueueObj = RT::Queue->new( $self->CurrentUser );
138         $QueueObj->Load( $args{'Queue'} );
139         unless ( $QueueObj->id ) {
140             return ( 0, $self->loc('Invalid queue') );
141         }
142         unless ( $QueueObj->CurrentUserHasRight('ModifyScrips') ) {
143             return ( 0, $self->loc('Permission Denied') );
144         }
145         $args{'Queue'} = $QueueObj->id;
146     }
147
148     #TODO +++ validate input
149
150     require RT::ScripAction;
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'} ) ) 
156         unless $action->Id;
157
158     require RT::Template;
159     return ( 0, $self->loc("Template is mandatory argument") )
160         unless $args{'Template'};
161     my $template = RT::Template->new( $self->CurrentUser );
162     $template->Load( $args{'Template'} );
163     return ( 0, $self->loc( "Template '[_1]' not found", $args{'Template'} ) )
164         unless $template->Id;
165
166     require RT::ScripCondition;
167     return ( 0, $self->loc("Condition is mandatory argument") )
168         unless $args{'ScripCondition'};
169     my $condition = RT::ScripCondition->new( $self->CurrentUser );
170     $condition->Load( $args{'ScripCondition'} );
171     return ( 0, $self->loc( "Condition '[_1]' not found", $args{'ScripCondition'} ) )
172         unless $condition->Id;
173
174     my ( $id, $msg ) = $self->SUPER::Create(
175         Queue                  => $args{'Queue'},
176         Template               => $template->Id,
177         ScripCondition         => $condition->id,
178         Stage                  => $args{'Stage'},
179         ScripAction            => $action->Id,
180         Description            => $args{'Description'},
181         CustomPrepareCode      => $args{'CustomPrepareCode'},
182         CustomCommitCode       => $args{'CustomCommitCode'},
183         CustomIsApplicableCode => $args{'CustomIsApplicableCode'},
184         ConditionRules         => $args{'ConditionRules'},
185         ActionRules            => $args{'ActionRules'},
186     );
187     if ( $id ) {
188         return ( $id, $self->loc('Scrip Created') );
189     }
190     else {
191         return ( $id, $msg );
192     }
193 }
194
195
196
197 =head2 Delete
198
199 Delete this object
200
201 =cut
202
203 sub Delete {
204     my $self = shift;
205
206     unless ( $self->CurrentUserHasRight('ModifyScrips') ) {
207         return ( 0, $self->loc('Permission Denied') );
208     }
209
210     return ( $self->SUPER::Delete(@_) );
211 }
212
213
214
215 =head2 QueueObj
216
217 Retuns an RT::Queue object with this Scrip's queue
218
219 =cut
220
221 sub QueueObj {
222     my $self = shift;
223
224     if ( !$self->{'QueueObj'} ) {
225         require RT::Queue;
226         $self->{'QueueObj'} = RT::Queue->new( $self->CurrentUser );
227         $self->{'QueueObj'}->Load( $self->__Value('Queue') );
228     }
229     return ( $self->{'QueueObj'} );
230 }
231
232
233
234 =head2 ActionObj
235
236 Retuns an RT::Action object with this Scrip's Action
237
238 =cut
239
240 sub ActionObj {
241     my $self = shift;
242
243     unless ( defined $self->{'ScripActionObj'} ) {
244         require RT::ScripAction;
245
246         $self->{'ScripActionObj'} = RT::ScripAction->new( $self->CurrentUser );
247
248         #TODO: why are we loading Actions with templates like this.
249         # two separate methods might make more sense
250         $self->{'ScripActionObj'}->Load( $self->ScripAction, $self->Template );
251     }
252     return ( $self->{'ScripActionObj'} );
253 }
254
255
256
257 =head2 ConditionObj
258
259 Retuns an L<RT::ScripCondition> object with this Scrip's IsApplicable
260
261 =cut
262
263 sub ConditionObj {
264     my $self = shift;
265
266     my $res = RT::ScripCondition->new( $self->CurrentUser );
267     $res->Load( $self->ScripCondition );
268     return $res;
269 }
270
271
272 =head2 LoadModules
273
274 Loads scrip's condition and action modules.
275
276 =cut
277
278 sub LoadModules {
279     my $self = shift;
280
281     $self->ConditionObj->LoadCondition;
282     $self->ActionObj->LoadAction;
283 }
284
285
286 =head2 TemplateObj
287
288 Retuns an RT::Template object with this Scrip's Template
289
290 =cut
291
292 sub TemplateObj {
293     my $self = shift;
294
295     unless ( defined $self->{'TemplateObj'} ) {
296         require RT::Template;
297         $self->{'TemplateObj'} = RT::Template->new( $self->CurrentUser );
298         $self->{'TemplateObj'}->Load( $self->Template );
299     }
300     return ( $self->{'TemplateObj'} );
301 }
302
303
304
305
306 =head2 Apply { TicketObj => undef, TransactionObj => undef}
307
308 This method instantiates the ScripCondition and ScripAction objects for a
309 single execution of this scrip. it then calls the IsApplicable method of the 
310 ScripCondition.
311 If that succeeds, it calls the Prepare method of the
312 ScripAction. If that succeeds, it calls the Commit method of the ScripAction.
313
314 Usually, the ticket and transaction objects passed to this method
315 should be loaded by the SuperUser role
316
317 =cut
318
319
320 # XXX TODO : This code appears to be obsoleted in favor of similar code in Scrips->Apply.
321 # Why is this here? Is it still called?
322
323 sub Apply {
324     my $self = shift;
325     my %args = ( TicketObj      => undef,
326                  TransactionObj => undef,
327                  @_ );
328
329     $RT::Logger->debug("Now applying scrip ".$self->Id . " for transaction ".$args{'TransactionObj'}->id);
330
331     my $ApplicableTransactionObj = $self->IsApplicable( TicketObj      => $args{'TicketObj'},
332                                                         TransactionObj => $args{'TransactionObj'} );
333     unless ( $ApplicableTransactionObj ) {
334         return undef;
335     }
336
337     if ( $ApplicableTransactionObj->id != $args{'TransactionObj'}->id ) {
338         $RT::Logger->debug("Found an applicable transaction ".$ApplicableTransactionObj->Id . " in the same batch with transaction ".$args{'TransactionObj'}->id);
339     }
340
341     #If it's applicable, prepare and commit it
342     $RT::Logger->debug("Now preparing scrip ".$self->Id . " for transaction ".$ApplicableTransactionObj->id);
343     unless ( $self->Prepare( TicketObj      => $args{'TicketObj'},
344                              TransactionObj => $ApplicableTransactionObj )
345       ) {
346         return undef;
347     }
348
349     $RT::Logger->debug("Now commiting scrip ".$self->Id . " for transaction ".$ApplicableTransactionObj->id);
350     unless ( $self->Commit( TicketObj => $args{'TicketObj'},
351                             TransactionObj => $ApplicableTransactionObj)
352       ) {
353         return undef;
354     }
355
356     $RT::Logger->debug("We actually finished scrip ".$self->Id . " for transaction ".$ApplicableTransactionObj->id);
357     return (1);
358
359 }
360
361
362
363 =head2 IsApplicable
364
365 Calls the  Condition object's IsApplicable method
366
367 Upon success, returns the applicable Transaction object.
368 Otherwise, undef is returned.
369
370 If the Scrip is in the TransactionCreate Stage (the usual case), only test
371 the associated Transaction object to see if it is applicable.
372
373 For Scrips in the TransactionBatch Stage, test all Transaction objects
374 created during the Ticket object's lifetime, and returns the first one
375 that is applicable.
376
377 =cut
378
379 sub IsApplicable {
380     my $self = shift;
381     my %args = ( TicketObj      => undef,
382                  TransactionObj => undef,
383                  @_ );
384
385     my $return;
386     eval {
387
388         my @Transactions;
389
390         if ( $self->Stage eq 'TransactionCreate') {
391             # Only look at our current Transaction
392             @Transactions = ( $args{'TransactionObj'} );
393         }
394         elsif ( $self->Stage eq 'TransactionBatch') {
395             # Look at all Transactions in this Batch
396             @Transactions = @{ $args{'TicketObj'}->TransactionBatch || [] };
397         }
398         else {
399             $RT::Logger->error( "Unknown Scrip stage:" . $self->Stage );
400             return (undef);
401         }
402         my $ConditionObj = $self->ConditionObj;
403         foreach my $TransactionObj ( @Transactions ) {
404             # in TxnBatch stage we can select scrips that are not applicable to all txns
405             my $txn_type = $TransactionObj->Type;
406             next unless( $ConditionObj->ApplicableTransTypes =~ /(?:^|,)(?:Any|\Q$txn_type\E)(?:,|$)/i );
407             # Load the scrip's Condition object
408             $ConditionObj->LoadCondition(
409                 ScripObj       => $self,
410                 TicketObj      => $args{'TicketObj'},
411                 TransactionObj => $TransactionObj,
412             );
413
414             if ( $ConditionObj->IsApplicable() ) {
415                 # We found an application Transaction -- return it
416                 $return = $TransactionObj;
417                 last;
418             }
419         }
420     };
421
422     if ($@) {
423         $RT::Logger->error( "Scrip IsApplicable " . $self->Id . " died. - " . $@ );
424         return (undef);
425     }
426
427             return ($return);
428
429 }
430
431
432
433 =head2 Prepare
434
435 Calls the action object's prepare method
436
437 =cut
438
439 sub Prepare {
440     my $self = shift;
441     my %args = ( TicketObj      => undef,
442                  TransactionObj => undef,
443                  @_ );
444
445     my $return;
446     eval {
447         $self->ActionObj->LoadAction( ScripObj       => $self,
448                                       TicketObj      => $args{'TicketObj'},
449                                       TransactionObj => $args{'TransactionObj'},
450         );
451
452         $return = $self->ActionObj->Prepare();
453     };
454     if ($@) {
455         $RT::Logger->error( "Scrip Prepare " . $self->Id . " died. - " . $@ );
456         return (undef);
457     }
458         unless ($return) {
459         }
460         return ($return);
461 }
462
463
464
465 =head2 Commit
466
467 Calls the action object's commit method
468
469 =cut
470
471 sub Commit {
472     my $self = shift;
473     my %args = ( TicketObj      => undef,
474                  TransactionObj => undef,
475                  @_ );
476
477     my $return;
478     eval {
479         $return = $self->ActionObj->Commit();
480     };
481
482 #Searchbuilder caching isn't perfectly coherent. got to reload the ticket object, since it
483 # may have changed
484     $args{'TicketObj'}->Load( $args{'TicketObj'}->Id );
485
486     if ($@) {
487         $RT::Logger->error( "Scrip Commit " . $self->Id . " died. - " . $@ );
488         return (undef);
489     }
490
491     # Not destroying or weakening hte Action and Condition here could cause a
492     # leak
493
494     return ($return);
495 }
496
497
498
499
500
501 # does an acl check and then passes off the call
502 sub _Set {
503     my $self = shift;
504     my %args = (
505         Field => undef,
506         Value => undef,
507         @_,
508     );
509
510     unless ( $self->CurrentUserHasRight('ModifyScrips') ) {
511         $RT::Logger->debug(
512                  "CurrentUser can't modify Scrips for " . $self->Queue . "\n" );
513         return ( 0, $self->loc('Permission Denied') );
514     }
515
516
517     if (exists $args{Value}) {
518         if ($args{Field} eq 'CustomIsApplicableCode' || $args{Field} eq 'CustomPrepareCode' || $args{Field} eq 'CustomCommitCode') {
519             unless ( $self->CurrentUser->HasRight( Object => $RT::System,
520                                                    Right  => 'ExecuteCode' ) ) {
521                 return ( 0, $self->loc('Permission Denied') );
522             }
523         }
524         elsif ($args{Field} eq 'Queue') {
525             if ($args{Value}) {
526                 # moving to another queue
527                 my $queue = RT::Queue->new( $self->CurrentUser );
528                 $queue->Load($args{Value});
529                 unless ($queue->Id and $queue->CurrentUserHasRight('ModifyScrips')) {
530                     return ( 0, $self->loc('Permission Denied') );
531                 }
532             } else {
533                 # moving to global
534                 unless ($self->CurrentUser->HasRight( Object => RT->System, Right => 'ModifyScrips' )) {
535                     return ( 0, $self->loc('Permission Denied') );
536                 }
537             }
538         }
539         elsif ($args{Field} eq 'Template') {
540             my $template = RT::Template->new( $self->CurrentUser );
541             $template->Load($args{Value});
542             unless ($template->Id and $template->CurrentUserCanRead) {
543                 return ( 0, $self->loc('Permission Denied') );
544             }
545         }
546     }
547
548     return $self->SUPER::_Set(@_);
549 }
550
551
552 # does an acl check and then passes off the call
553 sub _Value {
554     my $self = shift;
555
556     unless ( $self->CurrentUserHasRight('ShowScrips') ) {
557         $RT::Logger->debug( "CurrentUser can't modify Scrips for "
558                             . $self->__Value('Queue')
559                             . "\n" );
560         return (undef);
561     }
562
563     return $self->__Value(@_);
564 }
565
566
567
568 =head2 CurrentUserHasRight
569
570 Helper menthod for HasRight. Presets Principal to CurrentUser then 
571 calls HasRight.
572
573 =cut
574
575 sub CurrentUserHasRight {
576     my $self  = shift;
577     my $right = shift;
578     return ( $self->HasRight( Principal => $self->CurrentUser->UserObj,
579                               Right     => $right ) );
580
581 }
582
583
584
585 =head2 HasRight
586
587 Takes a param-hash consisting of "Right" and "Principal"  Principal is 
588 an RT::User object or an RT::CurrentUser object. "Right" is a textual
589 Right string that applies to Scrips.
590
591 =cut
592
593 sub HasRight {
594     my $self = shift;
595     my %args = ( Right     => undef,
596                  Principal => undef,
597                  @_ );
598
599     if ( $self->SUPER::_Value('Queue') ) {
600         return $args{'Principal'}->HasRight(
601             Right  => $args{'Right'},
602             Object => $self->QueueObj
603         );
604     }
605     else {
606         return $args{'Principal'}->HasRight(
607             Object => $RT::System,
608             Right  => $args{'Right'},
609         );
610     }
611 }
612
613
614
615 =head2 CompileCheck
616
617 This routine compile-checks the custom prepare, commit, and is-applicable code
618 to see if they are syntactically valid Perl. We eval them in a codeblock to
619 avoid actually executing the code.
620
621 If one of the fields has a compile error, only the first is reported.
622
623 Returns an (ok, message) pair.
624
625 =cut
626
627 sub CompileCheck {
628     my $self = shift;
629
630     for my $method (qw/CustomPrepareCode CustomCommitCode CustomIsApplicableCode/) {
631         my $code = $self->$method;
632         next if !defined($code);
633
634         do {
635             no strict 'vars';
636             eval "sub { $code \n }";
637         };
638         next if !$@;
639
640         my $error = $@;
641         return (0, $self->loc("Couldn't compile [_1] codeblock '[_2]': [_3]", $method, $code, $error));
642     }
643 }
644
645
646 =head2 SetScripAction
647
648 =cut
649
650 sub SetScripAction {
651     my $self  = shift;
652     my $value = shift;
653
654     return ( 0, $self->loc("Action is mandatory argument") ) unless $value;
655
656     require RT::ScripAction;
657     my $action = RT::ScripAction->new( $self->CurrentUser );
658     $action->Load($value);
659     return ( 0, $self->loc( "Action '[_1]' not found", $value ) )
660       unless $action->Id;
661
662     return $self->_Set( Field => 'ScripAction', Value => $action->Id );
663 }
664
665 =head2 SetScripCondition
666
667 =cut
668
669 sub SetScripCondition {
670     my $self  = shift;
671     my $value = shift;
672
673     return ( 0, $self->loc("Condition is mandatory argument") )
674       unless $value;
675
676     require RT::ScripCondition;
677     my $condition = RT::ScripCondition->new( $self->CurrentUser );
678     $condition->Load($value);
679
680     return ( 0, $self->loc( "Condition '[_1]' not found", $value ) )
681       unless $condition->Id;
682
683     return $self->_Set( Field => 'ScripCondition', Value => $condition->Id );
684 }
685
686 =head2 SetTemplate
687
688 =cut
689
690 sub SetTemplate {
691     my $self  = shift;
692     my $value = shift;
693
694     return ( 0, $self->loc("Template is mandatory argument") ) unless $value;
695
696     require RT::Template;
697     my $template = RT::Template->new( $self->CurrentUser );
698     $template->Load($value);
699     return ( 0, $self->loc( "Template '[_1]' not found", $value ) )
700       unless $template->Id;
701
702     return $self->_Set( Field => 'Template', Value => $template->Id );
703 }
704
705 1;
706
707
708
709
710
711
712 =head2 id
713
714 Returns the current value of id.
715 (In the database, id is stored as int(11).)
716
717
718 =cut
719
720
721 =head2 Description
722
723 Returns the current value of Description.
724 (In the database, Description is stored as varchar(255).)
725
726
727
728 =head2 SetDescription VALUE
729
730
731 Set Description to VALUE.
732 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
733 (In the database, Description will be stored as a varchar(255).)
734
735
736 =cut
737
738
739 =head2 ScripCondition
740
741 Returns the current value of ScripCondition.
742 (In the database, ScripCondition is stored as int(11).)
743
744
745
746 =head2 SetScripCondition VALUE
747
748
749 Set ScripCondition to VALUE.
750 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
751 (In the database, ScripCondition will be stored as a int(11).)
752
753
754 =cut
755
756
757 =head2 ScripConditionObj
758
759 Returns the ScripCondition Object which has the id returned by ScripCondition
760
761
762 =cut
763
764 sub ScripConditionObj {
765         my $self = shift;
766         my $ScripCondition =  RT::ScripCondition->new($self->CurrentUser);
767         $ScripCondition->Load($self->__Value('ScripCondition'));
768         return($ScripCondition);
769 }
770
771 =head2 ScripAction
772
773 Returns the current value of ScripAction.
774 (In the database, ScripAction is stored as int(11).)
775
776
777
778 =head2 SetScripAction VALUE
779
780
781 Set ScripAction to VALUE.
782 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
783 (In the database, ScripAction will be stored as a int(11).)
784
785
786 =cut
787
788
789 =head2 ScripActionObj
790
791 Returns the ScripAction Object which has the id returned by ScripAction
792
793
794 =cut
795
796 sub ScripActionObj {
797         my $self = shift;
798         my $ScripAction =  RT::ScripAction->new($self->CurrentUser);
799         $ScripAction->Load($self->__Value('ScripAction'));
800         return($ScripAction);
801 }
802
803 =head2 ConditionRules
804
805 Returns the current value of ConditionRules.
806 (In the database, ConditionRules is stored as text.)
807
808
809
810 =head2 SetConditionRules VALUE
811
812
813 Set ConditionRules to VALUE.
814 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
815 (In the database, ConditionRules will be stored as a text.)
816
817
818 =cut
819
820
821 =head2 ActionRules
822
823 Returns the current value of ActionRules.
824 (In the database, ActionRules is stored as text.)
825
826
827
828 =head2 SetActionRules VALUE
829
830
831 Set ActionRules to VALUE.
832 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
833 (In the database, ActionRules will be stored as a text.)
834
835
836 =cut
837
838
839 =head2 CustomIsApplicableCode
840
841 Returns the current value of CustomIsApplicableCode.
842 (In the database, CustomIsApplicableCode is stored as text.)
843
844
845
846 =head2 SetCustomIsApplicableCode VALUE
847
848
849 Set CustomIsApplicableCode to VALUE.
850 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
851 (In the database, CustomIsApplicableCode will be stored as a text.)
852
853
854 =cut
855
856
857 =head2 CustomPrepareCode
858
859 Returns the current value of CustomPrepareCode.
860 (In the database, CustomPrepareCode is stored as text.)
861
862
863
864 =head2 SetCustomPrepareCode VALUE
865
866
867 Set CustomPrepareCode to VALUE.
868 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
869 (In the database, CustomPrepareCode will be stored as a text.)
870
871
872 =cut
873
874
875 =head2 CustomCommitCode
876
877 Returns the current value of CustomCommitCode.
878 (In the database, CustomCommitCode is stored as text.)
879
880
881
882 =head2 SetCustomCommitCode VALUE
883
884
885 Set CustomCommitCode to VALUE.
886 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
887 (In the database, CustomCommitCode will be stored as a text.)
888
889
890 =cut
891
892
893 =head2 Stage
894
895 Returns the current value of Stage.
896 (In the database, Stage is stored as varchar(32).)
897
898
899
900 =head2 SetStage VALUE
901
902
903 Set Stage to VALUE.
904 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
905 (In the database, Stage will be stored as a varchar(32).)
906
907
908 =cut
909
910
911 =head2 Queue
912
913 Returns the current value of Queue.
914 (In the database, Queue is stored as int(11).)
915
916
917
918 =head2 SetQueue VALUE
919
920
921 Set Queue to VALUE.
922 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
923 (In the database, Queue will be stored as a int(11).)
924
925
926 =cut
927
928
929 =head2 Template
930
931 Returns the current value of Template.
932 (In the database, Template is stored as int(11).)
933
934
935
936 =head2 SetTemplate VALUE
937
938
939 Set Template to VALUE.
940 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
941 (In the database, Template will be stored as a int(11).)
942
943
944 =cut
945
946
947 =head2 Creator
948
949 Returns the current value of Creator.
950 (In the database, Creator is stored as int(11).)
951
952
953 =cut
954
955
956 =head2 Created
957
958 Returns the current value of Created.
959 (In the database, Created is stored as datetime.)
960
961
962 =cut
963
964
965 =head2 LastUpdatedBy
966
967 Returns the current value of LastUpdatedBy.
968 (In the database, LastUpdatedBy is stored as int(11).)
969
970
971 =cut
972
973
974 =head2 LastUpdated
975
976 Returns the current value of LastUpdated.
977 (In the database, LastUpdated is stored as datetime.)
978
979
980 =cut
981
982
983
984 sub _CoreAccessible {
985     {
986
987         id =>
988                 {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
989         Description =>
990                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
991         ScripCondition =>
992                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
993         ScripAction =>
994                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
995         ConditionRules =>
996                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
997         ActionRules =>
998                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
999         CustomIsApplicableCode =>
1000                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
1001         CustomPrepareCode =>
1002                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
1003         CustomCommitCode =>
1004                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
1005         Stage =>
1006                 {read => 1, write => 1, sql_type => 12, length => 32,  is_blob => 0,  is_numeric => 0,  type => 'varchar(32)', default => ''},
1007         Queue =>
1008                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
1009         Template =>
1010                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
1011         Creator =>
1012                 {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
1013         Created =>
1014                 {read => 1, auto => 1, sql_type => 11, length => 0,  is_blob => 0,  is_numeric => 0,  type => 'datetime', default => ''},
1015         LastUpdatedBy =>
1016                 {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
1017         LastUpdated =>
1018                 {read => 1, auto => 1, sql_type => 11, length => 0,  is_blob => 0,  is_numeric => 0,  type => 'datetime', default => ''},
1019
1020  }
1021 };
1022
1023 RT::Base->_ImportOverlays();
1024
1025 1;