Lines 276-284
sub create {
Link Here
|
276 |
} |
276 |
} |
277 |
|
277 |
|
278 |
# Received completed details of form. Validate and create request. |
278 |
# Received completed details of form. Validate and create request. |
279 |
## Validate |
|
|
280 |
my ( $brw_count, $brw ) = |
281 |
_validate_borrower( $other->{'cardnumber'} ); |
282 |
my $result = { |
279 |
my $result = { |
283 |
cwd => dirname(__FILE__), |
280 |
cwd => dirname(__FILE__), |
284 |
status => "", |
281 |
status => "", |
Lines 290-320
sub create {
Link Here
|
290 |
core => $core_fields |
287 |
core => $core_fields |
291 |
}; |
288 |
}; |
292 |
my $failed = 0; |
289 |
my $failed = 0; |
293 |
if ( !$other->{'type'} ) { |
290 |
|
294 |
$result->{status} = "missing_type"; |
291 |
my $unauthenticated_request = |
295 |
$result->{value} = $params; |
292 |
C4::Context->preference("ILLOpacUnauthenticatedRequest") && !$other->{'cardnumber'}; |
296 |
$failed = 1; |
293 |
if($unauthenticated_request){ |
297 |
} elsif ( !$other->{'branchcode'} ) { |
294 |
( $failed, $result ) = _validate_form_params( $other, $result, $params); |
298 |
$result->{status} = "missing_branch"; |
295 |
if ( !_unauth_request_data_check($other) ) { |
299 |
$result->{value} = $params; |
296 |
$result->{status} = "missing_unauth_data"; |
300 |
$failed = 1; |
297 |
$result->{value} = $params; |
301 |
} elsif ( !Koha::Libraries->find( $other->{'branchcode'} ) ) { |
298 |
$failed = 1; |
302 |
$result->{status} = "invalid_branch"; |
299 |
} |
303 |
$result->{value} = $params; |
300 |
}else{ |
304 |
$failed = 1; |
301 |
( $failed, $result ) = _validate_form_params( $other, $result, $params ); |
305 |
} elsif ( $brw_count == 0 ) { |
302 |
|
306 |
$result->{status} = "invalid_borrower"; |
303 |
my ( $brw_count, $brw ) = |
307 |
$result->{value} = $params; |
304 |
_validate_borrower( $other->{'cardnumber'} ); |
308 |
$failed = 1; |
305 |
|
309 |
} elsif ( $brw_count > 1 ) { |
306 |
if ( $brw_count == 0 ) { |
310 |
|
307 |
$result->{status} = "invalid_borrower"; |
311 |
# We must select a specific borrower out of our options. |
308 |
$result->{value} = $params; |
312 |
$params->{brw} = $brw; |
309 |
$failed = 1; |
313 |
$result->{value} = $params; |
310 |
} elsif ( $brw_count > 1 ) { |
314 |
$result->{stage} = "borrowers"; |
311 |
# We must select a specific borrower out of our options. |
315 |
$result->{error} = 0; |
312 |
$params->{brw} = $brw; |
316 |
$failed = 1; |
313 |
$result->{value} = $params; |
|
|
314 |
$result->{stage} = "borrowers"; |
315 |
$result->{error} = 0; |
316 |
$failed = 1; |
317 |
} |
317 |
} |
318 |
} |
|
|
319 |
|
318 |
return $result if $failed; |
320 |
return $result if $failed; |
319 |
|
321 |
|
320 |
$self->add_request( { request => $params->{request}, other => $other } ); |
322 |
$self->add_request( { request => $params->{request}, other => $other } ); |
Lines 1224-1229
sub _set_suppression {
Link Here
|
1224 |
return 1; |
1226 |
return 1; |
1225 |
} |
1227 |
} |
1226 |
|
1228 |
|
|
|
1229 |
=head3 _unauth_request_data_check |
1230 |
|
1231 |
_unauth_request_data_check($other); |
1232 |
|
1233 |
Checks if unauthenticated request data is present |
1234 |
|
1235 |
=cut |
1236 |
|
1237 |
sub _unauth_request_data_check { |
1238 |
my ($other) = @_; |
1239 |
|
1240 |
return 1 unless C4::Context->preference("ILLOpacUnauthenticatedRequest"); |
1241 |
|
1242 |
return |
1243 |
$other->{unauthenticated_first_name} |
1244 |
&& $other->{unauthenticated_last_name} |
1245 |
&& $other->{unauthenticated_email}; |
1246 |
} |
1247 |
|
1248 |
=head3 _validate_form_params |
1249 |
|
1250 |
_validate_form_params( $other, $result, $params ); |
1251 |
|
1252 |
Validate form parameters and return the validation result |
1253 |
|
1254 |
=cut |
1255 |
|
1256 |
sub _validate_form_params { |
1257 |
my ( $other, $result, $params ) = @_; |
1258 |
|
1259 |
my $failed = 0; |
1260 |
if ( !$other->{'type'} ) { |
1261 |
$result->{status} = "missing_type"; |
1262 |
$result->{value} = $params; |
1263 |
$failed = 1; |
1264 |
} elsif ( !$other->{'branchcode'} ) { |
1265 |
$result->{status} = "missing_branch"; |
1266 |
$result->{value} = $params; |
1267 |
$failed = 1; |
1268 |
} elsif ( !Koha::Libraries->find( $other->{'branchcode'} ) ) { |
1269 |
$result->{status} = "invalid_branch"; |
1270 |
$result->{value} = $params; |
1271 |
$failed = 1; |
1272 |
} |
1273 |
|
1274 |
return ( $failed, $result ); |
1275 |
} |
1276 |
|
1227 |
=head1 AUTHORS |
1277 |
=head1 AUTHORS |
1228 |
|
1278 |
|
1229 |
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com> |
1279 |
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com> |