import rt 3.8.10
[freeside.git] / rt / lib / RT / Condition.pm
1 # BEGIN BPS TAGGED BLOCK {{{
2 #
3 # COPYRIGHT:
4 #
5 # This software is Copyright (c) 1996-2011 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::Condition - generic baseclass for scrip condition;
52
53 =head1 SYNOPSIS
54
55     use RT::Condition;
56     my $foo = RT::Condition->new( 
57                 TransactionObj => $tr, 
58                 TicketObj => $ti, 
59                 ScripObj => $scr, 
60                 Argument => $arg, 
61                 Type => $type);
62
63     if ($foo->IsApplicable) {
64            # do something
65     }
66
67
68 =head1 DESCRIPTION
69
70
71 =head1 METHODS
72
73
74
75
76 =cut
77
78 package RT::Condition;
79
80 use strict;
81 use warnings;
82
83 use base qw/RT::Base/;
84
85 # {{{ sub new 
86 sub new  {
87   my $proto = shift;
88   my $class = ref($proto) || $proto;
89   my $self  = {};
90   bless ($self, $class);
91   $self->_Init(@_);
92   return $self;
93 }
94 # }}}
95
96 # {{{ sub _Init 
97 sub _Init  {
98   my $self = shift;
99   my %args = ( TransactionObj => undef,
100                TicketObj => undef,
101                ScripObj => undef,
102                TemplateObj => undef,
103                Argument => undef,
104                ApplicableTransTypes => undef,
105            CurrentUser => undef,
106                @_ );
107   
108   $self->{'Argument'} = $args{'Argument'};
109   $self->{'ScripObj'} = $args{'ScripObj'};
110   $self->{'TicketObj'} = $args{'TicketObj'};
111   $self->{'TransactionObj'} = $args{'TransactionObj'};
112   $self->{'ApplicableTransTypes'} = $args{'ApplicableTransTypes'};
113   $self->CurrentUser($args{'CurrentUser'});
114 }
115 # }}}
116
117 # Access Scripwide data
118
119 # {{{ sub Argument 
120
121 =head2 Argument
122
123 Return the optional argument associated with this ScripCondition
124
125 =cut
126
127 sub Argument  {
128   my $self = shift;
129   return($self->{'Argument'});
130 }
131 # }}}
132
133 # {{{ sub TicketObj
134
135 =head2 TicketObj
136
137 Return the ticket object we're talking about
138
139 =cut
140
141 sub TicketObj  {
142   my $self = shift;
143   return($self->{'TicketObj'});
144 }
145 # }}}
146
147 # {{{ sub ScripObj
148
149 =head2 ScripObj
150
151 Return the Scrip object we're talking about
152
153 =cut
154
155 sub ScripObj  {
156   my $self = shift;
157   return($self->{'ScripObj'});
158 }
159 # }}}
160 # {{{ sub TransactionObj
161
162 =head2 TransactionObj
163
164 Return the transaction object we're talking about
165
166 =cut
167
168 sub TransactionObj  {
169   my $self = shift;
170   return($self->{'TransactionObj'});
171 }
172 # }}}
173
174 # {{{ sub Type
175
176 =head2 Type 
177
178
179
180 =cut
181
182 sub ApplicableTransTypes  {
183   my $self = shift;
184   return($self->{'ApplicableTransTypes'});
185 }
186 # }}}
187
188
189 # Scrip methods
190
191
192 #What does this type of Action does
193
194 # {{{ sub Describe 
195 sub Describe  {
196   my $self = shift;
197   return ($self->loc("No description for [_1]", ref $self));
198 }
199 # }}}
200
201
202 #Parse the templates, get things ready to go.
203
204 #If this rule applies to this transaction, return true.
205
206 # {{{ sub IsApplicable 
207 sub IsApplicable  {
208   my $self = shift;
209   return(undef);
210 }
211 # }}}
212
213 # {{{ sub DESTROY
214 sub DESTROY {
215     my $self = shift;
216
217     # We need to clean up all the references that might maybe get
218     # oddly circular
219     $self->{'TemplateObj'} =undef
220     $self->{'TicketObj'} = undef;
221     $self->{'TransactionObj'} = undef;
222     $self->{'ScripObj'} = undef;
223      
224 }
225
226 # }}}
227
228 RT::Base->_ImportOverlays();
229
230 1;