1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2015 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';
78 sub Table {'ScripConditions'}
84 $self->{'table'} = "ScripConditions";
85 return ($self->SUPER::_Init(@_));
90 my %Cols = ( Name => 'read',
91 Description => 'read',
92 ApplicableTransTypes => 'read',
95 Creator => 'read/auto',
96 Created => 'read/auto',
97 LastUpdatedBy => 'read/auto',
98 LastUpdated => 'read/auto'
100 return($self->SUPER::_Accessible(@_, %Cols));
106 Takes a hash. Creates a new Condition entry.
107 should be better documented.
113 return($self->SUPER::Create(@_));
119 No API available for deleting things just yet.
125 return(0, $self->loc('Unimplemented'));
129 =head2 Load IDENTIFIER
131 Loads a condition takes a name or ScripCondition id.
137 my $identifier = shift;
139 unless (defined $identifier) {
143 if ($identifier !~ /\D/) {
144 return ($self->SUPER::LoadById($identifier));
147 return ($self->LoadByCol('Name', $identifier));
152 =head2 LoadCondition HASH
154 takes a hash which has the following elements: TransactionObj and TicketObj.
155 Loads the Condition module in question.
162 my %args = ( TransactionObj => undef,
166 #TODO: Put this in an eval
167 $self->ExecModule =~ /^(\w+)$/;
169 my $type = "RT::Condition::". $module;
171 eval "require $type" || die "Require of $type failed.\n$@\n";
173 $self->{'Condition'} = $type->new ( 'ScripConditionObj' => $self,
174 'TicketObj' => $args{'TicketObj'},
175 'ScripObj' => $args{'ScripObj'},
176 'TransactionObj' => $args{'TransactionObj'},
177 'Argument' => $self->Argument,
178 'ApplicableTransTypes' => $self->ApplicableTransTypes,
179 CurrentUser => $self->CurrentUser
188 Helper method to call the condition module's Describe method.
194 return ($self->{'Condition'}->Describe());
201 Helper method to call the condition module's IsApplicable method.
207 return ($self->{'Condition'}->IsApplicable());
214 $self->{'Condition'} = undef;
225 Returns the current value of id.
226 (In the database, id is stored as int(11).)
234 Returns the current value of Name.
235 (In the database, Name is stored as varchar(200).)
243 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
244 (In the database, Name will be stored as a varchar(200).)
252 Returns the current value of Description.
253 (In the database, Description is stored as varchar(255).)
257 =head2 SetDescription VALUE
260 Set Description to VALUE.
261 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
262 (In the database, Description will be stored as a varchar(255).)
270 Returns the current value of ExecModule.
271 (In the database, ExecModule is stored as varchar(60).)
275 =head2 SetExecModule VALUE
278 Set ExecModule to VALUE.
279 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
280 (In the database, ExecModule will be stored as a varchar(60).)
288 Returns the current value of Argument.
289 (In the database, Argument is stored as varbinary(255).)
293 =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).)
304 =head2 ApplicableTransTypes
306 Returns the current value of ApplicableTransTypes.
307 (In the database, ApplicableTransTypes is stored as varchar(60).)
311 =head2 SetApplicableTransTypes VALUE
314 Set ApplicableTransTypes to VALUE.
315 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
316 (In the database, ApplicableTransTypes will be stored as a varchar(60).)
324 Returns the current value of Creator.
325 (In the database, Creator is stored as int(11).)
333 Returns the current value of Created.
334 (In the database, Created is stored as datetime.)
342 Returns the current value of LastUpdatedBy.
343 (In the database, LastUpdatedBy is stored as int(11).)
351 Returns the current value of LastUpdated.
352 (In the database, LastUpdated is stored as datetime.)
359 sub _CoreAccessible {
363 {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
365 {read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => ''},
367 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
369 {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''},
371 {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varbinary(255)', default => ''},
372 ApplicableTransTypes =>
373 {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''},
375 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
377 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
379 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
381 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
386 RT::Base->_ImportOverlays();