1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2013 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';
69 sub Table {'ScripActions'}
77 Description => 'read',
80 Creator => 'read/auto',
81 Created => 'read/auto',
82 LastUpdatedBy => 'read/auto',
83 LastUpdated => 'read/auto'
85 return($self->SUPER::_Accessible(@_, %Cols));
93 Takes a hash. Creates a new Action entry.
99 #TODO check these args and do smart things.
100 return($self->SUPER::Create(@_));
105 return (0, "ScripAction->Delete not implemented");
109 =head2 Load IDENTIFIER
111 Loads an action by its Name.
113 Returns: Id, Error Message
119 my $identifier = shift;
122 return wantarray ? (0, $self->loc('Input error')) : 0;
126 if ($identifier !~ /\D/) {
127 ($ok, $msg) = $self->SUPER::Load($identifier);
130 ($ok, $msg) = $self->LoadByCol('Name', $identifier);
135 Arguments => "Template as second argument",
138 $self->{'Template'} = shift;
141 return wantarray ? ($ok, $msg) : $ok;
145 =head2 LoadAction HASH
147 Takes a hash consisting of TicketObj and TransactionObj. Loads an RT::Action:: module.
154 TransactionObj => undef,
160 # XXX: this whole block goes with TemplateObj method
161 unless ( @_ && exists $args{'TemplateObj'} ) {
162 local $self->{_TicketObj} = $args{TicketObj};
163 $args{'TemplateObj'} = $self->TemplateObj;
166 $self->{'TemplateObj'} = $args{'TemplateObj'};
169 $self->ExecModule =~ /^(\w+)$/;
171 my $type = "RT::Action::". $module;
173 eval "require $type" || die "Require of $type failed.\n$@\n";
175 return $self->{'Action'} = $type->new(
177 Argument => $self->Argument,
178 CurrentUser => $self->CurrentUser,
179 ScripActionObj => $self,
186 Return this action's template object. Deprecated.
196 return undef unless $self->{Template};
197 if ( !$self->{'TemplateObj'} ) {
198 $self->{'TemplateObj'} = RT::Template->new( $self->CurrentUser );
199 $self->{'TemplateObj'}->Load( $self->{'Template'} );
201 if ( ( $self->{'TemplateObj'}->__Value('Queue') == 0 )
202 && $self->{'_TicketObj'} ) {
203 my $tmptemplate = RT::Template->new( $self->CurrentUser );
204 my ( $ok, $err ) = $tmptemplate->LoadQueueTemplate(
205 Queue => $self->{'_TicketObj'}->QueueObj->id,
206 Name => $self->{'TemplateObj'}->Name);
208 if ( $tmptemplate->id ) {
209 # found the queue-specific template with the same name
210 $self->{'TemplateObj'} = $tmptemplate;
216 return ( $self->{'TemplateObj'} );
221 $self->{_Message_ID} = 0;
222 return $self->Action->Prepare( @_ );
227 return $self->Action->Commit( @_ );
232 return $self->Action->Describe( @_ );
237 Return the actual RT::Action object for this scrip.
243 return $self->{'Action'};
248 Returns the current value of id.
249 (In the database, id is stored as int(11).)
254 Returns the current value of Name.
255 (In the database, Name is stored as varchar(200).)
260 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
261 (In the database, Name will be stored as a varchar(200).)
266 Returns the current value of Description.
267 (In the database, Description is stored as varchar(255).)
269 =head2 SetDescription VALUE
271 Set Description to VALUE.
272 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
273 (In the database, Description will be stored as a varchar(255).)
278 Returns the current value of ExecModule.
279 (In the database, ExecModule is stored as varchar(60).)
281 =head2 SetExecModule VALUE
283 Set ExecModule to VALUE.
284 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
285 (In the database, ExecModule will be stored as a varchar(60).)
290 Returns the current value of Argument.
291 (In the database, Argument is stored as varbinary(255).)
293 =head2 SetArgument VALUE
295 Set Argument to VALUE.
296 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
297 (In the database, Argument will be stored as a varbinary(255).)
302 Returns the current value of Creator.
303 (In the database, Creator is stored as int(11).)
307 Returns the current value of Created.
308 (In the database, Created is stored as datetime.)
312 Returns the current value of LastUpdatedBy.
313 (In the database, LastUpdatedBy is stored as int(11).)
317 Returns the current value of LastUpdated.
318 (In the database, LastUpdated is stored as datetime.)
323 sub _CoreAccessible {
327 {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
329 {read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => ''},
331 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
333 {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''},
335 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varbinary(255)', default => ''},
337 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
339 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
341 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
343 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
350 my ($importer, $uid, $data) = @_;
352 $class->SUPER::PreInflate( $importer, $uid, $data );
354 return not $importer->SkipBy( "Name", $class, $uid, $data );
357 RT::Base->_ImportOverlays();