From 5a1e844d101c7d157b73631c6a3b00e55c934831 Mon Sep 17 00:00:00 2001 From: Nahuel Angelinetti Date: Thu, 6 Nov 2008 11:01:32 +0100 Subject: [PATCH] Add a date field in news edition, and permit to set the "timestamp" field, that is the publication date and modify the GetNewsToDisplay to return only news that timestamp is < to current date that permit to publish news later without any action. Signed-off-by: Henri-Damien LAURENT --- C4/NewsChannels.pm | 13 ++++++++----- .../prog/en/modules/tools/koha-news.tmpl | 18 ++++++++++++++++-- tools/koha-news.pl | 5 +++-- 3 files changed, 27 insertions(+), 9 deletions(-) mode change 100644 => 100755 koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm index 5edf0f1a36..136cc5c282 100644 --- a/C4/NewsChannels.pm +++ b/C4/NewsChannels.pm @@ -234,16 +234,16 @@ sub update_channel_category { } sub add_opac_new { - my ($title, $new, $lang, $expirationdate, $number) = @_; + my ($title, $new, $lang, $expirationdate, $timestamp, $number) = @_; my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("INSERT INTO opac_news (title, new, lang, expirationdate, number) VALUES (?,?,?,?,?)"); - $sth->execute($title, $new, $lang, $expirationdate, $number); + my $sth = $dbh->prepare("INSERT INTO opac_news (title, new, lang, expirationdate, timestamp, number) VALUES (?,?,?,?,?,?)"); + $sth->execute($title, $new, $lang, $expirationdate, $timestamp, $number); $sth->finish; return 1; } sub upd_opac_new { - my ($idnew, $title, $new, $lang, $expirationdate, $number) = @_; + my ($idnew, $title, $new, $lang, $expirationdate, $timestamp,$number) = @_; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare(" UPDATE opac_news SET @@ -251,10 +251,11 @@ sub upd_opac_new { new = ?, lang = ?, expirationdate = ?, + timestamp = ?, number = ? WHERE idnew = ? "); - $sth->execute($title, $new, $lang, $expirationdate,$number,$idnew); + $sth->execute($title, $new, $lang, $expirationdate, $timestamp,$number,$idnew); $sth->finish; return 1; } @@ -280,6 +281,7 @@ sub get_opac_new { my $data = $sth->fetchrow_hashref; $data->{$data->{'lang'}} = 1; $data->{expirationdate} = format_date($data->{expirationdate}); + $data->{timestamp} = format_date($data->{timestamp}); $sth->finish; return $data; } @@ -330,6 +332,7 @@ sub GetNewsToDisplay { OR expirationdate IS NULL OR expirationdate = '00-00-0000' ) + AND `timestamp` < CURRENT_DATE() AND lang = ? ORDER BY number "; # expirationdate field is NOT in ISO format? diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl old mode 100644 new mode 100755 index 6aa4d76feb..09dca9966b --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl @@ -64,14 +64,28 @@ Edit News ItemAdd News Item " /> +
  • + + " /> + /lib/calendar/cal.gif" alt="Show Calendar" border="0" id="timestampButton" style="cursor: pointer;" /> + +
  • " /> - /lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openCalendar" style="cursor: pointer;" /> + /lib/calendar/cal.gif" alt="Show Calendar" border="0" id="openCalendar" style="cursor: pointer;" />