1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
6 # <jesse@bestpractical.com>
8 # (Except where explicitly superseded by other copyright notices)
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
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.
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.
30 # CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 # END BPS TAGGED BLOCK }}}
50 RT::ScripAction - RT Action object
59 This module should never be called directly by client code. it's an internal module which
60 should only be accessed through exported APIs in other modules.
65 ok (require RT::ScripAction);
74 package RT::ScripAction;
77 no warnings qw(redefine);
83 my %Cols = ( Name => 'read',
84 Description => 'read',
87 Creator => 'read/auto',
88 Created => 'read/auto',
89 LastUpdatedBy => 'read/auto',
90 LastUpdated => 'read/auto'
92 return($self->SUPER::_Accessible(@_, %Cols));
100 Takes a hash. Creates a new Action entry. should be better
107 #TODO check these args and do smart things.
108 return($self->SUPER::Create(@_));
116 return (0, "ScripAction->Delete not implemented");
122 =head2 Load IDENTIFIER
124 Loads an action by its Name.
126 Returns: Id, Error Message
132 my $identifier = shift;
135 return (0, $self->loc('Input error'));
138 if ($identifier !~ /\D/) {
139 $self->SUPER::Load($identifier);
142 $self->LoadByCol('Name', $identifier);
147 # Set the template Id to the passed in template
148 my $template = shift;
150 $self->{'Template'} = $template;
152 return ($self->Id, ($self->loc('[_1] ScripAction loaded', $self->Id)));
158 =head2 LoadAction HASH
160 Takes a hash consisting of TicketObj and TransactionObj. Loads an RT::Action:: module.
166 my %args = ( TransactionObj => undef,
170 $self->{_TicketObj} = $args{TicketObj};
172 #TODO: Put this in an eval
173 $self->ExecModule =~ /^(\w+)$/;
175 my $type = "RT::Action::". $module;
177 eval "require $type" || die "Require of $type failed.\n$@\n";
179 $self->{'Action'} = $type->new ( Argument => $self->Argument,
180 CurrentUser => $self->CurrentUser,
181 ScripActionObj => $self,
182 ScripObj => $args{'ScripObj'},
183 TemplateObj => $self->TemplateObj,
184 TicketObj => $args{'TicketObj'},
185 TransactionObj => $args{'TransactionObj'},
190 # {{{ sub TemplateObj
194 Return this action's template object
196 TODO: Why are we not using the Scrip's template object?
203 return undef unless $self->{Template};
204 if ( !$self->{'TemplateObj'} ) {
205 $self->{'TemplateObj'} = RT::Template->new( $self->CurrentUser );
206 $self->{'TemplateObj'}->LoadById( $self->{'Template'} );
208 if ( ( $self->{'TemplateObj'}->__Value('Queue') == 0 )
209 && $self->{'_TicketObj'} ) {
210 my $tmptemplate = RT::Template->new( $self->CurrentUser );
211 my ( $ok, $err ) = $tmptemplate->LoadQueueTemplate(
212 Queue => $self->{'_TicketObj'}->QueueObj->id,
213 Name => $self->{'TemplateObj'}->Name);
215 if ( $tmptemplate->id ) {
216 # found the queue-specific template with the same name
217 $self->{'TemplateObj'} = $tmptemplate;
223 return ( $self->{'TemplateObj'} );
227 # The following methods call the action object
233 $self->{_Message_ID} = 0;
234 return ($self->Action->Prepare());
242 return($self->Action->Commit());
251 return ($self->Action->Describe());
258 Return the actual RT::Action object for this scrip.
264 return ($self->{'Action'});
270 $self->{'_TicketObj'} = undef;
271 $self->{'Action'} = undef;
272 $self->{'TemplateObj'} = undef;
278 Between this, RT::Scrip and RT::Action::*, we need to be able to get rid of a
279 class. This just reeks of too much complexity -- jesse