Bug 16550: Can't set opac news expiration date to NULL, it reverts to today

This patch fixes an issue with the expiration dates for news always reverting to today if empty.

To test:
- Apply patch
- Go to Home > Tools > News
- Create a news item, do not set expiration date
- Verify that expiration date stays empty
- Edit this news item
- Do not set expiration date
- Verify that expiration date stays empty
- Do the same with expiration dates
- Verify that they are saved properly

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit b5acde6513)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
This commit is contained in:
Marc Véron 2016-05-20 12:19:36 +02:00 committed by Julian Maurice
parent 98a39cee30
commit dac9b06b18
2 changed files with 5 additions and 2 deletions

View File

@ -135,7 +135,7 @@ sub get_opac_new {
$sth->execute($idnew);
my $data = $sth->fetchrow_hashref;
$data->{$data->{'lang'}} = 1 if defined $data->{lang};
$data->{expirationdate} = output_pref({ dt => dt_from_string( $data->{expirationdate} ), dateonly => 1 });
$data->{expirationdate} = output_pref({ dt => dt_from_string( $data->{expirationdate} ), dateonly => 1 }) if ( $data->{expirationdate} );
$data->{timestamp} = output_pref({ dt => dt_from_string( $data->{timestamp} ), dateonly => 1 }) ;
return $data;
}

View File

@ -40,7 +40,10 @@ my $cgi = new CGI;
my $id = $cgi->param('id');
my $title = $cgi->param('title');
my $new = $cgi->param('new');
my $expirationdate = output_pref({ dt => dt_from_string( scalar $cgi->param('expirationdate') ), dateformat => 'iso', dateonly => 1 });
my $expirationdate;
if ( scalar $cgi->param('expirationdate') ) {
$expirationdate = output_pref({ dt => dt_from_string( scalar $cgi->param('expirationdate') ), dateformat => 'iso', dateonly => 1 });
}
my $timestamp = output_pref({ dt => dt_from_string( scalar $cgi->param('timestamp') ), dateformat => 'iso', dateonly => 1 });
my $number = $cgi->param('number');
my $lang = $cgi->param('lang');