1 # {{{ BEGIN BPS TAGGED BLOCK
5 # This software is Copyright (c) 1996-2004 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
48 RT::ScripAction - RT Action object
57 This module should never be called directly by client code. it's an internal module which
58 should only be accessed through exported APIs in other modules.
63 ok (require RT::ScripAction);
72 no warnings qw(redefine);
78 my %Cols = ( Name => 'read',
79 Description => 'read',
82 Creator => 'read/auto',
83 Created => 'read/auto',
84 LastUpdatedBy => 'read/auto',
85 LastUpdated => 'read/auto'
87 return($self->SUPER::_Accessible(@_, %Cols));
94 Takes a hash. Creates a new Action entry.
95 should be better documented.
100 #TODO check these args and do smart things.
101 return($self->SUPER::Create(@_));
109 return (0, "ScripAction->Delete not implemented");
116 my $identifier = shift;
119 return (0, $self->loc('Input error'));
122 if ($identifier !~ /\D/) {
123 $self->SUPER::Load($identifier);
126 $self->LoadByCol('Name', $identifier);
131 # Set the template Id to the passed in template
132 my $template = shift;
134 $self->{'Template'} = $template;
136 return ($self->loc('[_1] ScripAction loaded', $self->Id));
142 =head2 LoadAction HASH
144 Takes a hash consisting of TicketObj and TransactionObj. Loads an RT::Action:: module.
150 my %args = ( TransactionObj => undef,
154 $self->{_TicketObj} = $args{TicketObj};
156 #TODO: Put this in an eval
157 $self->ExecModule =~ /^(\w+)$/;
159 my $type = "RT::Action::". $module;
161 eval "require $type" || die "Require of $type failed.\n$@\n";
163 $self->{'Action'} = $type->new ( ScripActionObj => $self,
164 TicketObj => $args{'TicketObj'},
165 ScripObj => $args{'ScripObj'},
166 TransactionObj => $args{'TransactionObj'},
167 TemplateObj => $self->TemplateObj,
168 Argument => $self->Argument,
169 CurrentUser => $self->CurrentUser
174 # {{{ sub TemplateObj
178 Return this action's template object
180 TODO: Why are we not using the Scrip's template object?
187 return undef unless $self->{Template};
188 if ( !$self->{'TemplateObj'} ) {
189 $self->{'TemplateObj'} = RT::Template->new( $self->CurrentUser );
190 $self->{'TemplateObj'}->LoadById( $self->{'Template'} );
192 if ( ( $self->{'TemplateObj'}->__Value('Queue') == 0 )
193 && $self->{'_TicketObj'} ) {
194 my $tmptemplate = RT::Template->new( $self->CurrentUser );
195 my ( $ok, $err ) = $tmptemplate->LoadQueueTemplate(
196 Queue => $self->{'_TicketObj'}->QueueObj->id,
197 Name => $self->{'TemplateObj'}->Name);
199 if ( $tmptemplate->id ) {
200 # found the queue-specific template with the same name
201 $self->{'TemplateObj'} = $tmptemplate;
207 return ( $self->{'TemplateObj'} );
211 # The following methods call the action object
217 return ($self->Action->Prepare());
225 return($self->Action->Commit());
234 return ($self->Action->Describe());
241 Return the actual RT::Action object for this scrip.
247 return ($self->{'Action'});
253 $self->{'_TicketObj'} = undef;
254 $self->{'Action'} = undef;
255 $self->{'TemplateObj'} = undef;
261 Between this, RT::Scrip and RT::Action::*, we need to be able to get rid of a
262 class. This just reeks of too much complexity -- jesse