@@ -, +, @@ --- Koha/Exceptions/Ill.pm | 16 ++++++++++++++++ Koha/Illrequest.pm | 12 ++++++++++-- ill/ill-requests.pl | 13 +++++++------ koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc | 10 ++++++++-- .../intranet-tmpl/prog/en/modules/ill/ill-requests.tt | 3 +-- 5 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 Koha/Exceptions/Ill.pm --- a/Koha/Exceptions/Ill.pm +++ a/Koha/Exceptions/Ill.pm @@ -0,0 +1,16 @@ +package Koha::Exceptions::Ill; + +use Modern::Perl; + +use Exception::Class ( + + 'Koha::Exceptions::Ill' => { + description => 'Something went wrong!', + }, + 'Koha::Exceptions::Ill::InvalidBackendId' => { + isa => 'Koha::Exceptions::Ill', + description => "Invalid backend name required", + } +); + +1; --- a/Koha/Illrequest.pm +++ a/Koha/Illrequest.pm @@ -18,16 +18,18 @@ package Koha::Illrequest; # Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin # Street, Fifth Floor, Boston, MA 02110-1301 USA. +use Modern::Perl; + use Clone 'clone'; use File::Basename qw/basename/; use Koha::Database; use Koha::Email; +use Koha::Exceptions::Ill; use Koha::Illrequest; use Koha::Illrequestattributes; use Koha::Patron; use Mail::Sendmail; use Try::Tiny; -use Modern::Perl; use base qw(Koha::Object); @@ -138,14 +140,20 @@ sub load_backend { my @raw = qw/Koha Illbackends/; # Base Path + unless ( defined $backend_id && $backend_id ne '' ) { + Koha::Exceptions::Ill::InvalidBackendId->throw( + "An invalid backend ID was requested ('')"); + } + my $backend_name = $backend_id || $self->backend; - my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load + my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name require $location; $self->{_my_backend} = $backend_class->new({ config => $self->_config }); return $self; } + =head3 _backend my $backend = $abstract->_backend($new_backend); --- a/ill/ill-requests.pl +++ a/ill/ill-requests.pl @@ -224,14 +224,15 @@ if ( $op eq 'illview' ) { } # Get a list of backends -my $ir = Koha::Illrequest->new; +my $available_backends = Koha::Illrequest->new->available_backends; $template->param( - backends => $ir->available_backends, - media => [ "Book", "Article", "Journal" ], - query_type => $op, - branches => Koha::Libraries->search->unblessed, - here_link => "/cgi-bin/koha/ill/ill-requests.pl" + backends_available => ( scalar $available_backends > 0 ), + backends => $available_backends, + media => [ "Book", "Article", "Journal" ], + query_type => $op, + branches => Koha::Libraries->search, + here_link => "/cgi-bin/koha/ill/ill-requests.pl" ); output_html_with_http_headers( $cgi, $cookie, $template->output ); --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc @@ -1,7 +1,8 @@ [% USE Koha %] [% IF Koha.Preference('ILLModule ') %]
- [% IF backends.size > 1 %] + [% IF available_backends %] + [% IF backends.size > 1 %] - [% ELSE %] + [% ELSE %] New ILL request + [% END %] + [% ELSE %] + + New ILL request + [% END %] List requests --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -4,8 +4,7 @@ [% INCLUDE 'doc-head-open.inc' %] Koha › ILL requests › [% INCLUDE 'doc-head-close.inc' %] - - + [% INCLUDE 'datatables.inc' %]