Bug 31333: (follow-up) Handle anonymous patrons making suggestions

Test plan:
1. Enable suggestion & AnonSuggestions sysprefs 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
7. Select the category of your user in the suggestionPatronCategoryExceptions syspref
8. Log into the OPAC
9. 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
- opac-user.pl ('Your summary') page
10. Confirm if you try visiting /cgi-bin/koha/opac-suggestions.pl page
you are re-directed to a 404 error page
11. Enable AnonSuggestions syspref
12. Confirm you can successfully create a suggestion from:
- Item detail page
- Search result page
- Masthead under the 'Library catalogue' search box
- opac-user.pl ('Your summary') page
13. Disable AnonSuggestions syspref and un-check your category from
suggestionPatronCategoryExeptions syspref
14. Confirm you can create a suggestion from:
- Item detail page
- Search result page
- Masthead under the 'Library catalogue' search box
- opac-user.pl ('Your summary') page

Sponsored-by: Catalyst IT, New Zealand

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Alex Buckley 2022-08-26 02:04:51 +00:00 committed by Tomas Cohen Arazi
parent 5f769adb34
commit 9c999293ef
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
4 changed files with 10 additions and 6 deletions

View File

@ -449,7 +449,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;
}

View File

@ -329,7 +329,7 @@
<a href="/cgi-bin/koha/opac-browse.pl">Browse search</a>
</li>
[% END %]
[% IF Koha.Preference( 'suggestion' ) == 1 %]
[% IF suggestion %]
[% IF Koha.Preference( 'AnonSuggestions' ) == 1 || Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
<li class="nav-item">
<a href="/cgi-bin/koha/opac-suggestions.pl?suggested_by_anyone=1">Purchase suggestions</a>

View File

@ -549,7 +549,7 @@
[% END # / IF total %]
[%# Display "Not finding what you're looking for" for suggestion or ILL %]
[% IF suggestion && ( Koha.Preference( 'AnonSuggestions' ) == 1 || loggedinusername ) || ( Koha.Preference( 'ILLModule' ) == 1 && loggedinusername ) %]
[% IF suggestion || ( Koha.Preference( 'ILLModule' ) == 1 && loggedinusername ) %]
<div class="suggestion">
Not finding what you're looking for?
<ul>

View File

@ -94,9 +94,11 @@ else {
}
# If suggestions are turned off, or this patron belongs to a category not allowed to make suggestions (suggestionPatronCategoryExceptions syspref) we redirect to 404 error. This will also redirect guest suggestions
if ( !Koha::Patrons->find( $borrowernumber )->category->can_make_suggestions ) {
print $input->redirect("/cgi-bin/koha/errors/404.pl");
exit;
if ( defined $borrowernumber && !C4::Context->preference('AnonSuggestions') ) {
if ( (!Koha::Patrons->find( $borrowernumber )->category->can_make_suggestions) ) {
print $input->redirect("/cgi-bin/koha/errors/404.pl");
exit;
}
}
my $suggested_by;