From fd803a915cfab560f7ef3df086785642ba6bdaef 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Koha/AdditionalContents.pm b/Koha/AdditionalContents.pm index 3ed9f42f41c..9c34b33eae0 100644 --- a/Koha/AdditionalContents.pm +++ b/Koha/AdditionalContents.pm @@ -19,6 +19,8 @@ package Koha::AdditionalContents; use Modern::Perl; +use Data::Dumper; + use Koha::Database; use Koha::Exceptions; use Koha::AdditionalContent; @@ -69,10 +71,17 @@ location is one of this: sub search_for_display { my ( $self, $params ) = @_; + warn Dumper($params); + 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->{-or} = [ expirationdate => { '>=' => \'CAST(NOW() AS DATE)' }, expirationdate => undef ]; $search_params->{category} = $params->{category} if $params->{category}; -- 2.30.2