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>
(cherry picked from commit bc2a1d18e2)
Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
parent
19c7059573
commit
bad8eea9e1
23
C4/Review.pm
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);
|
||||
|
|
|
|||
|
|
@ -1,29 +1,13 @@
|
|||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Koha › Tools › Comments waiting for Approval</title>
|
||||
<title>Koha › Tools › Comments › [% 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> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
|
||||
› Comments Awaiting Moderation</div>
|
||||
› <a href="/cgi-bin/koha/reviews/reviewswaiting.pl">Comments</a> ›[% 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&reviewid=[% review.reviewid %]">Approve</a> |
|
||||
[% IF ( status ) %]<a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=unapprove&reviewid=[% review.reviewid %]">Unapprove</a>[% ELSE %]<a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=approve&reviewid=[% review.reviewid %]">Approve</a>[% END %] |
|
||||
<a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=delete&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>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue