From 3e5b1f52b00de751eaad62b92eb7163c4b4f98a5 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 27 Oct 2021 14:54:43 +0100 Subject: [PATCH] Bug 27360: Use 'public' to filter libraries for opac display This patch adds the ability to set a library as 'public' or not; this allows librarians to hide back office library branches from the opac. Test plan 1/ Set a library as public from `admin > libraries`. 2/ Navigate to the `Libraries` page in the OPAC 3/ Note that only `public` libraries are displayed. Signed-off-by: Barbara Johnson Signed-off-by: Christopher Brannon Signed-off-by: Katrin Fischer --- admin/branches.pl | 1 + api/v1/swagger/definitions/library.json | 4 ++++ .../prog/en/modules/admin/branches.tt | 22 +++++++++++++++++- opac/opac-library.pl | 26 +++++++++++++--------- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/admin/branches.pl b/admin/branches.pl index 66b69868f0..88ff021c8c 100755 --- a/admin/branches.pl +++ b/admin/branches.pl @@ -84,6 +84,7 @@ if ( $op eq 'add_form' ) { opac_info marcorgcode pickup_location + public ); my $is_a_modif = $input->param('is_a_modif'); diff --git a/api/v1/swagger/definitions/library.json b/api/v1/swagger/definitions/library.json index def00d3c4f..2848a49a6d 100644 --- a/api/v1/swagger/definitions/library.json +++ b/api/v1/swagger/definitions/library.json @@ -88,6 +88,10 @@ "type": "boolean", "description": "If the library can act as a pickup location" }, + "public": { + "type": "boolean", + "description": "If the library is visible to the public" + }, "smtp_server": { "type": ["object", "null"], "description": "The library effective SMTP server" diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt index 6ce5842847..69ffdd74df 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt @@ -265,6 +265,17 @@ Libraries › Administration › Koha [% END %] +
  • + +
  • @@ -301,6 +312,7 @@ Libraries › Administration › Koha MARC organization code IP Pickup location + Public SMTP server Actions @@ -339,7 +351,7 @@ Libraries › Administration › Koha 'embed': [ 'smtp_server' ], 'emptyTable': '
    '+_("There are no libraries defined.")+' '+_("Start defining libraries")+'.
    ', "columnDefs": [ { - "targets": [0,1,3,4,6,8,9,10,11,12,13,14,15], + "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16], "render": function (data, type, row, meta) { if ( type == 'display' ) { if ( data != null ) { @@ -411,6 +423,14 @@ Libraries › Administration › Koha } }, { + "data": "public", + "searchable": true, + "orderable": true, + "render": function( data, type, row, meta ) { + return (data) ? _("Yes") : _("No"); + } + }, + { "data": "smtp_server", "render": function( data, type, row, meta ) { if ( data.smtp_server_id ) { diff --git a/opac/opac-library.pl b/opac/opac-library.pl index 951d0b43ab..21e4142f6b 100755 --- a/opac/opac-library.pl +++ b/opac/opac-library.pl @@ -17,7 +17,6 @@ # You should have received a copy of the GNU General Public License # along with Koha; if not, see . - use Modern::Perl; use CGI qw ( -utf8 ); @@ -27,7 +26,7 @@ use Koha::Libraries; my $query = CGI->new(); -my $branchcode = $query->param('branchcode'); +my $branchcode = $query->param('branchcode'); my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { @@ -38,15 +37,22 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); -if( $branchcode ){ - my $library = Koha::Libraries->find( $branchcode ); - $template->param( library => $library ); +my $found; +if ($branchcode) { + my $library = Koha::Libraries->find($branchcode); + if ( $library->public ) { + $found++; + $template->param( library => $library ); + } } -my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] }, ); -$template->param( - libraries => $libraries, - branchcode => $branchcode, -); +unless ($found) { + my $libraries = Koha::Libraries->search( { public => 1 }, { order_by => ['branchname'] } ); + + $template->param( + libraries => $libraries, + branchcode => $branchcode, + ); +} output_html_with_http_headers $query, $cookie, $template->output; -- 2.11.0