[Koha-patches] [PATCH] [bug #2762] Add a date field in news edition, and permit to set the "timestamp" field, that is the publication date
Nahuel ANGELINETTI
nahuel.angelinetti at biblibre.com
Thu Nov 6 11:19:02 CET 2008
Hi,
git-send-email done something wrong, the entire commit log is :
[bug #2762] 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.
And I invite you to see the bugzilla ticket :
http://bugs.koha.org/cgi-bin/bugzilla/show_bug.cgi?id=2762
Regards,
--
Nahuel
Le Thu, 6 Nov 2008 11:03:52 +0100,
Nahuel Angelinetti <nahuel.angelinetti at biblibre.com> a écrit :
> ---
> C4/NewsChannels.pm | 13
> ++++++++----- .../prog/en/modules/tools/koha-news.tmpl |
> 18 ++++++++++++++++--
> tools/koha-news.pl | 5 +++-- 3
> files changed, 27 insertions(+), 9 deletions(-)
>
> diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm
> index ec222ba..ca85f55 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 index
> 6aa4d76..09dca99 100755 ---
> a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl +++
> b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl @@
> -65,13 +65,27 @@ Edit News Item<!-- TMPL_ELSE -->Add News
> Item<!-- /TMPL_IF --><!-- TMPL_ELSE --> <input id="title" size="30"
> type="text" name="title" value="<!-- TMPL_VAR NAME="title" -->" />
> </li> <li>
> + <label for="timestamp">Publication date</label>
> + <input id="timestamp" type="text" name="timestamp"
> size="15" value="<!-- TMPL_VAR NAME="timestamp" -->" />
> + <img src="<!-- TMPL_VAR Name="themelang"
> -->/lib/calendar/cal.gif" alt="Show Calendar" border="0"
> id="timestampButton" style="cursor: pointer;" />
> + <script type="text/javascript">
> + Calendar.setup(
> + {
> + button : "timestampButton",
> + inputField : "timestamp",
> + ifFormat : "<!-- TMPL_VAR
> NAME="DHTMLcalendar_dateformat" -->",
> + }
> + );
> + </script>
> + </li>
> + <li>
> <label for="expirationdate">Expiration date</label>
> <input id="expirationdate" type="text"
> name="expirationdate" size="15" value="<!-- TMPL_VAR
> NAME="expirationdate" -->" />
> - <img src="<!-- TMPL_VAR
> Name="themelang" -->/lib/calendar/cal.gif" alt="Show Calendar"
> border="0" id="openCalendar" style="cursor: pointer;" />
> + <img src="<!-- TMPL_VAR Name="themelang"
> -->/lib/calendar/cal.gif" alt="Show Calendar" border="0"
> id="openCalendar" style="cursor: pointer;" /> <script
> type="text/javascript"> Calendar.setup( {
> - button :
> "openCalendar",
> + button : "openCalendar",
> inputField : "expirationdate",
> ifFormat : "<!-- TMPL_VAR
> NAME="DHTMLcalendar_dateformat" -->", }
> diff --git a/tools/koha-news.pl b/tools/koha-news.pl
> index 3730c10..08b38c8 100755
> --- a/tools/koha-news.pl
> +++ b/tools/koha-news.pl
> @@ -38,6 +38,7 @@ my $id = $cgi->param('id');
> my $title = $cgi->param('title');
> my $new = $cgi->param('new');
> my $expirationdate =
> format_date_in_iso($cgi->param('expirationdate')); +my
> $timestamp = format_date_in_iso($cgi->param('timestamp')); my
> $number = $cgi->param('number'); my $lang =
> $cgi->param('lang');
> @@ -83,11 +84,11 @@ if ( $op eq 'add_form' ) {
> }
> }
> elsif ( $op eq 'add' ) {
> - add_opac_new( $title, $new, $lang, $expirationdate, $number );
> + add_opac_new( $title, $new, $lang, $expirationdate, $timestamp,
> $number ); print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
> }
> elsif ( $op eq 'edit' ) {
> - upd_opac_new( $id, $title, $new, $lang, $expirationdate,
> $number );
> + upd_opac_new( $id, $title, $new, $lang, $expirationdate,
> $timestamp ,$number ); print
> $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); }
> elsif ( $op eq 'del' ) {
More information about the Koha-patches
mailing list