From ab71394760cecb358fc8e35f884480ad426d56e3 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 17 Jul 2018 16:11:01 +0200 Subject: [PATCH] Bug 21066: Code changes needed for replacing opac_news.timestamp Content-Type: text/plain; charset=utf-8 Note: This is not finished yet. TODO installer/data/mysql/en/mandatory/sample_notices.sql:

Posted on <>

TODO installer/data/mysql/en/optional/sample_news.sql:INSERT INTO `opac_news` (`title`, `new`, `lang`, `timestamp`, `expirationdate`, `number`) ETC TODO t/db_dependent/NewsChannels.t --- C4/NewsChannels.pm | 12 ++++++------ koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt | 2 +- tools/koha-news.pl | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm index 8e261db..36ace87 100644 --- a/C4/NewsChannels.pm +++ b/C4/NewsChannels.pm @@ -135,7 +135,7 @@ sub get_opac_new { 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 }) if ( $data->{expirationdate} ); - $data->{timestamp} = output_pref({ dt => dt_from_string( $data->{timestamp} ), dateonly => 1 }) ; + $data->{publisheddate} = output_pref({ dt => dt_from_string( $data->{publisheddate} ), dateonly => 1 }) ; return $data; } @@ -145,7 +145,7 @@ sub get_opac_news { my $dbh = C4::Context->dbh; my $query = q{ SELECT opac_news.*, branches.branchname, - timestamp AS newdate, + publisheddate AS newdate, borrowers.title AS author_title, borrowers.firstname AS author_firstname, borrowers.surname AS author_surname @@ -162,7 +162,7 @@ sub get_opac_news { $query .= ' AND (opac_news.branchcode IS NULL OR opac_news.branchcode=?)'; push @values,$branchcode; } - $query.= ' ORDER BY timestamp DESC '; + $query.= ' ORDER BY publisheddate DESC '; #if ($limit) { # $query.= 'LIMIT 0, ' . $limit; #} @@ -193,7 +193,7 @@ sub GetNewsToDisplay { my $dbh = C4::Context->dbh; # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate my $query = q{ - SELECT opac_news.*,timestamp AS newdate, + SELECT opac_news.*,publisheddate AS newdate, borrowers.title AS author_title, borrowers.firstname AS author_firstname, borrowers.surname AS author_surname @@ -204,7 +204,7 @@ sub GetNewsToDisplay { OR expirationdate IS NULL OR expirationdate = '00-00-0000' ) - AND DATE(timestamp) < DATE_ADD(CURDATE(), INTERVAL 1 DAY) + AND publisheddate < DATE_ADD(CURDATE(), INTERVAL 1 DAY) AND (lang = '' OR lang = ?) AND (opac_news.branchcode IS NULL OR opac_news.branchcode = ?) ORDER BY number @@ -216,7 +216,7 @@ sub GetNewsToDisplay { $sth->execute($lang,$branch); my @results; while ( my $row = $sth->fetchrow_hashref ){ - $row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate} ), dateonly => 1 }); + $row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate} ) }); push @results, $row; } return \@results; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt index 074f875..d60a3fa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt @@ -145,7 +145,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]
  • - +
    [% INCLUDE 'date-format.inc' %]
  • diff --git a/tools/koha-news.pl b/tools/koha-news.pl index 53b943d..ef75728 100755 --- a/tools/koha-news.pl +++ b/tools/koha-news.pl @@ -43,7 +43,7 @@ my $expirationdate; if ( $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 $publisheddate = output_pref({ dt => dt_from_string( scalar $cgi->param('publisheddate') ), dateformat => 'iso', dateonly => 1 }); my $number = $cgi->param('number'); my $lang = $cgi->param('lang'); my $branchcode = $cgi->param('branch'); @@ -110,7 +110,7 @@ elsif ( $op eq 'add' ) { new => $new, lang => $lang, expirationdate => $expirationdate, - timestamp => $timestamp, + publisheddate => $publisheddate, number => $number, branchcode => $branchcode, borrowernumber => $borrowernumber, @@ -130,7 +130,7 @@ elsif ( $op eq 'edit' ) { new => $new, lang => $lang, expirationdate => $expirationdate, - timestamp => $timestamp, + publisheddate => $publisheddate, number => $number, branchcode => $branchcode, } -- 2.1.4