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