From 2a26ca7a4d7cd3a8087f05e2b901ed67a6238ae1 Mon Sep 17 00:00:00 2001 From: Victor Grousset Date: Fri, 15 Dec 2017 15:22:24 +0100 Subject: [PATCH] Bug 19808: Handle deleted reviewers gracefully - opac-detail And other display issues when the patron was NULL. Which allows to keep the review even if it has no patron. Because it might be useful. For example when disconnected, the borrowernumber is null. So the comments from deleted patrons were displayed as if the disconnected user wrote them. So it had the edit button... And fix borrowernumber not being passed to the template when OpacStarRatings was false. Test plan 1. Log in as a patron 2. Leave a comment/review on a record 3. Librarian: approve this comment 4. Delete the borrower 5. See the record (opac:/cgi-bin/koha/opac-detail.pl?biblionumber=RELEVANT_BIB_NUMBER) 6. Then you should see an error 7. Apply this patch 8. Refresh the page 9. Then you should see the record page with the comment Signed-off-by: Mark Tompsett Signed-off-by: Jon Knight Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens --- .../bootstrap/en/modules/opac-detail.tt | 20 ++++++++++--------- opac/opac-detail.pl | 14 +++++-------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 74f8578f9e..c4a697502a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -905,7 +905,7 @@
[% IF ( reviews ) %] [% FOREACH review IN reviews %] - [% IF review.borrowernumber == borrowernumber %] + [% IF borrowernumber && review.borrowernumber == borrowernumber %]
[% IF ( review.avatarurl ) %] @@ -925,26 +925,28 @@
[% ELSE %]
- [% IF ( ShowReviewer != "none" ) %] + [% IF ( ShowReviewer != "none" && review.patron) %] + [% IF ( review.avatarurl ) %] [% END %] [% SWITCH ShowReviewer %] [% CASE 'full' %] -
Comment by [% review.title %] [% review.firstname %] [% review.surname %]
+
Comment by [% review.patron.title %] [% review.patron.firstname %] [% review.patron.surname %]
[% CASE 'first' %] -
Comment by [% review.firstname %]
+
Comment by [% review.patron.firstname %]
[% CASE 'surname' %] -
Comment by [% review.surname %]
+
Comment by [% review.patron.surname %]
[% CASE 'firstandinitial' %] -
Comment by [% review.firstname %] [% review.surname|truncate(2,'.') %]
+
Comment by [% review.patron.firstname %] [% review.patron.surname|truncate(2,'.') %]
[% CASE 'username' %] -
Comment by [% review.userid %]
+
Comment by [% review.patron.userid %]
[% END %] + [% review.datereviewed | $KohaDates %] - [% ELSIF ( ShowReviewer == "none") %] + [% ELSE %]
Patron comment on [% review.datereviewed | $KohaDates %]
- [% END # / IF ShowReviewer != "none"%] + [% END # / IF ShowReviewer != "none" && review.patron %]

[% FILTER html_break %] [% review.review |html %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 2e4afdd0a4..9b75015303 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -845,17 +845,12 @@ if ( C4::Context->preference('reviewson') ) { my $patron = Koha::Patrons->find( $review->{borrowernumber} ); # setting some borrower info into this hash - $review->{title} = $patron->title; - $review->{surname} = $patron->surname; - $review->{firstname} = $patron->firstname; - if ( $libravatar_enabled and $patron->email ) { + $review->{patron} = $patron; + if ( $libravatar_enabled and $patron and $patron->email ) { $review->{avatarurl} = libravatar_url( email => $patron->email, https => $ENV{HTTPS} ); } - $review->{userid} = $patron->userid; - $review->{cardnumber} = $patron->cardnumber; - if ( $patron->borrowernumber eq $borrowernumber ) { - $review->{your_comment} = 1; + if ( $patron and $patron->borrowernumber eq $borrowernumber ) { $loggedincommenter = 1; } } @@ -1103,13 +1098,14 @@ if (C4::Context->preference("OPACURLOpenInNewWindow")) { $template->param(covernewwindow => 'false'); } +$template->param(borrowernumber => $borrowernumber); + if ( C4::Context->preference('OpacStarRatings') !~ /disable/ ) { my $ratings = Koha::Ratings->search({ biblionumber => $biblionumber }); my $my_rating = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef; $template->param( ratings => $ratings, my_rating => $my_rating, - borrowernumber => $borrowernumber ); } -- 2.39.5