Bugzilla – Attachment 53796 Details for
Bug 15839
Move the reviews related code to Koha::Reviews
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15839: Koha::Reviews - Remove getallreviews
Bug-15839-KohaReviews---Remove-getallreviews.patch (text/plain), 5.37 KB, created by
Marcel de Rooy
on 2016-07-29 09:44:20 UTC
(
hide
)
Description:
Bug 15839: Koha::Reviews - Remove getallreviews
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-07-29 09:44:20 UTC
Size:
5.37 KB
patch
obsolete
>From b0c1b0d32dfe1d9ad598b5fcfdf218649fb7185d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 16 Feb 2016 15:56:03 +0000 >Subject: [PATCH] Bug 15839: Koha::Reviews - Remove getallreviews >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Marc Veron <veron@veron.ch> >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Review.pm | 25 +------------------- > .../opac-tmpl/bootstrap/en/modules/opac-review.tt | 1 + > opac/opac-showreviews.pl | 13 +++++++--- > reviews/reviewswaiting.pl | 14 +++++++---- > 4 files changed, 22 insertions(+), 31 deletions(-) > >diff --git a/C4/Review.pm b/C4/Review.pm >index 6f40ec1..9b27c44 100644 >--- a/C4/Review.pm >+++ b/C4/Review.pm >@@ -28,7 +28,7 @@ BEGIN { > require Exporter; > @ISA = qw(Exporter); > @EXPORT = qw(getreview savereview updatereview numberofreviews numberofreviewsbybiblionumber >- getallreviews approvereview unapprovereview deletereview); >+ approvereview unapprovereview deletereview); > } > > =head1 NAME >@@ -44,7 +44,6 @@ C4::Review - Perl Module containing routines for dealing with reviews of items > updatereview($biblionumber,$borrowernumber,$review); > my $count=numberofreviews($status); > my $count=numberofreviewsbybiblionumber($biblionumber); >- my $reviews=getallreviews($status, [$offset], [$row_count]); > > =head1 DESCRIPTION > >@@ -139,28 +138,6 @@ sub numberofreviewsbybiblionumber { > return $sth->fetchrow; > } > >-=head2 getallreviews >- >- my $reviews=getallreviews($status, [$offset], [$row_count]); >- >-Return all reviews where in the 'reviews' database : 'approved' = $status >- >-If offset and row_count are fiven, it's return all reviews between the >-$offset position and the ($offset + $row_count) position. >-(By default : $offset = 0 and $row_count = 20) >- >-=cut >- >-sub getallreviews { >- my ( $status, $offset, $row_count ) = @_; >- my @params = ( $status, ( $offset ? $offset : 0 ), ( $row_count ? $row_count : 20 ) ); >- my $dbh = C4::Context->dbh; >- my $query = "SELECT * FROM reviews WHERE approved=? order by datereviewed desc LIMIT ?, ?"; >- my $sth = $dbh->prepare($query); >- $sth->execute(@params); >- return $sth->fetchall_arrayref( {} ); >-} >- > =head2 approvereview > > approvereview($reviewid); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt >index c5ecd82..b6f968d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt >@@ -62,6 +62,7 @@ > //<![CDATA[ > $(document).ready(function() { > [% IF WINDOW_CLOSE %] >+ opener.location.reload(); > window.close(); > [% END %] > }); >diff --git a/opac/opac-showreviews.pl b/opac/opac-showreviews.pl >index 628fec8..69c0869 100755 >--- a/opac/opac-showreviews.pl >+++ b/opac/opac-showreviews.pl >@@ -30,6 +30,7 @@ use C4::Review; > use C4::Biblio; > use C4::Members qw/GetMemberDetails/; > use Koha::DateUtils; >+use Koha::Reviews; > use POSIX qw(ceil strftime); > > my $template_name; >@@ -38,8 +39,7 @@ my $format = $query->param("format") || ''; > my $count = C4::Context->preference('OPACnumSearchResults') || 20; > my $results_per_page = $query->param('count') || $count; > my $offset = $query->param('offset') || 0; >-my $page = $query->param('page') || 1; >-$offset = ($page-1)*$results_per_page if $page>1; >+my $page = $offset / $results_per_page + 1; > > if ($format eq "rss") { > $template_name = "opac-showreviews-rss.tt"; >@@ -76,7 +76,14 @@ if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowRe > } > } > >-my $reviews = getallreviews(1,$offset,$results_per_page); >+my $reviews = Koha::Reviews->search( >+ { approved => 1 }, >+ { >+ rows => $results_per_page, >+ page => $page, >+ order_by => { -desc => 'datereviewed' }, >+ } >+)->unblessed; > my $marcflavour = C4::Context->preference("marcflavour"); > my $hits = numberofreviews(1); > my $i = 0; >diff --git a/reviews/reviewswaiting.pl b/reviews/reviewswaiting.pl >index e3d6c8d..b534391 100755 >--- a/reviews/reviewswaiting.pl >+++ b/reviews/reviewswaiting.pl >@@ -15,8 +15,7 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-use warnings; >+use Modern::Perl; > > use CGI qw ( -utf8 ); > use C4::Auth; >@@ -25,6 +24,7 @@ use C4::Context; > use C4::Review; > use C4::Members; > use C4::Biblio; >+use Koha::Reviews; > > my $query = new CGI; > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >@@ -43,7 +43,6 @@ my $status = $query->param('status') || 0; > my $reviewid = $query->param('reviewid'); > my $page = $query->param('page') || 1; > my $count = C4::Context->preference('numSearchResults') || 20; >-my $offset = ($page-1) * $count; > my $total = numberofreviews($status); > > if ( $op eq 'approve' ) { >@@ -56,7 +55,14 @@ elsif ( $op eq 'delete' ) { > deletereview($reviewid); > } > >-my $reviews = getallreviews($status,$offset,$count); >+my $reviews = Koha::Reviews->search( >+ { approved => $status }, >+ { >+ rows => $count, >+ page => $page, >+ order_by => { -desc => 'datereviewed' }, >+ } >+)->unblessed; > > foreach ( @$reviews ) { > my $borrowernumber = $_->{borrowernumber}; >-- >1.7.10.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 15839
:
48166
|
48167
|
48168
|
48169
|
48170
|
48171
|
48172
|
48173
|
48174
|
48175
|
48176
|
48280
|
48281
|
48282
|
48283
|
48284
|
48285
|
48286
|
48287
|
48288
|
48289
|
48290
|
51197
|
51198
|
51199
|
51200
|
51201
|
51202
|
51203
|
51204
|
51205
|
51206
|
51207
|
53794
|
53795
| 53796 |
53797
|
53798
|
53799
|
53800
|
53801
|
53802
|
53803
|
53804
|
53805
|
53806
|
53807