starting to work...
[freeside.git] / rt / lib / RT / Scrip.pm
1 # BEGIN BPS TAGGED BLOCK {{{
2 #
3 # COPYRIGHT:
4 #
5 # This software is Copyright (c) 1996-2012 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 (length($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     }
525
526     return $self->__Set(@_);
527 }
528
529
530 # does an acl check and then passes off the call
531 sub _Value {
532     my $self = shift;
533
534     unless ( $self->CurrentUserHasRight('ShowScrips') ) {
535         $RT::Logger->debug( "CurrentUser can't modify Scrips for "
536                             . $self->__Value('Queue')
537                             . "\n" );
538         return (undef);
539     }
540
541     return $self->__Value(@_);
542 }
543
544
545
546 =head2 CurrentUserHasRight
547
548 Helper menthod for HasRight. Presets Principal to CurrentUser then 
549 calls HasRight.
550
551 =cut
552
553 sub CurrentUserHasRight {
554     my $self  = shift;
555     my $right = shift;
556     return ( $self->HasRight( Principal => $self->CurrentUser->UserObj,
557                               Right     => $right ) );
558
559 }
560
561
562
563 =head2 HasRight
564
565 Takes a param-hash consisting of "Right" and "Principal"  Principal is 
566 an RT::User object or an RT::CurrentUser object. "Right" is a textual
567 Right string that applies to Scrips.
568
569 =cut
570
571 sub HasRight {
572     my $self = shift;
573     my %args = ( Right     => undef,
574                  Principal => undef,
575                  @_ );
576
577     if ( $self->SUPER::_Value('Queue') ) {
578         return $args{'Principal'}->HasRight(
579             Right  => $args{'Right'},
580             Object => $self->QueueObj
581         );
582     }
583     else {
584         return $args{'Principal'}->HasRight(
585             Object => $RT::System,
586             Right  => $args{'Right'},
587         );
588     }
589 }
590
591
592
593 =head2 CompileCheck
594
595 This routine compile-checks the custom prepare, commit, and is-applicable code
596 to see if they are syntactically valid Perl. We eval them in a codeblock to
597 avoid actually executing the code.
598
599 If one of the fields has a compile error, only the first is reported.
600
601 Returns an (ok, message) pair.
602
603 =cut
604
605 sub CompileCheck {
606     my $self = shift;
607
608     for my $method (qw/CustomPrepareCode CustomCommitCode CustomIsApplicableCode/) {
609         my $code = $self->$method;
610         next if !defined($code);
611
612         do {
613             no strict 'vars';
614             eval "sub { $code }";
615         };
616         next if !$@;
617
618         my $error = $@;
619         return (0, $self->loc("Couldn't compile [_1] codeblock '[_2]': [_3]", $method, $code, $error));
620     }
621 }
622
623
624 =head2 SetScripAction
625
626 =cut
627
628 sub SetScripAction {
629     my $self  = shift;
630     my $value = shift;
631
632     return ( 0, $self->loc("Action is mandatory argument") ) unless $value;
633
634     require RT::ScripAction;
635     my $action = RT::ScripAction->new( $self->CurrentUser );
636     $action->Load($value);
637     return ( 0, $self->loc( "Action '[_1]' not found", $value ) )
638       unless $action->Id;
639
640     return $self->_Set( Field => 'ScripAction', Value => $action->Id );
641 }
642
643 =head2 SetScripCondition
644
645 =cut
646
647 sub SetScripCondition {
648     my $self  = shift;
649     my $value = shift;
650
651     return ( 0, $self->loc("Condition is mandatory argument") )
652       unless $value;
653
654     require RT::ScripCondition;
655     my $condition = RT::ScripCondition->new( $self->CurrentUser );
656     $condition->Load($value);
657
658     return ( 0, $self->loc( "Condition '[_1]' not found", $value ) )
659       unless $condition->Id;
660
661     return $self->_Set( Field => 'ScripCondition', Value => $condition->Id );
662 }
663
664 =head2 SetTemplate
665
666 =cut
667
668 sub SetTemplate {
669     my $self  = shift;
670     my $value = shift;
671
672     return ( 0, $self->loc("Template is mandatory argument") ) unless $value;
673
674     require RT::Template;
675     my $template = RT::Template->new( $self->CurrentUser );
676     $template->Load($value);
677     return ( 0, $self->loc( "Template '[_1]' not found", $value ) )
678       unless $template->Id;
679
680     return $self->_Set( Field => 'Template', Value => $template->Id );
681 }
682
683 1;
684
685
686
687
688
689
690 =head2 id
691
692 Returns the current value of id.
693 (In the database, id is stored as int(11).)
694
695
696 =cut
697
698
699 =head2 Description
700
701 Returns the current value of Description.
702 (In the database, Description is stored as varchar(255).)
703
704
705
706 =head2 SetDescription VALUE
707
708
709 Set Description to VALUE.
710 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
711 (In the database, Description will be stored as a varchar(255).)
712
713
714 =cut
715
716
717 =head2 ScripCondition
718
719 Returns the current value of ScripCondition.
720 (In the database, ScripCondition is stored as int(11).)
721
722
723
724 =head2 SetScripCondition VALUE
725
726
727 Set ScripCondition to VALUE.
728 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
729 (In the database, ScripCondition will be stored as a int(11).)
730
731
732 =cut
733
734
735 =head2 ScripConditionObj
736
737 Returns the ScripCondition Object which has the id returned by ScripCondition
738
739
740 =cut
741
742 sub ScripConditionObj {
743         my $self = shift;
744         my $ScripCondition =  RT::ScripCondition->new($self->CurrentUser);
745         $ScripCondition->Load($self->__Value('ScripCondition'));
746         return($ScripCondition);
747 }
748
749 =head2 ScripAction
750
751 Returns the current value of ScripAction.
752 (In the database, ScripAction is stored as int(11).)
753
754
755
756 =head2 SetScripAction VALUE
757
758
759 Set ScripAction to VALUE.
760 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
761 (In the database, ScripAction will be stored as a int(11).)
762
763
764 =cut
765
766
767 =head2 ScripActionObj
768
769 Returns the ScripAction Object which has the id returned by ScripAction
770
771
772 =cut
773
774 sub ScripActionObj {
775         my $self = shift;
776         my $ScripAction =  RT::ScripAction->new($self->CurrentUser);
777         $ScripAction->Load($self->__Value('ScripAction'));
778         return($ScripAction);
779 }
780
781 =head2 ConditionRules
782
783 Returns the current value of ConditionRules.
784 (In the database, ConditionRules is stored as text.)
785
786
787
788 =head2 SetConditionRules VALUE
789
790
791 Set ConditionRules to VALUE.
792 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
793 (In the database, ConditionRules will be stored as a text.)
794
795
796 =cut
797
798
799 =head2 ActionRules
800
801 Returns the current value of ActionRules.
802 (In the database, ActionRules is stored as text.)
803
804
805
806 =head2 SetActionRules VALUE
807
808
809 Set ActionRules to VALUE.
810 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
811 (In the database, ActionRules will be stored as a text.)
812
813
814 =cut
815
816
817 =head2 CustomIsApplicableCode
818
819 Returns the current value of CustomIsApplicableCode.
820 (In the database, CustomIsApplicableCode is stored as text.)
821
822
823
824 =head2 SetCustomIsApplicableCode VALUE
825
826
827 Set CustomIsApplicableCode to VALUE.
828 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
829 (In the database, CustomIsApplicableCode will be stored as a text.)
830
831
832 =cut
833
834
835 =head2 CustomPrepareCode
836
837 Returns the current value of CustomPrepareCode.
838 (In the database, CustomPrepareCode is stored as text.)
839
840
841
842 =head2 SetCustomPrepareCode VALUE
843
844
845 Set CustomPrepareCode to VALUE.
846 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
847 (In the database, CustomPrepareCode will be stored as a text.)
848
849
850 =cut
851
852
853 =head2 CustomCommitCode
854
855 Returns the current value of CustomCommitCode.
856 (In the database, CustomCommitCode is stored as text.)
857
858
859
860 =head2 SetCustomCommitCode VALUE
861
862
863 Set CustomCommitCode to VALUE.
864 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
865 (In the database, CustomCommitCode will be stored as a text.)
866
867
868 =cut
869
870
871 =head2 Stage
872
873 Returns the current value of Stage.
874 (In the database, Stage is stored as varchar(32).)
875
876
877
878 =head2 SetStage VALUE
879
880
881 Set Stage to VALUE.
882 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
883 (In the database, Stage will be stored as a varchar(32).)
884
885
886 =cut
887
888
889 =head2 Queue
890
891 Returns the current value of Queue.
892 (In the database, Queue is stored as int(11).)
893
894
895
896 =head2 SetQueue VALUE
897
898
899 Set Queue to VALUE.
900 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
901 (In the database, Queue will be stored as a int(11).)
902
903
904 =cut
905
906
907 =head2 Template
908
909 Returns the current value of Template.
910 (In the database, Template is stored as int(11).)
911
912
913
914 =head2 SetTemplate VALUE
915
916
917 Set Template to VALUE.
918 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
919 (In the database, Template will be stored as a int(11).)
920
921
922 =cut
923
924
925 =head2 Creator
926
927 Returns the current value of Creator.
928 (In the database, Creator is stored as int(11).)
929
930
931 =cut
932
933
934 =head2 Created
935
936 Returns the current value of Created.
937 (In the database, Created is stored as datetime.)
938
939
940 =cut
941
942
943 =head2 LastUpdatedBy
944
945 Returns the current value of LastUpdatedBy.
946 (In the database, LastUpdatedBy is stored as int(11).)
947
948
949 =cut
950
951
952 =head2 LastUpdated
953
954 Returns the current value of LastUpdated.
955 (In the database, LastUpdated is stored as datetime.)
956
957
958 =cut
959
960
961
962 sub _CoreAccessible {
963     {
964
965         id =>
966                 {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
967         Description =>
968                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
969         ScripCondition =>
970                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
971         ScripAction =>
972                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
973         ConditionRules =>
974                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
975         ActionRules =>
976                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
977         CustomIsApplicableCode =>
978                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
979         CustomPrepareCode =>
980                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
981         CustomCommitCode =>
982                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
983         Stage =>
984                 {read => 1, write => 1, sql_type => 12, length => 32,  is_blob => 0,  is_numeric => 0,  type => 'varchar(32)', default => ''},
985         Queue =>
986                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
987         Template =>
988                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
989         Creator =>
990                 {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
991         Created =>
992                 {read => 1, auto => 1, sql_type => 11, length => 0,  is_blob => 0,  is_numeric => 0,  type => 'datetime', default => ''},
993         LastUpdatedBy =>
994                 {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
995         LastUpdated =>
996                 {read => 1, auto => 1, sql_type => 11, length => 0,  is_blob => 0,  is_numeric => 0,  type => 'datetime', default => ''},
997
998  }
999 };
1000
1001 RT::Base->_ImportOverlays();
1002
1003 1;