1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2005 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., 675 Mass Ave, Cambridge, MA 02139, USA.
28 # CONTRIBUTION SUBMISSION POLICY:
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.)
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.
45 # END BPS TAGGED BLOCK }}}
49 RT::ScripAction - RT Action object
58 This module should never be called directly by client code. it's an internal module which
59 should only be accessed through exported APIs in other modules.
64 ok (require RT::ScripAction);
73 package RT::ScripAction;
76 no warnings qw(redefine);
82 my %Cols = ( Name => 'read',
83 Description => 'read',
86 Creator => 'read/auto',
87 Created => 'read/auto',
88 LastUpdatedBy => 'read/auto',
89 LastUpdated => 'read/auto'
91 return($self->SUPER::_Accessible(@_, %Cols));
99 Takes a hash. Creates a new Action entry. should be better
106 #TODO check these args and do smart things.
107 return($self->SUPER::Create(@_));
115 return (0, "ScripAction->Delete not implemented");
121 =head2 Load IDENTIFIER
123 Loads an action by its Name.
125 Returns: Id, Error Message
131 my $identifier = shift;
134 return (0, $self->loc('Input error'));
137 if ($identifier !~ /\D/) {
138 $self->SUPER::Load($identifier);
141 $self->LoadByCol('Name', $identifier);
146 # Set the template Id to the passed in template
147 my $template = shift;
149 $self->{'Template'} = $template;
151 return ($self->Id, ($self->loc('[_1] ScripAction loaded', $self->Id)));
157 =head2 LoadAction HASH
159 Takes a hash consisting of TicketObj and TransactionObj. Loads an RT::Action:: module.
165 my %args = ( TransactionObj => undef,
169 $self->{_TicketObj} = $args{TicketObj};
171 #TODO: Put this in an eval
172 $self->ExecModule =~ /^(\w+)$/;
174 my $type = "RT::Action::". $module;
176 eval "require $type" || die "Require of $type failed.\n$@\n";
178 $self->{'Action'} = $type->new ( Argument => $self->Argument,
179 CurrentUser => $self->CurrentUser,
180 ScripActionObj => $self,
181 ScripObj => $args{'ScripObj'},
182 TemplateObj => $self->TemplateObj,
183 TicketObj => $args{'TicketObj'},
184 TransactionObj => $args{'TransactionObj'},
189 # {{{ sub TemplateObj
193 Return this action's template object
195 TODO: Why are we not using the Scrip's template object?
202 return undef unless $self->{Template};
203 if ( !$self->{'TemplateObj'} ) {
204 $self->{'TemplateObj'} = RT::Template->new( $self->CurrentUser );
205 $self->{'TemplateObj'}->LoadById( $self->{'Template'} );
207 if ( ( $self->{'TemplateObj'}->__Value('Queue') == 0 )
208 && $self->{'_TicketObj'} ) {
209 my $tmptemplate = RT::Template->new( $self->CurrentUser );
210 my ( $ok, $err ) = $tmptemplate->LoadQueueTemplate(
211 Queue => $self->{'_TicketObj'}->QueueObj->id,
212 Name => $self->{'TemplateObj'}->Name);
214 if ( $tmptemplate->id ) {
215 # found the queue-specific template with the same name
216 $self->{'TemplateObj'} = $tmptemplate;
222 return ( $self->{'TemplateObj'} );
226 # The following methods call the action object
232 $self->{_Message_ID} = 0;
233 return ($self->Action->Prepare());
241 return($self->Action->Commit());
250 return ($self->Action->Describe());
257 Return the actual RT::Action object for this scrip.
263 return ($self->{'Action'});
269 $self->{'_TicketObj'} = undef;
270 $self->{'Action'} = undef;
271 $self->{'TemplateObj'} = undef;
277 Between this, RT::Scrip and RT::Action::*, we need to be able to get rid of a
278 class. This just reeks of too much complexity -- jesse