From d5ed74eb8d19c9bda719aa292dc992a3156ee066 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Fri, 26 Aug 2022 02:04:51 +0000 Subject: [PATCH] Bug 31333: (follow-up) Handle anonymous patrons making suggestions Test plan: 1. Enable AnonSuggestions syspref and set AnonymousPatron = 1 2. Visit the OPAC without logging in 3. Confirm you can successfully create a suggestion from: - Item detail page - Search result page - Masthead under the 'Library catalogue' search box 4. Disable the AnonSuggestions syspref 5. Confirm you cannot see links to make purchase suggestions on the following pages: - Item detail page - Search result page - Masthead under the 'Library catalogue' search box 6. Confirm if you try visiting /cgi-bin/koha/opac-suggestions.pl page you are re-directed to a login page Sponsored-by: Catalyst IT, New Zealand --- C4/Auth.pm | 4 +++- koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt | 2 +- opac/opac-suggestions.pl | 8 +++++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 612aeb4fe24..137b74943d6 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -501,7 +501,9 @@ sub get_template_and_user { # Decide if the patron can make suggestions in the OPAC my $can_make_suggestions; - if ( C4::Context->userenv && C4::Context->userenv->{'number'} ) { + if ( C4::Context->preference('Suggestion') && C4::Context->preference('AnonSuggestions') ) { + $can_make_suggestions = 1; + } elsif ( C4::Context->userenv && C4::Context->userenv->{'number'} ) { $can_make_suggestions = Koha::Patrons->find(C4::Context->userenv->{'number'})->category->can_make_suggestions; } diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index fbab4ec2c9b..c13f52f4dc3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -329,7 +329,7 @@ Browse search [% END %] - [% IF Koha.Preference( 'suggestion' ) == 1 %] + [% IF suggestion %] [% IF Koha.Preference( 'AnonSuggestions' ) == 1 || Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]