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);
55 $self->{'table'} = "ScripActions";
56 return ($self->SUPER::_Init(@_));
63 my %Cols = ( Name => 'read',
64 Description => 'read',
67 Creator => 'read/auto',
68 Created => 'read/auto',
69 LastUpdatedBy => 'read/auto',
70 LastUpdated => 'read/auto'
72 return($self->SUPER::_Accessible(@_, %Cols));
79 Takes a hash. Creates a new Action entry.
80 should be better documented.
85 #TODO check these args and do smart things.
86 return($self->SUPER::Create(@_));
94 return (0, "ScripAction->Delete not implemented");
101 my $identifier = shift;
104 return (0, $self->loc('Input error'));
107 if ($identifier !~ /\D/) {
108 $self->SUPER::Load($identifier);
111 $self->LoadByCol('Name', $identifier);
116 # Set the template Id to the passed in template
117 my $template = shift;
119 $self->{'Template'} = $template;
121 return ($self->loc('[_1] ScripAction loaded', $self->Id));
127 =head2 LoadAction HASH
129 Takes a hash consisting of TicketObj and TransactionObj. Loads an RT::Action:: module.
135 my %args = ( TransactionObj => undef,
139 #TODO: Put this in an eval
140 $self->ExecModule =~ /^(\w+)$/;
142 my $type = "RT::Action::". $module;
144 eval "require $type" || die "Require of $type failed.\n$@\n";
146 $self->{'Action'} = $type->new ( 'ScripActionObj' => $self,
147 'TicketObj' => $args{'TicketObj'},
148 'ScripObj' => $args{'ScripObj'},
149 'TransactionObj' => $args{'TransactionObj'},
150 'TemplateObj' => $self->TemplateObj,
151 'Argument' => $self->Argument,
156 # {{{ sub TemplateObj
160 Return this action\'s template object
166 return undef unless $self->{Template};
167 if (!$self->{'TemplateObj'}) {
168 require RT::Template;
169 $self->{'TemplateObj'} = RT::Template->new($self->CurrentUser);
170 $self->{'TemplateObj'}->LoadById($self->{'Template'});
174 return ($self->{'TemplateObj'});
178 # The following methods call the action object
184 return ($self->{'Action'}->Prepare());
192 return($self->{'Action'}->Commit());
201 return ($self->{'Action'}->Describe());
209 $self->{'Action'} = undef;
210 $self->{'TemplateObj'} = undef;