3 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 # (Except where explictly superceded by other copyright notices)
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
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.
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.
26 RT::ScripAction - RT Action object
35 This module should never be called directly by client code. it's an internal module which
36 should only be accessed through exported APIs in other modules.
41 ok (require RT::ScripAction);
50 no warnings qw(redefine);
56 $self->{'table'} = "ScripActions";
57 return ($self->SUPER::_Init(@_));
64 my %Cols = ( Name => 'read',
65 Description => 'read',
68 Creator => 'read/auto',
69 Created => 'read/auto',
70 LastUpdatedBy => 'read/auto',
71 LastUpdated => 'read/auto'
73 return($self->SUPER::_Accessible(@_, %Cols));
80 Takes a hash. Creates a new Action entry.
81 should be better documented.
86 #TODO check these args and do smart things.
87 return($self->SUPER::Create(@_));
95 return (0, "ScripAction->Delete not implemented");
102 my $identifier = shift;
105 return (0, $self->loc('Input error'));
108 if ($identifier !~ /\D/) {
109 $self->SUPER::Load($identifier);
112 $self->LoadByCol('Name', $identifier);
117 # Set the template Id to the passed in template
118 my $template = shift;
120 $self->{'Template'} = $template;
122 return ($self->loc('[_1] ScripAction loaded', $self->Id));
128 =head2 LoadAction HASH
130 Takes a hash consisting of TicketObj and TransactionObj. Loads an RT::Action:: module.
136 my %args = ( TransactionObj => undef,
140 $self->{_TicketObj} = $args{TicketObj};
142 #TODO: Put this in an eval
143 $self->ExecModule =~ /^(\w+)$/;
145 my $type = "RT::Action::". $module;
147 eval "require $type" || die "Require of $type failed.\n$@\n";
149 $self->{'Action'} = $type->new ( 'ScripActionObj' => $self,
150 'TicketObj' => $args{'TicketObj'},
151 'ScripObj' => $args{'ScripObj'},
152 'TransactionObj' => $args{'TransactionObj'},
153 'TemplateObj' => $self->TemplateObj,
154 'Argument' => $self->Argument,
159 # {{{ sub TemplateObj
163 Return this action\'s template object
169 return undef unless $self->{Template};
170 if ( !$self->{'TemplateObj'} ) {
171 $self->{'TemplateObj'} = RT::Template->new( $self->CurrentUser );
172 $self->{'TemplateObj'}->LoadById( $self->{'Template'} );
174 if ( ( $self->{'TemplateObj'}->__Value('Queue') == 0 )
175 && $self->{'_TicketObj'} ) {
176 my $tmptemplate = RT::Template->new( $self->CurrentUser );
177 my ( $ok, $err ) = $tmptemplate->LoadQueueTemplate(
178 Queue => $self->{'_TicketObj'}->QueueObj->id,
179 Name => $self->{'TemplateObj'}->Name);
181 if ( $tmptemplate->id ) {
182 # found the queue-specific template with the same name
183 $self->{'TemplateObj'} = $tmptemplate;
189 return ( $self->{'TemplateObj'} );
193 # The following methods call the action object
199 return ($self->{'Action'}->Prepare());
207 return($self->{'Action'}->Commit());
216 return ($self->{'Action'}->Describe());
224 $self->{'_TicketObj'} = undef;
225 $self->{'Action'} = undef;
226 $self->{'TemplateObj'} = undef;