line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gantry::Plugins::AutoCRUD; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
55701
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
59
|
|
4
|
2
|
|
|
2
|
|
1003
|
use Data::FormValidator; |
|
2
|
|
|
|
|
31556
|
|
|
2
|
|
|
|
|
87
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
|
|
135
|
use Gantry::Utils::CRUDHelp qw( |
7
|
|
|
|
|
|
|
clean_params |
8
|
|
|
|
|
|
|
form_profile |
9
|
|
|
|
|
|
|
write_file |
10
|
|
|
|
|
|
|
verify_permission |
11
|
2
|
|
|
2
|
|
520
|
); |
|
2
|
|
|
|
|
4
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
11
|
use Exporter; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
14
|
2
|
|
|
2
|
|
9
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
3506
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
############################################################ |
17
|
|
|
|
|
|
|
# Variables # |
18
|
|
|
|
|
|
|
############################################################ |
19
|
|
|
|
|
|
|
our @ISA = qw( Exporter ); |
20
|
|
|
|
|
|
|
our @EXPORT = qw( |
21
|
|
|
|
|
|
|
do_add |
22
|
|
|
|
|
|
|
do_edit |
23
|
|
|
|
|
|
|
do_delete |
24
|
|
|
|
|
|
|
form_name |
25
|
|
|
|
|
|
|
write_file |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $orm_helper; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
############################################################ |
31
|
|
|
|
|
|
|
# Functions # |
32
|
|
|
|
|
|
|
############################################################ |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
0
|
1
|
|
sub form_name { return 'form.tt'; } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# not exported |
37
|
|
|
|
|
|
|
sub get_cancel_loc { |
38
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
39
|
0
|
0
|
|
|
|
|
return( $self->location . ( $self->{__PID__} ? "/main/$$self{__PID__}" : '' ) ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# not exported |
43
|
|
|
|
|
|
|
sub get_submit_loc { |
44
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
my $action = shift; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if ( $action eq 'add_another' ) { |
48
|
|
|
|
|
|
|
return ( |
49
|
0
|
0
|
|
|
|
|
$self->location . "/add" |
50
|
|
|
|
|
|
|
. ( $self->{__PID__} ? "/$$self{__PID__}" : '' ) |
51
|
|
|
|
|
|
|
) |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return( |
55
|
0
|
0
|
|
|
|
|
$self->location |
56
|
|
|
|
|
|
|
. ( $self->{__PID__} ? "/main/$$self{__PID__}" : '' ) |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#------------------------------------------------- |
61
|
|
|
|
|
|
|
# $self->do_add( ) |
62
|
|
|
|
|
|
|
#------------------------------------------------- |
63
|
|
|
|
|
|
|
sub do_add { |
64
|
0
|
|
|
0
|
1
|
|
my ( $self, $pid ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self->{__PID__} = $pid; |
67
|
0
|
|
|
|
|
|
$self->stash->view->template( $self->form_name( 'add' ) ); |
68
|
0
|
|
|
|
|
|
$self->stash->view->title( 'Add ' . $self->text_descr( 'add' ) ); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $params = $self->get_param_hash(); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Redirect if user pressed 'Cancel' |
73
|
0
|
0
|
|
|
|
|
if ( $params->{cancel} ) { |
74
|
0
|
|
|
|
|
|
return $self->relocate( find_cancel_loc( $self, 'add' ) ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# get and hold the form description |
78
|
0
|
|
|
|
|
|
my $form; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
eval { |
81
|
0
|
|
|
|
|
|
$form = $self->form(); |
82
|
|
|
|
|
|
|
}; |
83
|
0
|
|
|
|
|
|
my $full_error = $@; |
84
|
0
|
0
|
|
|
|
|
unless ( $form ) { |
85
|
0
|
|
|
|
|
|
eval { |
86
|
0
|
|
|
|
|
|
$form = $self->_form(); |
87
|
|
|
|
|
|
|
}; |
88
|
0
|
|
|
|
|
|
$full_error .= $@; |
89
|
|
|
|
|
|
|
} |
90
|
0
|
0
|
|
|
|
|
croak ( 'No form or _form method defined for AutoCRUD do_add ' . |
91
|
|
|
|
|
|
|
"[ invocant: $self errors: $full_error ]" ) |
92
|
|
|
|
|
|
|
unless ( $form ); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Check form data |
95
|
0
|
|
|
|
|
|
my $show_form = 0; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# If there are no form parameters, show the form (all the fields might |
98
|
|
|
|
|
|
|
# be optional). |
99
|
0
|
0
|
|
|
|
|
$show_form = 1 if ( keys %{ $params } == 0 ); |
|
0
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my $results = Data::FormValidator->check( |
102
|
|
|
|
|
|
|
$params, |
103
|
|
|
|
|
|
|
form_profile( $form->{fields} ), |
104
|
|
|
|
|
|
|
); |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
$show_form = 1 if ( not $self->is_post ); |
107
|
0
|
0
|
|
|
|
|
$show_form = 1 if ( $results->has_invalid ); |
108
|
0
|
0
|
|
|
|
|
$show_form = 1 if ( $results->has_missing ); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# do row auth check to see if they are allowed to add |
111
|
0
|
|
|
|
|
|
my $permissions = $self->controller_config->{ permissions }; |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
if ( defined $permissions ) { |
114
|
0
|
|
|
|
|
|
verify_permission( |
115
|
|
|
|
|
|
|
{ |
116
|
|
|
|
|
|
|
site => $self, |
117
|
|
|
|
|
|
|
permissions => $permissions, |
118
|
|
|
|
|
|
|
params => $params, |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
|
if ( $show_form ) { |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# order is important, first put in the form... |
126
|
0
|
|
|
|
|
|
$self->stash->view->form( $form ); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# ... then add error results |
129
|
0
|
0
|
|
|
|
|
if ( $self->method eq 'POST' ) { |
130
|
0
|
|
|
|
|
|
$self->stash->view->form->results( $results ); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
else { |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# remove submit buttons entries |
136
|
0
|
|
|
|
|
|
my $submit_add_another = delete $params->{submit_add_another}; |
137
|
0
|
|
|
|
|
|
delete $params->{submit}; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
clean_params( $params, $form->{fields} ); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# let subclass massage the params, but only if it wants to |
142
|
0
|
0
|
|
|
|
|
if ( $self->can( 'add_pre_action' ) ) { |
143
|
0
|
|
|
|
|
|
$self->add_pre_action( $params ); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# update the database |
147
|
0
|
|
0
|
|
|
|
$orm_helper ||= find_orm_helper( $self ); |
148
|
0
|
|
|
|
|
|
my $new_row = $orm_helper->insert( $self, $params ); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# let the subclass do post add actions |
151
|
0
|
0
|
|
|
|
|
if ( $self->can( 'add_post_action' ) ) { |
152
|
0
|
|
|
|
|
|
$self->add_post_action( $new_row ); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# move along, we're all done here |
156
|
0
|
|
|
|
|
|
my $redirect; |
157
|
0
|
0
|
|
|
|
|
if ( $submit_add_another ) { |
158
|
0
|
|
|
|
|
|
$redirect = find_submit_loc( $self, 'add_another' ); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
else { |
161
|
0
|
|
|
|
|
|
$redirect = find_submit_loc( $self, 'add' ) |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
return $self->relocate( $redirect ); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
} # END: do_add |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
#------------------------------------------------- |
169
|
|
|
|
|
|
|
# $self->do_edit( $id ) |
170
|
|
|
|
|
|
|
#------------------------------------------------- |
171
|
|
|
|
|
|
|
sub do_edit { |
172
|
0
|
|
|
0
|
1
|
|
my ( $self, $id, $pid ) = @_; |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
$self->{__PID__} = $pid; |
175
|
0
|
|
|
|
|
|
$self->stash->view->template( $self->form_name( 'edit' ) ); |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
my %params = $self->get_param_hash(); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# Redirect if 'Cancel' |
180
|
0
|
0
|
|
|
|
|
if ( $params{cancel} ) { |
181
|
0
|
|
|
|
|
|
return $self->relocate( find_cancel_loc( $self, 'edit' ) ); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
0
|
|
|
|
$orm_helper ||= find_orm_helper( $self ); |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# Load data from database |
187
|
0
|
|
|
|
|
|
my $row = $orm_helper->retrieve( $self, $id ); |
188
|
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
|
$self->stash->view->title( 'Edit ' . $self->text_descr( 'edit', $row ) ); |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
my $show_form = 0; |
192
|
|
|
|
|
|
|
|
193
|
0
|
0
|
|
|
|
|
$show_form = 1 if ( not $self->is_post ); |
194
|
0
|
0
|
|
|
|
|
$show_form = 1 if ( keys %params == 0 ); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# get and hold the form description |
197
|
0
|
|
|
|
|
|
my $form; |
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
eval { |
200
|
0
|
|
|
|
|
|
$form = $self->form( $row ); |
201
|
|
|
|
|
|
|
}; |
202
|
0
|
|
|
|
|
|
my $full_error = $@; |
203
|
0
|
0
|
|
|
|
|
unless ( $form ) { |
204
|
0
|
|
|
|
|
|
eval { |
205
|
0
|
|
|
|
|
|
$form = $self->_form( $row ); |
206
|
|
|
|
|
|
|
}; |
207
|
0
|
|
|
|
|
|
$full_error .= $@; |
208
|
|
|
|
|
|
|
} |
209
|
0
|
0
|
|
|
|
|
croak ( 'No form or _form method defined for AutoCRUD do_edit ' . |
210
|
|
|
|
|
|
|
"[ invocant: $self errors: $full_error ]" ) |
211
|
|
|
|
|
|
|
unless ( $form ); |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# Check form data |
214
|
0
|
|
|
|
|
|
my $results = Data::FormValidator->check( |
215
|
|
|
|
|
|
|
\%params, |
216
|
|
|
|
|
|
|
form_profile( $form->{fields} ), |
217
|
|
|
|
|
|
|
); |
218
|
|
|
|
|
|
|
|
219
|
0
|
0
|
|
|
|
|
$show_form = 1 if ( $results->has_invalid ); |
220
|
0
|
0
|
|
|
|
|
$show_form = 1 if ( $results->has_missing ); |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# do row auth check to see if they are allowed to add |
223
|
0
|
|
|
|
|
|
my $permissions = $self->controller_config->{ permissions }; |
224
|
|
|
|
|
|
|
|
225
|
0
|
0
|
|
|
|
|
if ( defined $permissions ) { |
226
|
0
|
|
|
|
|
|
verify_permission( |
227
|
|
|
|
|
|
|
{ |
228
|
|
|
|
|
|
|
site => $self, |
229
|
|
|
|
|
|
|
permissions => $permissions, |
230
|
|
|
|
|
|
|
params => \%params, |
231
|
|
|
|
|
|
|
row => $row, |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
); |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
# Form has errors |
237
|
0
|
0
|
|
|
|
|
if ( $show_form ) { |
238
|
|
|
|
|
|
|
# order matters, get form data first... |
239
|
0
|
|
|
|
|
|
$self->stash->view->form( $form ); |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# ... then overlay with results |
242
|
0
|
0
|
|
|
|
|
if ( $self->method eq 'POST' ) { |
243
|
0
|
|
|
|
|
|
$self->stash->view->form->results( $results ); |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
# Form looks good, make update |
247
|
|
|
|
|
|
|
else { |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
# remove submit button param |
250
|
0
|
|
|
|
|
|
my $submit_add_another = delete $params{submit_add_another}; |
251
|
0
|
|
|
|
|
|
delete $params{submit}; |
252
|
|
|
|
|
|
|
|
253
|
0
|
|
|
|
|
|
clean_params( \%params, $form->{fields} ); |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# allow child module to make changes |
256
|
0
|
0
|
|
|
|
|
if ( $self->can( 'edit_pre_action' ) ) { |
257
|
0
|
|
|
|
|
|
$self->edit_pre_action( $row, \%params ); |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
# make the update |
261
|
0
|
|
|
|
|
|
$orm_helper->update( $self, $row, \%params ); |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
# allow child to do post update actions |
264
|
0
|
0
|
|
|
|
|
if ( $self->can( 'edit_post_action' ) ) { |
265
|
0
|
|
|
|
|
|
$self->edit_post_action( $row ); |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
# all done, move along |
269
|
0
|
|
|
|
|
|
my $redirect; |
270
|
0
|
0
|
|
|
|
|
if ( $submit_add_another ) { |
271
|
0
|
|
|
|
|
|
$redirect = find_submit_loc( $self, 'add_another' ) |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
else { |
274
|
0
|
|
|
|
|
|
$redirect = find_submit_loc( $self, 'edit' ); |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
|
277
|
0
|
|
|
|
|
|
return $self->relocate( $redirect ); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
} # END: do_edit |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
#------------------------------------------------- |
282
|
|
|
|
|
|
|
# $self->do_delete( $id, $yes ) |
283
|
|
|
|
|
|
|
#------------------------------------------------- |
284
|
|
|
|
|
|
|
sub do_delete { |
285
|
0
|
|
|
0
|
1
|
|
my ( $self, $id, $pid, $yes ) = @_; |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
# look for a parent id and set the proper variables |
288
|
0
|
0
|
|
|
|
|
if ( $pid =~ /yes|no/ ) { |
289
|
0
|
|
|
|
|
|
$yes = $pid; |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
else { |
292
|
0
|
|
|
|
|
|
$self->{__PID__} = $pid; |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
|
295
|
0
|
|
|
|
|
|
$self->stash->view->template( 'delete.tt' ); |
296
|
0
|
|
|
|
|
|
$self->stash->view->title( 'Delete' ); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
# go back if user cancelled |
299
|
0
|
0
|
|
|
|
|
if ( $self->params->{cancel} ) { |
300
|
0
|
|
|
|
|
|
return $self->relocate( find_cancel_loc( $self, 'delete' ) ); |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
|
303
|
0
|
|
0
|
|
|
|
$orm_helper ||= find_orm_helper( $self ); |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
# Get the doomed row |
306
|
0
|
|
|
|
|
|
my $row = $orm_helper->retrieve( $self, $id ); |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
# do row auth check to see if they are allowed to add |
309
|
0
|
|
|
|
|
|
my $permissions = $self->controller_config->{ permissions }; |
310
|
|
|
|
|
|
|
|
311
|
0
|
0
|
|
|
|
|
if ( defined $permissions ) { |
312
|
0
|
|
|
|
|
|
verify_permission( |
313
|
|
|
|
|
|
|
{ |
314
|
|
|
|
|
|
|
site => $self, |
315
|
|
|
|
|
|
|
permissions => $permissions, |
316
|
|
|
|
|
|
|
row => $row, |
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
); |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
0
|
0
|
0
|
|
|
|
if ( ( defined $yes ) and ( $yes eq 'yes' ) ) { |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
# allow subclasses to do things before the delete |
324
|
0
|
0
|
|
|
|
|
if ( $self->can( 'delete_pre_action' ) ) { |
325
|
0
|
|
|
|
|
|
$self->delete_pre_action( $row ); |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
# dum dum da dum... |
329
|
0
|
|
|
|
|
|
$orm_helper->delete( $self, $row ); |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
# allow subclasses to do things after the delete |
332
|
0
|
0
|
|
|
|
|
if ( $self->can( 'delete_post_action' ) ) { |
333
|
0
|
|
|
|
|
|
$self->delete_post_action( $id ); |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
# Move along, it's already dead |
337
|
0
|
|
|
|
|
|
return $self->relocate( find_submit_loc( $self, 'delete' ) ); |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
else { |
340
|
0
|
|
|
|
|
|
$self->stash->view->form->message ( |
341
|
|
|
|
|
|
|
'Delete ' . $self->text_descr( 'delete', $row ) . '?' |
342
|
|
|
|
|
|
|
); |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
#------------------------------------------------- |
347
|
|
|
|
|
|
|
# The following routines look for user supplied |
348
|
|
|
|
|
|
|
# methods, but provide fallbacks if the user didn't |
349
|
|
|
|
|
|
|
# give any. |
350
|
|
|
|
|
|
|
#------------------------------------------------- |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
sub find_orm_helper { |
353
|
0
|
|
|
0
|
1
|
|
my ( $gantry_site ) = @_; |
354
|
|
|
|
|
|
|
|
355
|
0
|
0
|
|
|
|
|
if ( $gantry_site->can( 'get_orm_helper' ) ) { |
356
|
0
|
|
|
|
|
|
$orm_helper = $gantry_site->get_orm_helper; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
else { |
359
|
0
|
|
|
|
|
|
$orm_helper = 'Gantry::Plugins::AutoCRUDHelper::CDBI'; |
360
|
|
|
|
|
|
|
} |
361
|
|
|
|
|
|
|
|
362
|
0
|
|
|
|
|
|
my $orm_helper_file = $orm_helper; |
363
|
|
|
|
|
|
|
|
364
|
0
|
|
|
|
|
|
$orm_helper_file =~ s{::}{/}g; |
365
|
0
|
|
|
|
|
|
$orm_helper_file .= '.pm'; |
366
|
|
|
|
|
|
|
|
367
|
0
|
|
|
|
|
|
require $orm_helper_file; |
368
|
|
|
|
|
|
|
|
369
|
0
|
|
|
|
|
|
return $orm_helper; |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
sub find_submit_loc { |
373
|
0
|
|
|
0
|
1
|
|
my ( $self, $action ) = @_; |
374
|
|
|
|
|
|
|
|
375
|
0
|
|
|
|
|
|
my $submit_loc; |
376
|
|
|
|
|
|
|
|
377
|
0
|
0
|
|
|
|
|
if ( $self->can( 'get_relocation' ) ) { |
378
|
0
|
|
|
|
|
|
$submit_loc = $self->get_relocation( $action, 'submit' ); |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
else { |
381
|
|
|
|
|
|
|
# see if caller has submit loc sub... |
382
|
0
|
0
|
|
|
|
|
if ( $self->can( 'get_submit_loc' ) ) { |
383
|
0
|
|
|
|
|
|
$submit_loc = $self->get_submit_loc( $action, 'submit' ); |
384
|
|
|
|
|
|
|
} |
385
|
|
|
|
|
|
|
# ...or use ours |
386
|
|
|
|
|
|
|
else { |
387
|
0
|
|
|
|
|
|
$submit_loc = get_submit_loc( $self, $action ); |
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
} |
390
|
|
|
|
|
|
|
|
391
|
0
|
|
|
|
|
|
return $submit_loc; |
392
|
|
|
|
|
|
|
} |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
sub find_cancel_loc { |
395
|
0
|
|
|
0
|
1
|
|
my ( $self, $action ) = @_; |
396
|
|
|
|
|
|
|
|
397
|
0
|
|
|
|
|
|
my $cancel_loc; |
398
|
|
|
|
|
|
|
|
399
|
0
|
0
|
|
|
|
|
if ( $self->can( 'get_relocation' ) ) { |
400
|
0
|
|
|
|
|
|
$cancel_loc = $self->get_relocation( $action, 'cancel' ); |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
else { |
403
|
|
|
|
|
|
|
# see if caller has cancel loc sub... |
404
|
0
|
0
|
|
|
|
|
if ( $self->can( 'get_cancel_loc' ) ) { |
405
|
0
|
|
|
|
|
|
$cancel_loc = $self->get_cancel_loc( $action, 'cancel' ); |
406
|
|
|
|
|
|
|
} |
407
|
|
|
|
|
|
|
# ...or use ours |
408
|
|
|
|
|
|
|
else { |
409
|
0
|
|
|
|
|
|
$cancel_loc = get_cancel_loc( $self ); |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
|
413
|
0
|
|
|
|
|
|
return $cancel_loc; |
414
|
|
|
|
|
|
|
} |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
1; |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
__END__ |