Bug 2486: Show user comments in staff interface
This patch the staff interface's bibliographic detail page, adding a tab that shows comments submitted by users from the OPAC. To test, apply the patch and restart services. - If necessary, enable the "OPACComments" system preference and submit some comments in the OPAC. - In the staff interface, locate the title you submitted comments on. - The bibliographic detail page should show a "Comments" tab with a count of the number of all comments (approved and unapproved). Sponsored-By: Athens County Public Libraries Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
5daf6909b3
commit
2e0582ea31
5 changed files with 167 additions and 4 deletions
|
@ -531,6 +531,21 @@ modules:
|
|||
-
|
||||
columnname: subscription_callnumber
|
||||
|
||||
comments-table:
|
||||
columns:
|
||||
-
|
||||
columnname: patron
|
||||
-
|
||||
columnname: date
|
||||
-
|
||||
columnname: status
|
||||
-
|
||||
columnname: comment
|
||||
-
|
||||
columnname: actions
|
||||
cannot_be_toggled: 1
|
||||
cannot_be_modified: 1
|
||||
|
||||
checkoutshistory-table:
|
||||
default_display_length: 20
|
||||
columns:
|
||||
|
|
|
@ -57,6 +57,7 @@ use Koha::Patrons;
|
|||
use Koha::Virtualshelves;
|
||||
use Koha::Plugins;
|
||||
use Koha::Recalls;
|
||||
use Koha::Reviews;
|
||||
use Koha::SearchEngine::Search;
|
||||
use Koha::SearchEngine::QueryBuilder;
|
||||
use Koha::Serial::Items;
|
||||
|
@ -85,10 +86,15 @@ if ( C4::Context->config('enable_plugins') ) {
|
|||
);
|
||||
}
|
||||
|
||||
my $activetab = $query->param('activetab');
|
||||
my $biblionumber = $query->param('biblionumber');
|
||||
$biblionumber = HTML::Entities::encode($biblionumber);
|
||||
my $biblio = Koha::Biblios->find( $biblionumber );
|
||||
$template->param( 'biblio', $biblio );
|
||||
|
||||
$template->param(
|
||||
biblio => $biblio,
|
||||
activetab => $activetab,
|
||||
);
|
||||
|
||||
unless ( $biblio ) {
|
||||
# biblionumber invalid -> report and exit
|
||||
|
@ -382,6 +388,37 @@ if (C4::Context->preference("AlternateHoldingsField") && $items_to_display->coun
|
|||
);
|
||||
}
|
||||
|
||||
if ( C4::Context->preference('OPACComments') ) {
|
||||
my $reviews = Koha::Reviews->search(
|
||||
{ biblionumber => $biblionumber },
|
||||
{ order_by => { -desc => 'datereviewed' } }
|
||||
)->unblessed;
|
||||
my $libravatar_enabled = 0;
|
||||
if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto') ) {
|
||||
eval {
|
||||
require Libravatar::URL;
|
||||
Libravatar::URL->import();
|
||||
};
|
||||
if ( !$@ ) {
|
||||
$libravatar_enabled = 1;
|
||||
}
|
||||
}
|
||||
for my $review (@$reviews) {
|
||||
my $review_patron =
|
||||
Koha::Patrons->find( $review->{borrowernumber} ); # FIXME Should be Koha::Review->reviewer or similar
|
||||
|
||||
# setting some borrower info into this hash
|
||||
if ($review_patron) {
|
||||
$review->{patron} = $review_patron;
|
||||
if ( $libravatar_enabled and $review_patron->email ) {
|
||||
$review->{avatarurl} = libravatar_url( email => $review_patron->email, https => $ENV{HTTPS} );
|
||||
}
|
||||
}
|
||||
}
|
||||
$template->param( 'reviews' => $reviews );
|
||||
|
||||
}
|
||||
|
||||
my @results = ( $dat, );
|
||||
foreach ( keys %{$dat} ) {
|
||||
$template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
|
||||
|
|
|
@ -2753,6 +2753,15 @@ fieldset > .toptabs {
|
|||
font-style: italic;
|
||||
}
|
||||
|
||||
.commentline {
|
||||
border-bottom: 1px solid #CCC;
|
||||
|
||||
.btn-toolbar {
|
||||
margin-bottom: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.contents {
|
||||
width: 75%;
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
[% END %]
|
||||
|
||||
<body id="catalog_detail" class="catalog">
|
||||
|
||||
[% WRAPPER 'header.inc' %]
|
||||
[% INCLUDE 'cat-search.inc' %]
|
||||
[% END %]
|
||||
|
@ -381,6 +380,12 @@
|
|||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% IF ( reviews ) %]
|
||||
[% WRAPPER tab_item tabname= "comments" %]
|
||||
<span>Comments [% ' ( ' _ ( reviews.size ) _ ' )' | html %]</span>
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
|
||||
[% WRAPPER tab_item tabname= "NovelistSelect" %]
|
||||
<span>NoveList Select</span>
|
||||
|
@ -837,6 +842,82 @@
|
|||
[% END # /tab_panel %]
|
||||
[% END # /IF HTML5MediaEnabled %]
|
||||
|
||||
[% IF ( reviews ) %]
|
||||
[% WRAPPER tab_panel tabname="comments" %]
|
||||
[% SET ShowReviewerPhoto = Koha.Preference( "ShowReviewerPhoto" ) %]
|
||||
<table id="comments_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Commenter</th>
|
||||
<th>Date</th>
|
||||
<th>Status</th>
|
||||
<th>Comment</th>
|
||||
<th class="NoSort">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[% FOREACH review IN reviews %]
|
||||
<tr id="comment[% review.reviewid | html %]">
|
||||
<td>
|
||||
[% IF ( review.patron ) %]
|
||||
[% IF ( review.avatarurl ) %]
|
||||
<img class="avatar" src="[% review.avatarurl | html %]" height="80" width="80" alt="" />
|
||||
[% END %]
|
||||
[% INCLUDE 'patron-title.inc' patron=review.patron hide_patron_infos_if_needed=1 %]
|
||||
[% ELSE %]
|
||||
<em>Patron deleted<em>
|
||||
[% END %]
|
||||
</td>
|
||||
<td data-order="[% review.datereviewed | html %]">
|
||||
[% review.datereviewed | $KohaDates %]
|
||||
</td>
|
||||
<td>
|
||||
[% IF ( review.approved ) %]
|
||||
<em>Approved</em>
|
||||
[% ELSE %]
|
||||
<em>Unapproved</em>
|
||||
[% END %]
|
||||
</td>
|
||||
<td>
|
||||
[% FILTER html_break %]
|
||||
[% review.review | html %]
|
||||
[% END %]
|
||||
</td>
|
||||
[% IF ( CAN_user_tools_moderate_comments ) %]
|
||||
<td class="actions">
|
||||
[% IF ( review.approved ) %]
|
||||
<form action="/cgi-bin/koha/reviews/reviewswaiting.pl" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="cud-unapprove" />
|
||||
<input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
|
||||
<input type="hidden" name="reviewid" value="[% review.reviewid | html %]" />
|
||||
<button type="submit" class="btn btn-default btn-xs"><i class="fa fa-times" aria-hidden="true"></i> Unapprove</button>
|
||||
</form>
|
||||
[% ELSE %]
|
||||
<form action="/cgi-bin/koha/reviews/reviewswaiting.pl" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="cud-approve" />
|
||||
<input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
|
||||
<input type="hidden" name="reviewid" value="[% review.reviewid | html %]" />
|
||||
<button type="submit" class="btn btn-default btn-xs"><i class="fa fa-check" aria-hidden="true"></i> Approve</button>
|
||||
</form>
|
||||
[% END %]
|
||||
<form action="/cgi-bin/koha/reviews/reviewswaiting.pl" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="cud-delete" />
|
||||
<input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
|
||||
<input type="hidden" name="reviewid" value="[% review.reviewid | html %]" />
|
||||
<button type="submit" class="btn btn-default btn-xs delete-comment"><i class="fa fa-trash-can" aria-hidden="true"></i> Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
[% END # /IF CAN_user_tools_moderate_comments %]
|
||||
</tr>
|
||||
[% END # / FOREACH reviews %]
|
||||
</tbody>
|
||||
</table>
|
||||
[% END %]
|
||||
[% END # /IF reviews %]
|
||||
|
||||
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'tab' ) %]
|
||||
[% WRAPPER tab_panel tabname="NovelistSelect" %]
|
||||
<div data-novelist-novelistselect=[% normalized_isbn | html %]></div>
|
||||
|
@ -847,7 +928,7 @@
|
|||
[% WRAPPER tab_panel tabname="${ plugins_intranet_catalog_biblio_tab.id }" %]
|
||||
[% plugins_intranet_catalog_biblio_tab.content | $raw %]
|
||||
[% END # /tab_panel %]
|
||||
[% END %]
|
||||
[% END # /WRAPPER comments %]
|
||||
[% END # /WRAPPER tab_panels %]
|
||||
[% END # /WRAPPER tabs %]
|
||||
|
||||
|
@ -1441,7 +1522,9 @@
|
|||
|
||||
$(document).ready(function() {
|
||||
// Pick details tab to display by default
|
||||
[% IF count == 0 %]
|
||||
[% IF activetab == "comments" %]
|
||||
$("#bibliodetails a[href='#comments_panel']").tab("show");
|
||||
[% ELSIF count == 0 %]
|
||||
[% IF ( Koha.Preference('HTML5MediaEnabled') == 'staff' or Koha.Preference('HTML5MediaEnabled') == 'both' ) && HTML5MediaSets.size %]
|
||||
$("#bibliodetails a[href='#html5media_panel']").tab("show");
|
||||
[% ELSIF ComponentParts && ComponentParts.size %]
|
||||
|
@ -1927,6 +2010,14 @@
|
|||
}));
|
||||
[% END %]
|
||||
|
||||
[% IF ( reviews ) %]
|
||||
var comment_table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail', 'comments-table', 'json') | $raw %];
|
||||
var comments_table = KohaTable("comments_table", {
|
||||
"paginate": false,
|
||||
"autoWidth": false,
|
||||
"order": [[ 2, "desc" ]],
|
||||
}, comment_table_settings);
|
||||
[% END %]
|
||||
});
|
||||
|
||||
[% IF found1 && Koha.Preference('RetainCatalogSearchTerms') %]
|
||||
|
@ -2176,8 +2267,13 @@
|
|||
|
||||
$('#modal-item-group-unset').modal('hide');
|
||||
});
|
||||
|
||||
[% END # /IF EnableItemGroups %]
|
||||
|
||||
$(".delete-comment").on("click", function(){
|
||||
return confirm( _("Are you sure you want to delete this comment?") );
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
[%# The following PROCESS needs: %]
|
||||
|
|
|
@ -41,6 +41,7 @@ my $reviewid = $query->param('reviewid');
|
|||
my $page = $query->param('page') || 1;
|
||||
my $count = C4::Context->preference('numSearchResults') || 20;
|
||||
my $total = Koha::Reviews->search_limited({ approved => $status })->count;
|
||||
my $biblionumber = $query->param('biblionumber');
|
||||
|
||||
if ( $op eq 'cud-approve' ) {
|
||||
my $review = Koha::Reviews->find( $reviewid );
|
||||
|
@ -55,6 +56,11 @@ elsif ( $op eq 'cud-delete' ) {
|
|||
$review->delete if $review;
|
||||
}
|
||||
|
||||
if ( $op && $biblionumber ) {
|
||||
print scalar $query->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber&activetab=comments");
|
||||
exit; # You can only send 1 redirect! After that, content or other headers don't matter.
|
||||
}
|
||||
|
||||
my $reviews = Koha::Reviews->search_limited(
|
||||
{ approved => $status },
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue