1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC
6 # <sales@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/licenses/old-licenses/gpl-2.0.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 }}}
51 RT::ScripAction - RT Action object
55 This module should never be called directly by client code. it's an
56 internal module which should only be accessed through exported APIs
62 package RT::ScripAction;
67 use base 'RT::Record';
70 sub Table {'ScripActions'}
78 Description => 'read',
81 Creator => 'read/auto',
82 Created => 'read/auto',
83 LastUpdatedBy => 'read/auto',
84 LastUpdated => 'read/auto'
86 return($self->SUPER::_Accessible(@_, %Cols));
94 Takes a hash. Creates a new Action entry.
100 #TODO check these args and do smart things.
101 return($self->SUPER::Create(@_));
106 return (0, "ScripAction->Delete not implemented");
110 =head2 Load IDENTIFIER
112 Loads an action by its Name.
114 Returns: Id, Error Message
120 my $identifier = shift;
123 return wantarray ? (0, $self->loc('Input error')) : 0;
127 if ($identifier !~ /\D/) {
128 ($ok, $msg) = $self->SUPER::Load($identifier);
131 ($ok, $msg) = $self->LoadByCol('Name', $identifier);
136 Arguments => "Template as second argument",
139 $self->{'Template'} = shift;
142 return wantarray ? ($ok, $msg) : $ok;
146 =head2 LoadAction HASH
148 Takes a hash consisting of TicketObj and TransactionObj. Loads an RT::Action:: module.
155 TransactionObj => undef,
161 # XXX: this whole block goes with TemplateObj method
162 unless ( @_ && exists $args{'TemplateObj'} ) {
163 local $self->{_TicketObj} = $args{TicketObj};
164 $args{'TemplateObj'} = $self->TemplateObj;
167 $self->{'TemplateObj'} = $args{'TemplateObj'};
170 $self->ExecModule =~ /^(\w+)$/;
172 my $type = "RT::Action::". $module;
174 $type->require or die "Require of $type action module failed.\n$@\n";
176 return $self->{'Action'} = $type->new(
178 Argument => $self->Argument,
179 CurrentUser => $self->CurrentUser,
180 ScripActionObj => $self,
187 Return this action's template object. Deprecated.
197 if ( !$self->{'TemplateObj'} ) {
198 return undef unless $self->{Template};
199 $self->{'TemplateObj'} = RT::Template->new( $self->CurrentUser );
200 $self->{'TemplateObj'}->Load( $self->{'Template'} );
202 if ( ( $self->{'TemplateObj'}->__Value('Queue') == 0 )
203 && $self->{'_TicketObj'} ) {
204 my $tmptemplate = RT::Template->new( $self->CurrentUser );
205 my ( $ok, $err ) = $tmptemplate->LoadQueueTemplate(
206 Queue => $self->{'_TicketObj'}->QueueObj->id,
207 Name => $self->{'TemplateObj'}->Name);
209 if ( $tmptemplate->id ) {
210 # found the queue-specific template with the same name
211 $self->{'TemplateObj'} = $tmptemplate;
217 return ( $self->{'TemplateObj'} );
222 $self->{_Message_ID} = 0;
223 return $self->Action->Prepare( @_ );
228 return $self->Action->Commit( @_ );
233 return $self->Action->Describe( @_ );
238 Return the actual RT::Action object for this scrip.
244 return $self->{'Action'};
249 Returns the current value of id.
250 (In the database, id is stored as int(11).)
255 Returns the current value of Name.
256 (In the database, Name is stored as varchar(200).)
261 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
262 (In the database, Name will be stored as a varchar(200).)
267 Returns the current value of Description.
268 (In the database, Description is stored as varchar(255).)
270 =head2 SetDescription VALUE
272 Set Description to VALUE.
273 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
274 (In the database, Description will be stored as a varchar(255).)
279 Returns the current value of ExecModule.
280 (In the database, ExecModule is stored as varchar(60).)
282 =head2 SetExecModule VALUE
284 Set ExecModule to VALUE.
285 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
286 (In the database, ExecModule will be stored as a varchar(60).)
291 Returns the current value of Argument.
292 (In the database, Argument is stored as varbinary(255).)
294 =head2 SetArgument VALUE
296 Set Argument to VALUE.
297 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
298 (In the database, Argument will be stored as a varbinary(255).)
303 Returns the current value of Creator.
304 (In the database, Creator is stored as int(11).)
308 Returns the current value of Created.
309 (In the database, Created is stored as datetime.)
313 Returns the current value of LastUpdatedBy.
314 (In the database, LastUpdatedBy is stored as int(11).)
318 Returns the current value of LastUpdated.
319 (In the database, LastUpdated is stored as datetime.)
324 sub _CoreAccessible {
328 {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
330 {read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => ''},
332 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
334 {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''},
336 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varbinary(255)', default => ''},
338 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
340 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
342 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
344 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
351 my ($importer, $uid, $data) = @_;
353 $class->SUPER::PreInflate( $importer, $uid, $data );
355 return not $importer->SkipBy( "Name", $class, $uid, $data );
362 Dependencies => undef,
365 my $deps = $args{'Dependencies'};
368 my $objs = RT::Scrips->new( $self->CurrentUser );
369 $objs->Limit( FIELD => 'ScripAction', VALUE => $self->Id );
370 $deps->_PushDependencies(
372 Flags => RT::Shredder::Constants::DEPENDS_ON,
373 TargetObjects => $objs,
374 Shredder => $args{'Shredder'}
377 return $self->SUPER::__DependsOn( %args );
380 RT::Base->_ImportOverlays();