]>
Commit | Line | Data |
---|---|---|
84fb5b46 MKG |
1 | # BEGIN BPS TAGGED BLOCK {{{ |
2 | # | |
3 | # COPYRIGHT: | |
4 | # | |
403d7b0b | 5 | # This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC |
84fb5b46 MKG |
6 | # <sales@bestpractical.com> |
7 | # | |
8 | # (Except where explicitly superseded by other copyright notices) | |
9 | # | |
10 | # | |
11 | # LICENSE: | |
12 | # | |
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 | |
16 | # from www.gnu.org. | |
17 | # | |
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. | |
22 | # | |
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. | |
28 | # | |
29 | # | |
30 | # CONTRIBUTION SUBMISSION POLICY: | |
31 | # | |
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.) | |
37 | # | |
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. | |
46 | # | |
47 | # END BPS TAGGED BLOCK }}} | |
48 | ||
49 | =head1 NAME | |
50 | ||
51 | RT::ScripCondition - RT scrip conditional | |
52 | ||
53 | =head1 SYNOPSIS | |
54 | ||
55 | use RT::ScripCondition; | |
56 | ||
57 | ||
58 | =head1 DESCRIPTION | |
59 | ||
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. | |
62 | ||
63 | ||
64 | ||
65 | =head1 METHODS | |
66 | ||
67 | =cut | |
68 | ||
69 | ||
70 | package RT::ScripCondition; | |
71 | ||
72 | use strict; | |
73 | use warnings; | |
74 | ||
75 | ||
76 | use base 'RT::Record'; | |
77 | ||
78 | sub Table {'ScripConditions'} | |
79 | ||
80 | ||
84fb5b46 MKG |
81 | sub _Accessible { |
82 | my $self = shift; | |
83 | my %Cols = ( Name => 'read', | |
af59614d MKG |
84 | Description => 'read', |
85 | ApplicableTransTypes => 'read', | |
86 | ExecModule => 'read', | |
87 | Argument => 'read', | |
88 | Creator => 'read/auto', | |
89 | Created => 'read/auto', | |
90 | LastUpdatedBy => 'read/auto', | |
91 | LastUpdated => 'read/auto' | |
92 | ); | |
84fb5b46 MKG |
93 | return($self->SUPER::_Accessible(@_, %Cols)); |
94 | } | |
95 | ||
96 | ||
97 | =head2 Create | |
98 | ||
99 | Takes a hash. Creates a new Condition entry. | |
100 | should be better documented. | |
101 | ||
102 | =cut | |
103 | ||
104 | sub Create { | |
105 | my $self = shift; | |
106 | return($self->SUPER::Create(@_)); | |
107 | } | |
108 | ||
109 | ||
110 | =head2 Delete | |
111 | ||
112 | No API available for deleting things just yet. | |
113 | ||
114 | =cut | |
115 | ||
116 | sub Delete { | |
117 | my $self = shift; | |
118 | return(0, $self->loc('Unimplemented')); | |
119 | } | |
120 | ||
121 | ||
122 | =head2 Load IDENTIFIER | |
123 | ||
124 | Loads a condition takes a name or ScripCondition id. | |
125 | ||
126 | =cut | |
127 | ||
128 | sub Load { | |
129 | my $self = shift; | |
130 | my $identifier = shift; | |
af59614d | 131 | |
84fb5b46 | 132 | unless (defined $identifier) { |
af59614d MKG |
133 | return (undef); |
134 | } | |
135 | ||
84fb5b46 | 136 | if ($identifier !~ /\D/) { |
af59614d | 137 | return ($self->SUPER::LoadById($identifier)); |
84fb5b46 MKG |
138 | } |
139 | else { | |
af59614d | 140 | return ($self->LoadByCol('Name', $identifier)); |
84fb5b46 MKG |
141 | } |
142 | } | |
143 | ||
144 | ||
145 | =head2 LoadCondition HASH | |
146 | ||
147 | takes a hash which has the following elements: TransactionObj and TicketObj. | |
148 | Loads the Condition module in question. | |
149 | ||
150 | =cut | |
151 | ||
152 | ||
153 | sub LoadCondition { | |
154 | my $self = shift; | |
155 | my %args = ( TransactionObj => undef, | |
af59614d MKG |
156 | TicketObj => undef, |
157 | @_ ); | |
158 | ||
159 | #TODO: Put this in an eval | |
84fb5b46 MKG |
160 | $self->ExecModule =~ /^(\w+)$/; |
161 | my $module = $1; | |
162 | my $type = "RT::Condition::". $module; | |
af59614d | 163 | |
84fb5b46 | 164 | eval "require $type" || die "Require of $type failed.\n$@\n"; |
af59614d MKG |
165 | |
166 | $self->{'Condition'} = $type->new ( 'ScripConditionObj' => $self, | |
167 | 'TicketObj' => $args{'TicketObj'}, | |
168 | 'ScripObj' => $args{'ScripObj'}, | |
169 | 'TransactionObj' => $args{'TransactionObj'}, | |
170 | 'Argument' => $self->Argument, | |
171 | 'ApplicableTransTypes' => $self->ApplicableTransTypes, | |
172 | CurrentUser => $self->CurrentUser | |
173 | ); | |
84fb5b46 MKG |
174 | } |
175 | ||
176 | ||
177 | ||
178 | ||
179 | =head2 Describe | |
180 | ||
403d7b0b | 181 | Helper method to call the condition module's Describe method. |
84fb5b46 MKG |
182 | |
183 | =cut | |
184 | ||
185 | sub Describe { | |
186 | my $self = shift; | |
187 | return ($self->{'Condition'}->Describe()); | |
188 | ||
189 | } | |
190 | ||
191 | ||
192 | =head2 IsApplicable | |
193 | ||
403d7b0b | 194 | Helper method to call the condition module's IsApplicable method. |
84fb5b46 MKG |
195 | |
196 | =cut | |
197 | ||
198 | sub IsApplicable { | |
199 | my $self = shift; | |
200 | return ($self->{'Condition'}->IsApplicable()); | |
201 | ||
202 | } | |
203 | ||
204 | ||
84fb5b46 MKG |
205 | |
206 | =head2 id | |
207 | ||
208 | Returns the current value of id. | |
209 | (In the database, id is stored as int(11).) | |
210 | ||
211 | ||
212 | =cut | |
213 | ||
214 | ||
215 | =head2 Name | |
216 | ||
217 | Returns the current value of Name. | |
218 | (In the database, Name is stored as varchar(200).) | |
219 | ||
220 | ||
221 | ||
222 | =head2 SetName VALUE | |
223 | ||
224 | ||
225 | Set Name to VALUE. | |
226 | Returns (1, 'Status message') on success and (0, 'Error Message') on failure. | |
227 | (In the database, Name will be stored as a varchar(200).) | |
228 | ||
229 | ||
230 | =cut | |
231 | ||
232 | ||
233 | =head2 Description | |
234 | ||
235 | Returns the current value of Description. | |
236 | (In the database, Description is stored as varchar(255).) | |
237 | ||
238 | ||
239 | ||
240 | =head2 SetDescription VALUE | |
241 | ||
242 | ||
243 | Set Description to VALUE. | |
244 | Returns (1, 'Status message') on success and (0, 'Error Message') on failure. | |
245 | (In the database, Description will be stored as a varchar(255).) | |
246 | ||
247 | ||
248 | =cut | |
249 | ||
250 | ||
251 | =head2 ExecModule | |
252 | ||
253 | Returns the current value of ExecModule. | |
254 | (In the database, ExecModule is stored as varchar(60).) | |
255 | ||
256 | ||
257 | ||
258 | =head2 SetExecModule VALUE | |
259 | ||
260 | ||
261 | Set ExecModule to VALUE. | |
262 | Returns (1, 'Status message') on success and (0, 'Error Message') on failure. | |
263 | (In the database, ExecModule will be stored as a varchar(60).) | |
264 | ||
265 | ||
266 | =cut | |
267 | ||
268 | ||
269 | =head2 Argument | |
270 | ||
271 | Returns the current value of Argument. | |
272 | (In the database, Argument is stored as varbinary(255).) | |
273 | ||
274 | ||
275 | ||
276 | =head2 SetArgument VALUE | |
277 | ||
278 | ||
279 | Set Argument to VALUE. | |
280 | Returns (1, 'Status message') on success and (0, 'Error Message') on failure. | |
281 | (In the database, Argument will be stored as a varbinary(255).) | |
282 | ||
283 | ||
284 | =cut | |
285 | ||
286 | ||
287 | =head2 ApplicableTransTypes | |
288 | ||
289 | Returns the current value of ApplicableTransTypes. | |
290 | (In the database, ApplicableTransTypes is stored as varchar(60).) | |
291 | ||
292 | ||
293 | ||
294 | =head2 SetApplicableTransTypes VALUE | |
295 | ||
296 | ||
297 | Set ApplicableTransTypes to VALUE. | |
298 | Returns (1, 'Status message') on success and (0, 'Error Message') on failure. | |
299 | (In the database, ApplicableTransTypes will be stored as a varchar(60).) | |
300 | ||
301 | ||
302 | =cut | |
303 | ||
304 | ||
305 | =head2 Creator | |
306 | ||
307 | Returns the current value of Creator. | |
308 | (In the database, Creator is stored as int(11).) | |
309 | ||
310 | ||
311 | =cut | |
312 | ||
313 | ||
314 | =head2 Created | |
315 | ||
316 | Returns the current value of Created. | |
317 | (In the database, Created is stored as datetime.) | |
318 | ||
319 | ||
320 | =cut | |
321 | ||
322 | ||
323 | =head2 LastUpdatedBy | |
324 | ||
325 | Returns the current value of LastUpdatedBy. | |
326 | (In the database, LastUpdatedBy is stored as int(11).) | |
327 | ||
328 | ||
329 | =cut | |
330 | ||
331 | ||
332 | =head2 LastUpdated | |
333 | ||
334 | Returns the current value of LastUpdated. | |
335 | (In the database, LastUpdated is stored as datetime.) | |
336 | ||
337 | ||
338 | =cut | |
339 | ||
340 | ||
341 | ||
342 | sub _CoreAccessible { | |
343 | { | |
344 | ||
345 | id => | |
af59614d | 346 | {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''}, |
84fb5b46 | 347 | Name => |
af59614d | 348 | {read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => ''}, |
84fb5b46 | 349 | Description => |
af59614d | 350 | {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''}, |
84fb5b46 | 351 | ExecModule => |
af59614d | 352 | {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''}, |
84fb5b46 | 353 | Argument => |
af59614d | 354 | {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varbinary(255)', default => ''}, |
84fb5b46 | 355 | ApplicableTransTypes => |
af59614d | 356 | {read => 1, write => 1, sql_type => 12, length => 60, is_blob => 0, is_numeric => 0, type => 'varchar(60)', default => ''}, |
84fb5b46 | 357 | Creator => |
af59614d | 358 | {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'}, |
84fb5b46 | 359 | Created => |
af59614d | 360 | {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''}, |
84fb5b46 | 361 | LastUpdatedBy => |
af59614d | 362 | {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'}, |
84fb5b46 | 363 | LastUpdated => |
af59614d | 364 | {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''}, |
84fb5b46 MKG |
365 | |
366 | } | |
367 | }; | |
368 | ||
af59614d MKG |
369 | sub PreInflate { |
370 | my $class = shift; | |
371 | my ($importer, $uid, $data) = @_; | |
372 | ||
373 | $class->SUPER::PreInflate( $importer, $uid, $data ); | |
374 | ||
375 | return not $importer->SkipBy( "Name", $class, $uid, $data ); | |
376 | } | |
377 | ||
84fb5b46 MKG |
378 | RT::Base->_ImportOverlays(); |
379 | ||
380 | 1; |