Bug 6298 : Hide avatars when ShowReviewer is off
authorFrancois Marier <francois@debian.org>
Fri, 6 May 2011 14:00:51 +0000 (10:00 -0400)
committerChris Cormack <chrisc@catalyst.net.nz>
Tue, 5 Jul 2011 03:01:12 +0000 (15:01 +1200)
As suggested by Nicole, when a library hides the names of the
reviewers, they probably don't want to show their faces.

The OPAC detail page was already hiding these avatars but this
change also prevents Koha from looking for these avatars (which
could incur DNS queries) if they're not going to be displayed.

Signed-off-by: Francois Marier <francois@debian.org>
Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
opac/opac-detail.pl
opac/opac-showreviews.pl

index 0510917..4260ca5 100755 (executable)
@@ -295,11 +295,10 @@ $template->param(
     ocoins => GetCOinSBiblio($biblionumber),
 );
 
-my $libravatar_available = 0;
-
+my $libravatar_enabled = 0;
 eval 'use Libravatar::URL';
-if (! $@) {
-    $libravatar_available = 1;
+if (!$@ and C4::Context->preference('ShowReviewer')) {
+    $libravatar_enabled = 1;
 }
 
 my $reviews = getreviews( $biblionumber, 1 );
@@ -310,7 +309,7 @@ foreach ( @$reviews ) {
     $_->{title}     = $borrowerData->{'title'};
     $_->{surname}   = $borrowerData->{'surname'};
     $_->{firstname} = $borrowerData->{'firstname'};
-    if ($libravatar_available and $borrowerData->{'email'}) {
+    if ($libravatar_enabled and $borrowerData->{'email'}) {
         $_->{avatarurl} = libravatar_url(email => $borrowerData->{'email'}, https => $ENV{HTTPS});
     }
     $_->{userid}    = $borrowerData->{'userid'};
index fbce8a2..7b7fddb 100755 (executable)
@@ -65,11 +65,10 @@ if($format eq "rss"){
         );
 }
 
-my $libravatar_available = 0;
-
+my $libravatar_enabled = 0;
 eval 'use Libravatar::URL';
-if (! $@) {
-    $libravatar_available = 1;
+if (!$@ and C4::Context->preference('ShowReviewer')) {
+    $libravatar_enabled = 1;
 }
 
 my $reviews = getallreviews(1,$offset,$results_per_page);
@@ -99,7 +98,7 @@ for my $result (@$reviews){
        $result->{timestamp} = $bib->{'timestamp'};
        $result->{firstname} = $borr->{'firstname'};
        $result->{surname} = $borr->{'surname'};
-        if ($libravatar_available and $borr->{'email'}) {
+        if ($libravatar_enabled and $borr->{'email'}) {
             $result->{avatarurl} = libravatar_url(email => $borr->{'email'}, size => 40, https => $ENV{HTTPS});
         }