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::ScripCondition - RT scrip conditional
55 use RT::ScripCondition;
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::ScripCondition;
76 use base 'RT::Record';
79 sub Table {'ScripConditions'}
84 my %Cols = ( Name => 'read',
85 Description => 'read',
86 ApplicableTransTypes => '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 Condition entry.
101 should be better documented.
107 return($self->SUPER::Create(@_));
113 No API available for deleting things just yet.
119 return(0, $self->loc('Unimplemented'));
123 =head2 Load IDENTIFIER
125 Loads a condition takes a name or ScripCondition id.
131 my $identifier = shift;
133 unless (defined $identifier) {
137 if ($identifier !~ /\D/) {
138 return ($self->SUPER::LoadById($identifier));
141 return ($self->LoadByCol('Name', $identifier));
146 =head2 LoadCondition HASH
148 takes a hash which has the following elements: TransactionObj and TicketObj.
149 Loads the Condition module in question.
156 my %args = ( TransactionObj => undef,
160 #TODO: Put this in an eval
161 $self->ExecModule =~ /^(\w+)$/;
163 my $type = "RT::Condition::". $module;
165 $type->require or die "Require of $type condition module failed.\n$@\n";
167 $self->{'Condition'} = $type->new ( 'ScripConditionObj' => $self,
168 'TicketObj' => $args{'TicketObj'},
169 'ScripObj' => $args{'ScripObj'},
170 'TransactionObj' => $args{'TransactionObj'},
171 'Argument' => $self->Argument,
172 'ApplicableTransTypes' => $self->ApplicableTransTypes,
173 CurrentUser => $self->CurrentUser
182 Helper method to call the condition module's Describe method.
188 return ($self->{'Condition'}->Describe());
195 Helper method to call the condition module's IsApplicable method.
201 return ($self->{'Condition'}->IsApplicable());
209 Returns the current value of id.
210 (In the database, id is stored as int(11).)
218 Returns the current value of Name.
219 (In the database, Name is stored as varchar(200).)
227 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
228 (In the database, Name will be stored as a varchar(200).)
236 Returns the current value of Description.
237 (In the database, Description is stored as varchar(255).)
241 =head2 SetDescription VALUE
244 Set Description to VALUE.
245 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
246 (In the database, Description will be stored as a varchar(255).)
254 Returns the current value of ExecModule.
255 (In the database, ExecModule is stored as varchar(60).)
259 =head2 SetExecModule VALUE
262 Set ExecModule to VALUE.
263 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
264 (In the database, ExecModule will be stored as a varchar(60).)
272 Returns the current value of Argument.
273 (In the database, Argument is stored as varbinary(255).)
277 =head2 SetArgument VALUE
280 Set Argument to VALUE.
281 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
282 (In the database, Argument will be stored as a varbinary(255).)
288 =head2 ApplicableTransTypes
290 Returns the current value of ApplicableTransTypes.
291 (In the database, ApplicableTransTypes is stored as varchar(60).)
295 =head2 SetApplicableTransTypes VALUE
298 Set ApplicableTransTypes to VALUE.
299 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
300 (In the database, ApplicableTransTypes will be stored as a varchar(60).)
308 Returns the current value of Creator.
309 (In the database, Creator is stored as int(11).)
317 Returns the current value of Created.
318 (In the database, Created is stored as datetime.)
326 Returns the current value of LastUpdatedBy.
327 (In the database, LastUpdatedBy is stored as int(11).)
335 Returns the current value of LastUpdated.
336 (In the database, LastUpdated is stored as datetime.)
343 sub _CoreAccessible {
347 {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
349 {read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => ''},
351 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
353 {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''},
355 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varbinary(255)', default => ''},
356 ApplicableTransTypes =>
357 {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''},
359 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
361 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
363 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
365 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
372 my ($importer, $uid, $data) = @_;
374 $class->SUPER::PreInflate( $importer, $uid, $data );
376 return not $importer->SkipBy( "Name", $class, $uid, $data );
383 Dependencies => undef,
386 my $deps = $args{'Dependencies'};
389 my $objs = RT::Scrips->new( $self->CurrentUser );
390 $objs->Limit( FIELD => 'ScripCondition', VALUE => $self->Id );
391 $deps->_PushDependencies(
393 Flags => RT::Shredder::Constants::DEPENDS_ON,
394 TargetObjects => $objs,
395 Shredder => $args{'Shredder'}
398 return $self->SUPER::__DependsOn( %args );
401 RT::Base->_ImportOverlays();