3 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 # (Except where explictly superceded by other copyright notices)
7 # This work is made available to you under the terms of Version 2 of
8 # the GNU General Public License. A copy of that license should have
9 # been provided with this software, but in any event can be snarfed
12 # This work is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # Unless otherwise specified, all modifications, corrections or
18 # extensions to this work which alter its source code become the
19 # property of Best Practical Solutions, LLC when submitted for
20 # inclusion in the work.
26 RT::ScripCondition - RT scrip conditional
30 use RT::ScripCondition;
35 This module should never be called directly by client code. it's an internal module which
36 should only be accessed through exported APIs in other modules.
41 ok (require RT::ScripCondition);
50 no warnings qw(redefine);
56 $self->{'table'} = "ScripConditions";
57 return ($self->SUPER::_Init(@_));
64 my %Cols = ( Name => 'read',
65 Description => 'read',
66 ApplicableTransTypes => 'read',
69 Creator => 'read/auto',
70 Created => 'read/auto',
71 LastUpdatedBy => 'read/auto',
72 LastUpdated => 'read/auto'
74 return($self->SUPER::_Accessible(@_, %Cols));
82 Takes a hash. Creates a new Condition entry.
83 should be better documented.
89 return($self->SUPER::Create(@_));
97 No API available for deleting things just yet.
103 return(0, $self->loc('Unimplemented'));
109 =head2 Load IDENTIFIER
111 Loads a condition takes a name or ScripCondition id.
117 my $identifier = shift;
119 unless (defined $identifier) {
123 if ($identifier !~ /\D/) {
124 return ($self->SUPER::LoadById($identifier));
127 return ($self->LoadByCol('Name', $identifier));
132 # {{{ sub LoadCondition
134 =head2 LoadCondition HASH
136 takes a hash which has the following elements: TransactionObj and TicketObj.
137 Loads the Condition module in question.
144 my %args = ( TransactionObj => undef,
148 #TODO: Put this in an eval
149 $self->ExecModule =~ /^(\w+)$/;
151 my $type = "RT::Condition::". $module;
153 eval "require $type" || die "Require of $type failed.\n$@\n";
155 $self->{'Condition'} = $type->new ( 'ScripConditionObj' => $self,
156 'TicketObj' => $args{'TicketObj'},
157 'ScripObj' => $args{'ScripObj'},
158 'TransactionObj' => $args{'TransactionObj'},
159 'Argument' => $self->Argument,
160 'ApplicableTransTypes' => $self->ApplicableTransTypes,
165 # {{{ The following methods call the Condition object
172 Helper method to call the condition module\'s Describe method.
178 return ($self->{'Condition'}->Describe());
183 # {{{ sub IsApplicable
187 Helper method to call the condition module\'s IsApplicable method.
193 return ($self->{'Condition'}->IsApplicable());
203 $self->{'Condition'} = undef;