From c4cb29d7d4ec681d30edab377934d11218dc983d Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Fri, 26 Aug 2022 14:28:39 +0200 Subject: [PATCH] Bug 31450: HTML customizations and News will not display on OPAC without Publication date To test: 1) Create some HTML Customizations and some News items that are set to display on the OPAC. Create one of each: [ 'With publication date today', 'With publication date in the future', 'Without publication date' ] 2) Note that news with publication date 'today' will display; with publication date 'in the future' will not display; with publication date unset will not display. 3) Note that html_customizations with date 'today' will display; with publication date 'in the future' will not display; with publication date unset will display. 4) Sign-Off Signed-off-by: Owen Leonard --- Koha/AdditionalContents.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Koha/AdditionalContents.pm b/Koha/AdditionalContents.pm index bbad4869a2..77694f141a 100644 --- a/Koha/AdditionalContents.pm +++ b/Koha/AdditionalContents.pm @@ -20,6 +20,7 @@ package Koha::AdditionalContents; use Modern::Perl; use Array::Utils qw( array_minus ); +use Data::Dumper; use Koha::Database; use Koha::Exceptions; @@ -83,7 +84,12 @@ sub search_for_display { my $search_params; $search_params->{location} = $params->{location}; $search_params->{branchcode} = $params->{library_id} ? [ $params->{library_id}, undef ] : undef; - $search_params->{published_on} = { '<=' => \'CAST(NOW() AS DATE)' }; + $params->{category} && $params->{category} eq 'news' + ? $search_params->{published_on} = { '<=' => \'CAST(NOW() AS DATE)' } + : $search_params->{-or} = [ + published_on => { '<=' => \'CAST(NOW() AS DATE)' }, + published_on => { '=' => \'NULL' } + ]; $search_params->{expirationdate} = [ '-or', { '>=' => \'CAST(NOW() AS DATE)' }, undef ]; $search_params->{category} = $params->{category} if $params->{category}; $search_params->{lang} = 'default' if !$lang || $lang eq 'default'; -- 2.39.2