reverting to vendor branch rt 3.0.4, hopefully
[freeside.git] / rt / lib / RT / Condition / Generic.pm
1 # BEGIN LICENSE BLOCK
2
3 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4
5 # (Except where explictly superceded by other copyright notices)
6
7 # This work is made available to you under the terms of Version 2 of
8 # the GNU General Public License. A copy of that license should have
9 # been provided with this software, but in any event can be snarfed
10 # from www.gnu.org.
11
12 # This work is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # General Public License for more details.
16
17 # Unless otherwise specified, all modifications, corrections or
18 # extensions to this work which alter its source code become the
19 # property of Best Practical Solutions, LLC when submitted for
20 # inclusion in the work.
21
22
23 # END LICENSE BLOCK
24 =head1 NAME
25
26   RT::Condition::Generic - ;
27
28 =head1 SYNOPSIS
29
30     use RT::Condition::Generic;
31     my $foo = new RT::Condition::IsApplicable( 
32                 TransactionObj => $tr, 
33                 TicketObj => $ti, 
34                 ScripObj => $scr, 
35                 Argument => $arg, 
36                 Type => $type);
37
38     if ($foo->IsApplicable) {
39            # do something
40     }
41
42
43 =head1 DESCRIPTION
44
45
46 =head1 METHODS
47
48
49 =begin testing
50
51 ok (require RT::Condition::Generic);
52
53 =end testing
54
55
56 =cut
57
58 package RT::Condition::Generic;
59
60 use RT::Base;
61 use strict;
62 use vars qw/@ISA/;
63 @ISA = qw(RT::Base);
64
65 # {{{ sub new 
66 sub new  {
67   my $proto = shift;
68   my $class = ref($proto) || $proto;
69   my $self  = {};
70   bless ($self, $class);
71   $self->_Init(@_);
72   return $self;
73 }
74 # }}}
75
76 # {{{ sub _Init 
77 sub _Init  {
78   my $self = shift;
79   my %args = ( TransactionObj => undef,
80                TicketObj => undef,
81                ScripObj => undef,
82                TemplateObj => undef,
83                Argument => undef,
84                ApplicableTransTypes => undef,
85                @_ );
86   
87   $self->{'Argument'} = $args{'Argument'};
88   $self->{'ScripObj'} = $args{'ScripObj'};
89   $self->{'TicketObj'} = $args{'TicketObj'};
90   $self->{'TransactionObj'} = $args{'TransactionObj'};
91   $self->{'ApplicableTransTypes'} = $args{'ApplicableTransTypes'};
92 }
93 # }}}
94
95 # Access Scripwide data
96
97 # {{{ sub Argument 
98
99 =head2 Argument
100
101 Return the optional argument associated with this ScripCondition
102
103 =cut
104
105 sub Argument  {
106   my $self = shift;
107   return($self->{'Argument'});
108 }
109 # }}}
110
111 # {{{ sub TicketObj
112
113 =head2 TicketObj
114
115 Return the ticket object we're talking about
116
117 =cut
118
119 sub TicketObj  {
120   my $self = shift;
121   return($self->{'TicketObj'});
122 }
123 # }}}
124
125 # {{{ sub ScripObj
126
127 =head2 ScripObj
128
129 Return the Scrip object we're talking about
130
131 =cut
132
133 sub ScripObj  {
134   my $self = shift;
135   return($self->{'ScripObj'});
136 }
137 # }}}
138 # {{{ sub TransactionObj
139
140 =head2 TransactionObj
141
142 Return the transaction object we're talking about
143
144 =cut
145
146 sub TransactionObj  {
147   my $self = shift;
148   return($self->{'TransactionObj'});
149 }
150 # }}}
151
152 # {{{ sub Type
153
154 =head2 Type 
155
156
157
158 =cut
159
160 sub ApplicableTransTypes  {
161   my $self = shift;
162   return($self->{'ApplicableTransTypes'});
163 }
164 # }}}
165
166
167 # Scrip methods
168
169
170 #What does this type of Action does
171
172 # {{{ sub Describe 
173 sub Describe  {
174   my $self = shift;
175   return ($self->loc("No description for [_1]", ref $self));
176 }
177 # }}}
178
179
180 #Parse the templates, get things ready to go.
181
182 #If this rule applies to this transaction, return true.
183
184 # {{{ sub IsApplicable 
185 sub IsApplicable  {
186   my $self = shift;
187   return(undef);
188 }
189 # }}}
190
191 # {{{ sub DESTROY
192 sub DESTROY {
193     my $self = shift;
194
195     # We need to clean up all the references that might maybe get
196     # oddly circular
197     $self->{'TemplateObj'} =undef
198     $self->{'TicketObj'} = undef;
199     $self->{'TransactionObj'} = undef;
200     $self->{'ScripObj'} = undef;
201      
202 }
203
204 # }}}
205
206 eval "require RT::Condition::Generic_Vendor";
207 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/Generic_Vendor.pm});
208 eval "require RT::Condition::Generic_Local";
209 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/Generic_Local.pm});
210
211 1;