1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2014 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
60 This module should never be called directly by client code. it's an internal module which
61 should only be accessed through exported APIs in other modules.
70 package RT::ScripAction;
75 use base 'RT::Record';
77 sub Table {'ScripActions'}
85 my %Cols = ( Name => 'read',
86 Description => 'read',
89 Creator => 'read/auto',
90 Created => 'read/auto',
91 LastUpdatedBy => 'read/auto',
92 LastUpdated => 'read/auto'
94 return($self->SUPER::_Accessible(@_, %Cols));
100 Takes a hash. Creates a new Action entry. should be better
107 #TODO check these args and do smart things.
108 return($self->SUPER::Create(@_));
114 return (0, "ScripAction->Delete not implemented");
118 =head2 Load IDENTIFIER
120 Loads an action by its Name.
122 Returns: Id, Error Message
128 my $identifier = shift;
131 return (0, $self->loc('Input error'));
135 if ($identifier !~ /\D/) {
136 ($ok, $msg) = $self->SUPER::Load($identifier);
139 ($ok, $msg) = $self->LoadByCol('Name', $identifier);
144 # Set the template Id to the passed in template
145 my $template = shift;
147 $self->{'Template'} = $template;
154 =head2 LoadAction HASH
156 Takes a hash consisting of TicketObj and TransactionObj. Loads an RT::Action:: module.
162 my %args = ( TransactionObj => undef,
166 $self->{_TicketObj} = $args{TicketObj};
168 #TODO: Put this in an eval
169 $self->ExecModule =~ /^(\w+)$/;
171 my $type = "RT::Action::". $module;
173 eval "require $type" || die "Require of $type failed.\n$@\n";
175 $self->{'Action'} = $type->new ( Argument => $self->Argument,
176 CurrentUser => $self->CurrentUser,
177 ScripActionObj => $self,
178 ScripObj => $args{'ScripObj'},
179 TemplateObj => $self->TemplateObj,
180 TicketObj => $args{'TicketObj'},
181 TransactionObj => $args{'TransactionObj'},
188 Return this action's template object
190 TODO: Why are we not using the Scrip's template object?
197 return undef unless $self->{Template};
198 if ( !$self->{'TemplateObj'} ) {
199 $self->{'TemplateObj'} = RT::Template->new( $self->CurrentUser );
200 $self->{'TemplateObj'}->LoadById( $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'} );
220 # The following methods call the action object
225 $self->{_Message_ID} = 0;
226 return ($self->Action->Prepare());
232 return($self->Action->Commit());
239 return ($self->Action->Describe());
245 Return the actual RT::Action object for this scrip.
251 return ($self->{'Action'});
256 $self->{'_TicketObj'} = undef;
257 $self->{'Action'} = undef;
258 $self->{'TemplateObj'} = undef;
263 Between this, RT::Scrip and RT::Action::*, we need to be able to get rid of a
264 class. This just reeks of too much complexity -- jesse
273 Returns the current value of id.
274 (In the database, id is stored as int(11).)
282 Returns the current value of Name.
283 (In the database, Name is stored as varchar(200).)
291 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
292 (In the database, Name will be stored as a varchar(200).)
300 Returns the current value of Description.
301 (In the database, Description is stored as varchar(255).)
305 =head2 SetDescription VALUE
308 Set Description to VALUE.
309 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
310 (In the database, Description will be stored as a varchar(255).)
318 Returns the current value of ExecModule.
319 (In the database, ExecModule is stored as varchar(60).)
323 =head2 SetExecModule VALUE
326 Set ExecModule to VALUE.
327 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
328 (In the database, ExecModule will be stored as a varchar(60).)
336 Returns the current value of Argument.
337 (In the database, Argument is stored as varbinary(255).)
341 =head2 SetArgument VALUE
344 Set Argument to VALUE.
345 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
346 (In the database, Argument will be stored as a varbinary(255).)
354 Returns the current value of Creator.
355 (In the database, Creator is stored as int(11).)
363 Returns the current value of Created.
364 (In the database, Created is stored as datetime.)
372 Returns the current value of LastUpdatedBy.
373 (In the database, LastUpdatedBy is stored as int(11).)
381 Returns the current value of LastUpdated.
382 (In the database, LastUpdated is stored as datetime.)
389 sub _CoreAccessible {
393 {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
395 {read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => ''},
397 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
399 {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''},
401 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varbinary(255)', default => ''},
403 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
405 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
407 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
409 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
414 RT::Base->_ImportOverlays();