Bugzilla – Attachment 167674 Details for
Bug 2486
Show user comments in staff interface
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 2486: Show user comments in staff interface
Bug-2486-Show-user-comments-in-staff-interface.patch (text/plain), 15.66 KB, created by
Owen Leonard
on 2024-06-12 19:07:49 UTC
(
hide
)
Description:
Bug 2486: Show user comments in staff interface
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2024-06-12 19:07:49 UTC
Size:
15.66 KB
patch
obsolete
>From bb67514903426290cb7a349c9e0bb040393aaab9 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 12 Jun 2024 12:54:47 +0000 >Subject: [PATCH] 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 >--- > admin/columns_settings.yml | 15 +++ > catalogue/detail.pl | 39 ++++++- > .../prog/css/src/staff-global.scss | 9 ++ > .../prog/en/modules/catalogue/detail.tt | 102 +++++++++++++++++- > reviews/reviewswaiting.pl | 6 ++ > 5 files changed, 167 insertions(+), 4 deletions(-) > >diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml >index 66586cef07..0e7ed48d4e 100644 >--- a/admin/columns_settings.yml >+++ b/admin/columns_settings.yml >@@ -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: >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 9a1306cf05..45d62a1410 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -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->{$_} : '' ); >diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >index f63558b8fb..763158e606 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -2817,6 +2817,15 @@ fieldset > .toptabs { > font-style: italic; > } > >+.commentline { >+ border-bottom: 1px solid #CCC; >+ >+ .btn-toolbar { >+ margin-bottom: 0; >+ margin-left: 0; >+ } >+} >+ > .contents { > width: 75%; > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index c50b09225a..c2331c5513 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -51,7 +51,6 @@ > [% END %] > > <body id="catalog_detail" class="catalog"> >- > [% WRAPPER 'header.inc' %] > [% INCLUDE 'cat-search.inc' %] > [% END %] >@@ -384,6 +383,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> >@@ -840,6 +845,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> >@@ -850,7 +931,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 %] > >@@ -1439,7 +1520,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 %] >@@ -1925,6 +2008,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') %] >@@ -2174,8 +2265,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: %] >diff --git a/reviews/reviewswaiting.pl b/reviews/reviewswaiting.pl >index b17dc8b9e1..1954482c0d 100755 >--- a/reviews/reviewswaiting.pl >+++ b/reviews/reviewswaiting.pl >@@ -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 }, > { >-- >2.39.2
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 2486
:
167674
|
167703
|
170093