Bug 29332: Set default library limits in search_for_display

Koha::AdditionalContents->search_for_display needs to filter to just
items with a 'null' branchcode if no library_id is passed.

Test plan
1/ Add some additional content blocks that should display only for
specific branches.
2/ Navigate to the OPAC and note that blocks display for all libraries
prior to login
3/ Login to the OPAC and note that now you only see you users library
block
4/ Apply the patch
5/ Repeat steps 2 and 3 and note that now you see only the 'All
libraries' blocks display prior to login and that 'All libraries' +
'Your users library' blocks appear after login.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Martin Renvoize 2021-10-27 11:50:18 +01:00 committed by Jonathan Druart
parent f1780f02f2
commit 7948b429d1

View file

@ -71,7 +71,7 @@ sub search_for_display {
my $search_params;
$search_params->{location} = $params->{location};
$search_params->{branchcode} = [ $params->{library_id}, undef ] if $params->{library_id};
$search_params->{branchcode} = $params->{library_id} ? [ $params->{library_id}, undef ] : undef;
$search_params->{published_on} = { '<=' => \'CAST(NOW() AS DATE)' };
$search_params->{-or} = [ expirationdate => { '>=' => \'CAST(NOW() AS DATE)' },
expirationdate => undef ];