import rt 3.2.2
[freeside.git] / rt / lib / RT / Condition / Generic.pm
1 # {{{ BEGIN BPS TAGGED BLOCK
2
3 # COPYRIGHT:
4 #  
5 # This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC 
6 #                                          <jesse@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., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27
28 # CONTRIBUTION SUBMISSION POLICY:
29
30 # (The following paragraph is not intended to limit the rights granted
31 # to you to modify and distribute this software under the terms of
32 # the GNU General Public License and is only of importance to you if
33 # you choose to contribute your changes and enhancements to the
34 # community by submitting them to Best Practical Solutions, LLC.)
35
36 # By intentionally submitting any modifications, corrections or
37 # derivatives to this work, or any other work intended for use with
38 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 # you are the copyright holder for those contributions and you grant
40 # Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
41 # royalty-free, perpetual, license to use, copy, create derivative
42 # works based on those contributions, and sublicense and distribute
43 # those contributions and any derivatives thereof.
44
45 # }}} END BPS TAGGED BLOCK
46 =head1 NAME
47
48   RT::Condition::Generic - ;
49
50 =head1 SYNOPSIS
51
52     use RT::Condition::Generic;
53     my $foo = new RT::Condition::IsApplicable( 
54                 TransactionObj => $tr, 
55                 TicketObj => $ti, 
56                 ScripObj => $scr, 
57                 Argument => $arg, 
58                 Type => $type);
59
60     if ($foo->IsApplicable) {
61            # do something
62     }
63
64
65 =head1 DESCRIPTION
66
67
68 =head1 METHODS
69
70
71 =begin testing
72
73 ok (require RT::Condition::Generic);
74
75 =end testing
76
77
78 =cut
79
80 package RT::Condition::Generic;
81
82 use strict;
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 eval "require RT::Condition::Generic_Vendor";
229 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/Generic_Vendor.pm});
230 eval "require RT::Condition::Generic_Local";
231 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/Generic_Local.pm});
232
233 1;