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