Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 <chrisc@catalyst.net.nz>
Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
  • Loading branch information...
commit bc2a1d18e246b024e93a88df140281eebeb53a48 1 parent 525c7bc
@oleonard oleonard authored PaulPoulain committed
View
23 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);
View
35 koha-tmpl/intranet-tmpl/prog/en/modules/reviews/reviewswaiting.tt
@@ -1,29 +1,13 @@
[% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Tools &rsaquo; Comments waiting for Approval</title>
+<title>Koha &rsaquo; Tools &rsaquo; Comments &rsaquo; [% IF ( status ) %] Approved comments[% ELSE %] Comments awaiting moderation[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
-<script type="text/javascript">//<![CDATA[
-$(document).ready(function() {
-$.tablesorter.addParser({
- id: 'articles',
- is: function(s) {return false; },
- format: function(s) { return s.toLowerCase().replace(/^(the|an|a) /,''); },
- type: 'text'
-});
- $("#commentst").tablesorter({
- sortList: [[0,0]],
- headers: { 1: {sorter: 'articles'},2: { sorter: false },3: { sorter: false }}
- });
-});
-//]]>
-</script>
</head>
<body>
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
-&rsaquo; Comments Awaiting Moderation</div>
+&rsaquo; <a href="/cgi-bin/koha/reviews/reviewswaiting.pl">Comments</a> &rsaquo;[% IF ( status ) %] Approved comments[% ELSE %] Comments awaiting moderation[% END %]</div>
<div id="doc3" class="yui-t2">
@@ -33,6 +17,14 @@ $.tablesorter.addParser({
<h1>Comments</h1>
+<!-- The manual invoice and credit buttons -->
+<div class="toptabs">
+<ul class="ui-tabs-nav">
+ [% IF ( status ) %]<li class="ui-tabs-selected">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/reviews/reviewswaiting.pl?status=1">Approved comments</a></li>
+ [% IF ( status ) %]<li>[% ELSE %]<li class="ui-tabs-selected">[% END %]<a href="/cgi-bin/koha/reviews/reviewswaiting.pl" >Comments awaiting moderation</a></li>
+</ul>
+<div class="tabs-container">
+
[% IF ( reviews ) %]
<table id="commentst">
<thead><tr>
@@ -61,15 +53,18 @@ $.tablesorter.addParser({
[% review.review |html %]
</td>
<td>
- <a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=approve&amp;reviewid=[% review.reviewid %]">Approve</a> |
+ [% IF ( status ) %]<a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=unapprove&amp;reviewid=[% review.reviewid %]">Unapprove</a>[% ELSE %]<a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=approve&amp;reviewid=[% review.reviewid %]">Approve</a>[% END %] |
<a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=delete&amp;reviewid=[% review.reviewid %]">Delete</a>
</td>
</tr>
[% END %]</tbody>
</table>
+ <div class="pages">[% pagination_bar %]</div>
[% ELSE %]
-<b>No comments to moderate</b>
+[% IF ( status ) %]<p><b>No comments have been approved.</b></p>[% ELSE %]<p><b>No comments to moderate.</b></p>[% END %]
[% END %]
+</div>
+</div>
</div>
</div>
View
17 reviews/reviewswaiting.pl
@@ -39,16 +39,23 @@
);
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 @@
$_->{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;
Please sign in to comment.
Something went wrong with that request. Please try again.