Bugzilla – Attachment 72549 Details for
Bug 14272
Allow OPAC to show a single news entry
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14272: Show single news item (backend)
Bug-14272-Show-single-news-item-backend.patch (text/plain), 3.99 KB, created by
Katrin Fischer
on 2018-03-09 07:06:11 UTC
(
hide
)
Description:
Bug 14272: Show single news item (backend)
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-03-09 07:06:11 UTC
Size:
3.99 KB
patch
obsolete
>From 16dbc46f5e6e12655a13b1f10cb78b49bb881bb5 Mon Sep 17 00:00:00 2001 >From: Martin Persson <xarragon@gmail.com> >Date: Fri, 18 Dec 2015 11:16:08 +0100 >Subject: [PATCH] Bug 14272: Show single news item (backend) > >Updates: > * Date formatting added to get_opac_new() > * Proper filtering by way of GetNewsToDisplay > >Sponsored-by: Halland County Library > >Signed-off-by: Aleisha <aleishaamohia@hotmail.com> > >Fixing merge conflicts > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/NewsChannels.pm | 46 ++++++++++++++++++++++++++++++++++------------ > 1 file changed, 34 insertions(+), 12 deletions(-) > >diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm >index a01d279..5228804 100644 >--- a/C4/NewsChannels.pm >+++ b/C4/NewsChannels.pm >@@ -125,9 +125,14 @@ sub get_opac_new { > my ($idnew) = @_; > my $dbh = C4::Context->dbh; > my $query = q{ >- SELECT opac_news.*,branches.branchname >+ SELECT opac_news.*,branches.branchname, >+ timestamp AS newdate, >+ borrowers.title AS author_title, >+ borrowers.firstname AS author_firstname, >+ borrowers.surname AS author_surname > FROM opac_news LEFT JOIN branches > ON opac_news.branchcode=branches.branchcode >+ LEFT JOIN borrowers on borrowers.borrowernumber = opac_news.borrowernumber > WHERE opac_news.idnew = ?; > }; > my $sth = $dbh->prepare($query); >@@ -135,6 +140,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->{newdate} = output_pref({ dt => dt_from_string( $data->{newdate} ), dateonly => 1 }); > $data->{timestamp} = output_pref({ dt => dt_from_string( $data->{timestamp} ), dateonly => 1 }) ; > return $data; > } >@@ -189,21 +195,35 @@ sub get_opac_news { > =cut > > sub GetNewsToDisplay { >- my ($lang,$branch) = @_; >+ my ($lang,$branch,$time,$id) = @_; > my $dbh = C4::Context->dbh; > # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate >+ my @values; > my $query = q{ > SELECT opac_news.*,timestamp AS newdate, >- borrowers.title AS author_title, >+ borrowers.title AS author_title, > borrowers.firstname AS author_firstname, >- borrowers.surname AS author_surname >- FROM opac_news >- LEFT JOIN borrowers on borrowers.borrowernumber = opac_news.borrowernumber >- WHERE ( >- expirationdate >= CURRENT_DATE() >- OR expirationdate IS NULL >- OR expirationdate = '00-00-0000' >- ) >+ borrowers.surname AS author_surname >+ FROM opac_news >+ LEFT JOIN borrowers on borrowers.borrowernumber = >+ opac_news.borrowernumber >+ WHERE (}; >+ >+ if ( defined $id ) { >+ $query .= q{ opac_news.idnew = ? } if defined $id; >+ push( @values, $id ); >+ } >+ >+ unless ( defined $time ) { >+ $query .= q{ AND } if defined $id; >+ $query .= q{ >+ expirationdate >= CURRENT_DATE() >+ OR expirationdate IS NULL >+ OR expirationdate = '00-00-0000' >+ } unless( defined $time and $time eq 'all' ); >+ } >+ >+ $query .= q{ ) > AND DATE(timestamp) < DATE_ADD(CURDATE(), INTERVAL 1 DAY) > AND (opac_news.lang = '' OR opac_news.lang = ?) > AND (opac_news.branchcode IS NULL OR opac_news.branchcode = ?) >@@ -213,7 +233,9 @@ sub GetNewsToDisplay { > # by adding 1, that captures today correctly. > my $sth = $dbh->prepare($query); > $lang = $lang // q{}; >- $sth->execute($lang,$branch); >+ push( @values, $lang ); >+ push( @values, $branch ); >+ $sth->execute(@values); > my @results; > while ( my $row = $sth->fetchrow_hashref ){ > $row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate} ), dateonly => 1 }); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14272
:
45721
|
45740
|
45741
|
45818
|
45820
|
45845
|
45846
|
45935
|
45936
|
45937
|
47556
|
47557
|
47558
|
47665
|
47666
|
47667
|
47668
|
47669
|
47670
|
47671
|
47672
|
47673
|
50557
|
50558
|
50559
|
59483
|
70728
|
70729
|
70730
|
70731
|
72065
|
72548
|
72549
|
72550
|
72551
|
76015
|
76307
|
76580
|
76662
|
77546
|
77564
|
77565
|
77566
|
77567
|
77568
|
77569
|
78104
|
78206
|
78207
|
78208
|
78231
|
81643
|
82713
|
83425
|
83426
|
83427
|
83428
|
83429
|
83430
|
84868
|
84869
|
84870
|
84871
|
84872
|
84873
|
84874