Bugzilla – Attachment 69000 Details for
Bug 7317
Add an Interlibrary Loan Module to Circulation and OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7317: Handle missing email addresses gracefuly
Bug-7317-Handle-missing-email-addresses-gracefuly.patch (text/plain), 6.30 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-11-07 15:06:15 UTC
(
hide
)
Description:
Bug 7317: Handle missing email addresses gracefuly
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-11-07 15:06:15 UTC
Size:
6.30 KB
patch
obsolete
>From 58081e0d123d6be7fca91513c08454fb49548fb9 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 7 Nov 2017 12:05:04 -0300 >Subject: [PATCH] Bug 7317: Handle missing email addresses gracefuly > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Exceptions/Ill.pm | 16 ++++++++ > Koha/Illrequest.pm | 10 +++-- > ill/ill-requests.pl | 43 +++++++++++++++++----- > .../prog/en/modules/ill/ill-requests.tt | 12 ++++++ > 4 files changed, 68 insertions(+), 13 deletions(-) > >diff --git a/Koha/Exceptions/Ill.pm b/Koha/Exceptions/Ill.pm >index 9e1376109b..2084ed06e5 100644 >--- a/Koha/Exceptions/Ill.pm >+++ b/Koha/Exceptions/Ill.pm >@@ -25,6 +25,14 @@ use Exception::Class ( > 'Koha::Exceptions::Ill::InvalidBackendId' => { > isa => 'Koha::Exceptions::Ill', > description => "Invalid backend name required", >+ }, >+ 'Koha::Exceptions::Ill::NoTargetEmail' => { >+ isa => 'Koha::Exceptions::Ill', >+ description => "ILL partner library has no email address configured", >+ }, >+ 'Koha::Exceptions::Ill::NoLibraryEmail' => { >+ isa => 'Koha::Exceptions::Ill', >+ description => "Invalid backend name required", > } > ); > >@@ -42,6 +50,14 @@ Generic Ill exception > > Exception to be used when the required ILL backend is invalid. > >+=head2 Koha::Exceptions::Ill::NoTargetEmail >+ >+Exception to be used when the ILL partner has no email address set. >+ >+=head2 Koha::Exceptions::Ill::NoLibraryEmail >+ >+Exception to be used when the current library has no email address set. >+ > =cut > > 1; >diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm >index db5b9a9fe7..53e9ddc0fe 100644 >--- a/Koha/Illrequest.pm >+++ b/Koha/Illrequest.pm >@@ -892,12 +892,16 @@ EOF > $to =~ s/^\x00//; # Strip leading NULLs > $to =~ s/\x00/; /; # Replace others with '; ' > } >- die "No target email addresses found. Either select at least one partner or check your ILL partner library records." if ( !$to ); >+ Koha::Exceptions::Ill::NoTargetEmail->throw( >+ "No target email addresses found. Either select at least one partner or check your ILL partner library records.") >+ if ( !$to ); > # Create the from, replyto and sender headers > my $from = $branch->branchemail; > my $replyto = $branch->branchreplyto || $from; >- die "Your branch has no email address. Please set it." >- if ( !$from ); >+ Koha::Exceptions::Ill::NoLibraryEmail->throw( >+ "Your library has no usable email address. Please set it.") >+ if ( !$from ); >+ > # Create the email > my $message = Koha::Email->new; > my %mail = $message->create_message_headers( >diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl >index 140eff90c7..6d375125b4 100755 >--- a/ill/ill-requests.pl >+++ b/ill/ill-requests.pl >@@ -27,6 +27,8 @@ use Koha::AuthorisedValues; > use Koha::Illrequests; > use Koha::Libraries; > >+use Try::Tiny; >+ > our $cgi = CGI->new; > my $illRequests = Koha::Illrequests->new; > >@@ -182,17 +184,38 @@ if ( $backends_available ) { > handle_commit_maybe($backend_result, $request); > > } elsif ( $op eq 'generic_confirm' ) { >- my $request = Koha::Illrequests->find($params->{illrequest_id}); >- $params->{current_branchcode} = C4::Context->mybranch; >- my $backend_result = $request->generic_confirm($params); >- $template->param( >- whole => $backend_result, >- request => $request, >- ); >- >- # handle special commit rules & update type >- handle_commit_maybe($backend_result, $request); >+ try { >+ my $request = Koha::Illrequests->find($params->{illrequest_id}); >+ $params->{current_branchcode} = C4::Context->mybranch; >+ my $backend_result = $request->generic_confirm($params); >+ $template->param( >+ whole => $backend_result, >+ request => $request, >+ ); >+ $template->param( error => $params->{error} ) >+ if $params->{error}; > >+ # handle special commit rules & update type >+ handle_commit_maybe($backend_result, $request); >+ } >+ catch { >+ my $error; >+ if ( $_->isa( 'Koha::Exceptions::Ill::NoTargetEmail' ) ) { >+ $error = 'no_target_email'; >+ } >+ elsif ( $_->isa( 'Koha::Exceptions::Ill::NoLibraryEmail' ) ) { >+ $error = 'no_library_email'; >+ } >+ else { >+ $error = 'unknown_error'; >+ } >+ print $cgi->redirect( >+ "/cgi-bin/koha/ill/ill-requests.pl?" . >+ "method=generic_confirm&illrequest_id=" . >+ $params->{illrequest_id} . >+ "&error=$error" ); >+ exit; >+ }; > } elsif ( $op eq 'illlist') { > # Display all current ILLs > my $requests = $illRequests->search(); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >index e57115bf05..0c41d02eb5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >@@ -421,6 +421,18 @@ > > [% ELSIF query_type == 'generic_confirm' %] > <h1>Place request with partner libraries</h1> >+ [% IF error %] >+ <div class="alert"> >+ [% IF error == 'no_target_email' %] >+ No target email addresses found. Either select at least >+ one partner or check your ILL partner library records. >+ [% ELSIF error == 'no_library_email' %] >+ Your library has no usable email address. Please set it. >+ [% ELSIF error == 'unkown_error' %] >+ Unknown error processing your request. Contact your administrator. >+ [% END %] >+ </div> >+ [% END %] > <!-- Start of GENERIC_EMAIL case --> > [% IF whole.value.partners %] > [% ill_url = here_link _ "?method=illview&illrequest_id=" _ request.illrequest_id %] >-- >2.14.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7317
:
59893
|
59894
|
59895
|
59920
|
60485
|
60486
|
60487
|
60488
|
63081
|
63082
|
63083
|
63084
|
63085
|
63086
|
63087
|
63088
|
63089
|
63090
|
63113
|
63175
|
63176
|
63354
|
63421
|
63472
|
63475
|
65469
|
65470
|
65471
|
65472
|
65473
|
65474
|
65475
|
65476
|
66266
|
67242
|
67243
|
67244
|
67245
|
67246
|
67247
|
67248
|
67249
|
67250
|
67251
|
67252
|
67253
|
67254
|
67255
|
67256
|
67257
|
67258
|
67259
|
67260
|
67261
|
67262
|
67263
|
67264
|
67281
|
67282
|
67283
|
67284
|
67285
|
67286
|
67287
|
67288
|
67289
|
67290
|
67291
|
67292
|
67293
|
67294
|
67295
|
67296
|
67297
|
67298
|
67299
|
67300
|
67301
|
67302
|
67303
|
68185
|
68186
|
68328
|
68391
|
68406
|
68407
|
68408
|
68409
|
68418
|
68444
|
68445
|
68483
|
68484
|
68485
|
68487
|
68516
|
68517
|
68518
|
68519
|
68520
|
68521
|
68522
|
68523
|
68524
|
68525
|
68542
|
68543
|
68544
|
68545
|
68546
|
68547
|
68548
|
68549
|
68550
|
68551
|
68552
|
68558
|
68559
|
68560
|
68561
|
68562
|
68563
|
68564
|
68565
|
68566
|
68567
|
68858
|
68874
|
68877
|
68878
|
68885
|
68886
|
68921
|
68922
|
68926
|
68927
|
68928
|
68929
|
68931
|
68932
|
68933
|
68988
|
68989
|
68999
| 69000 |
69006
|
69008
|
69009
|
69012
|
69014
|
69044
|
69045
|
69046
|
69056
|
69059
|
69060
|
69061
|
69063
|
69064
|
69065
|
69066
|
69069
|
69070
|
69071
|
69074