From bc2a1d18e246b024e93a88df140281eebeb53a48 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 28 Nov 2011 08:35:21 -0500 Subject: [PATCH] Bug 1623 - Provide view of approved comments This patch creates two tabs on the comments administration page: one for approved comments and one for unapproved comments. Each display is paginated according to the numSearchResults preference. The list of approved comments has, instead of a link to approve, a link to unapprove. The JavaScript table sorter has been removed since it doesn't make sense to sort individual pages of a multi-page result set. Signed-off-by: Chris Cormack Signed-off-by: Ian Walls Signed-off-by: Paul Poulain --- C4/Review.pm | 23 ++++++++++-- .../prog/en/modules/reviews/reviewswaiting.tt | 35 ++++++++----------- reviews/reviewswaiting.pl | 17 +++++++-- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/C4/Review.pm b/C4/Review.pm index 49d90b371c..a113d4ea8d 100644 --- a/C4/Review.pm +++ b/C4/Review.pm @@ -30,7 +30,7 @@ BEGIN { require Exporter; @ISA = qw(Exporter); @EXPORT = qw(getreview savereview updatereview numberofreviews numberofreviewsbybiblionumber - getreviews getallreviews approvereview deletereview); + getreviews getallreviews approvereview unapprovereview deletereview); } =head1 NAME @@ -44,7 +44,8 @@ C4::Review - Perl Module containing routines for dealing with reviews of items my $review=getreview($biblionumber,$borrowernumber); savereview($biblionumber,$borrowernumber,$review); updatereview($biblionumber,$borrowernumber,$review); - my $count=numberofreviews($biblionumber); + my $count=numberofreviews($status); + my $count=numberofreviewsbybiblionumber($biblionumber); my $reviews=getreviews($biblionumber); my $reviews=getallreviews($status); @@ -150,6 +151,24 @@ sub approvereview { $sth->execute( 1, $reviewid ); } +=head2 unapprovereview + + unapprovereview($reviewid); + +Takes a reviewid and marks that review as not approved + +=cut + +sub unapprovereview { + my ($reviewid) = @_; + my $dbh = C4::Context->dbh(); + my $query = "UPDATE reviews + SET approved=? + WHERE reviewid=?"; + my $sth = $dbh->prepare($query); + $sth->execute( 0, $reviewid ); +} + =head2 deletereview deletereview($reviewid); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reviews/reviewswaiting.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reviews/reviewswaiting.tt index 3d7bb22c36..a1dabbd092 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reviews/reviewswaiting.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reviews/reviewswaiting.tt @@ -1,29 +1,13 @@ [% INCLUDE 'doc-head-open.inc' %] -Koha › Tools › Comments waiting for Approval +Koha › Tools › Comments › [% IF ( status ) %] Approved comments[% ELSE %] Comments awaiting moderation[% END %] [% INCLUDE 'doc-head-close.inc' %] - - [% INCLUDE 'header.inc' %] [% INCLUDE 'cat-search.inc' %] +› Comments ›[% IF ( status ) %] Approved comments[% ELSE %] Comments awaiting moderation[% END %]
@@ -33,6 +17,14 @@ $.tablesorter.addParser({

Comments

+ +
+ +
+ [% IF ( reviews ) %] @@ -61,15 +53,18 @@ $.tablesorter.addParser({ [% review.review |html %] [% END %]
- Approve | + [% IF ( status ) %]Unapprove[% ELSE %]Approve[% END %] | Delete
+
[% pagination_bar %]
[% ELSE %] -No comments to moderate +[% IF ( status ) %]

No comments have been approved.

[% ELSE %]

No comments to moderate.

[% END %] [% END %] +
+
diff --git a/reviews/reviewswaiting.pl b/reviews/reviewswaiting.pl index 4d28a9671a..71072160ed 100755 --- a/reviews/reviewswaiting.pl +++ b/reviews/reviewswaiting.pl @@ -39,16 +39,23 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); my $op = $query->param('op') || ''; +my $status = $query->param('status') || 0; my $reviewid = $query->param('reviewid'); +my $offset = $query->param('offset') || 0; +my $count = C4::Context->preference('numSearchResults') || 20; +my $total = numberofreviews($status); if ( $op eq 'approve' ) { approvereview($reviewid); } +elsif ( $op eq 'unapprove' ) { + unapprovereview($reviewid); +} elsif ( $op eq 'delete' ) { deletereview($reviewid); } -my $reviews = getallreviews(0); +my $reviews = getallreviews($status,$offset,$count); foreach ( @$reviews ) { my $borrowernumber = $_->{borrowernumber}; @@ -60,6 +67,12 @@ foreach ( @$reviews ) { $_->{firstname} = $borrowerData->{'firstname'}; } -$template->param( reviews => $reviews ); +my $url = "/cgi-bin/koha/reviews/reviewswaiting.pl?status=$status"; + +$template->param( + status => $status, + reviews => $reviews, + pagination_bar => pagination_bar( $url, ( int( $total / $count ) ) + ( ( $total % $count ) > 0 ? 1 : 0 ), $offset, "offset" ) +); output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5