import rt 3.2.2
[freeside.git] / rt / lib / RT / Action / 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::Action::Generic - a generic baseclass for RT Actions
49
50 =head1 SYNOPSIS
51
52   use RT::Action::Generic;
53
54 =head1 DESCRIPTION
55
56 =head1 METHODS
57
58 =begin testing
59
60 ok (require RT::Action::Generic);
61
62 =end testing
63
64 =cut
65
66 package RT::Action::Generic;
67
68 use strict;
69 use Scalar::Util;
70
71 use base qw/RT::Base/;
72
73 # {{{ sub new 
74 sub new  {
75   my $proto = shift;
76   my $class = ref($proto) || $proto;
77   my $self  = {};
78   bless ($self, $class);
79   $self->_Init(@_);
80   return $self;
81 }
82 # }}}
83
84 # {{{ sub _Init 
85 sub _Init  {
86   my $self = shift;
87   my %args = ( TransactionObj => undef,
88                TicketObj => undef,
89                ScripObj => undef,
90                TemplateObj => undef,
91                Argument => undef,
92                Type => undef,
93             CurrentUser => undef,
94                @_ );
95   
96   
97   $self->{'Argument'} = $args{'Argument'};
98   $self->{'ScripObj'} = $args{'ScripObj'};
99   $self->{'TicketObj'} = $args{'TicketObj'};
100   $self->{'TransactionObj'} = $args{'TransactionObj'};
101   $self->{'TemplateObj'} = $args{'TemplateObj'};
102   $self->{'Type'} = $args{'Type'};
103   $self->CurrentUser( $args{'CurrentUser'});
104     Scalar::Util::weaken($self->{'ScripObj'});
105     Scalar::Util::weaken($self->{'TicketObj'});
106     Scalar::Util::weaken($self->{'TemplateObj'});
107     Scalar::Util::weaken($self->{'TransactionObj'});
108
109
110
111
112
113 }
114 # }}}
115
116 # Access Scripwide data
117
118 # {{{ sub Argument 
119 sub Argument  {
120   my $self = shift;
121   return($self->{'Argument'});
122 }
123 # }}}
124
125 # {{{ sub TicketObj
126 sub TicketObj  {
127   my $self = shift;
128   return($self->{'TicketObj'});
129 }
130 # }}}
131
132 # {{{ sub TransactionObj
133 sub TransactionObj  {
134   my $self = shift;
135   return($self->{'TransactionObj'});
136 }
137 # }}}
138
139 # {{{ sub TemplateObj
140 sub TemplateObj  {
141   my $self = shift;
142   return($self->{'TemplateObj'});
143 }
144 # }}}
145
146 # {{{ sub ScripObj
147 sub ScripObj  {
148   my $self = shift;
149   return($self->{'ScripObj'});
150 }
151 # }}}
152
153 # {{{ sub Type
154 sub Type  {
155   my $self = shift;
156   return($self->{'Type'});
157 }
158 # }}}
159
160
161 # Scrip methods
162
163 #Do what we need to do and send it out.
164
165 # {{{ sub Commit 
166 sub Commit  {
167   my $self = shift;
168   return(0, $self->loc("Commit Stubbed"));
169 }
170 # }}}
171
172
173 #What does this type of Action does
174
175 # {{{ sub Describe 
176 sub Describe  {
177   my $self = shift;
178   return $self->loc("No description for [_1]", ref $self);
179 }
180 # }}}
181
182
183 #Parse the templates, get things ready to go.
184
185 # {{{ sub Prepare 
186 sub Prepare  {
187   my $self = shift;
188   return (0, $self->loc("Prepare Stubbed"));
189 }
190 # }}}
191
192
193 #If this rule applies to this transaction, return true.
194
195 # {{{ sub IsApplicable 
196 sub IsApplicable  {
197   my $self = shift;
198   return(undef);
199 }
200 # }}}
201
202 # {{{ sub DESTROY
203 sub DESTROY {
204     my $self = shift;
205
206     # We need to clean up all the references that might maybe get
207     # oddly circular
208     $self->{'TemplateObj'} =undef
209     $self->{'TicketObj'} = undef;
210     $self->{'TransactionObj'} = undef;
211     $self->{'ScripObj'} = undef;
212
213
214      
215 }
216
217 # }}}
218
219 eval "require RT::Action::Generic_Vendor";
220 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/Generic_Vendor.pm});
221 eval "require RT::Action::Generic_Local";
222 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/Generic_Local.pm});
223
224 1;