Bug 40129 - Always show the "Not finding what you're looking for" links in opac-results.tt
Summary: Always show the "Not finding what you're looking for" links in opac-results.tt
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Paul Derscheid
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-12 08:59 UTC by Paul Derscheid
Modified: 2025-06-24 21:53 UTC (History)
2 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.11.00
Circulation function:


Attachments
Bug 40129: Always show the "Not finding what you're looking for" links in opac-results.tt (4.93 KB, patch)
2025-06-12 09:04 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 40129: Always show the "Not finding what you're looking for" links in opac-results.tt (5.08 KB, patch)
2025-06-24 12:17 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Derscheid 2025-06-12 08:59:30 UTC
I received the question why these links are not shown for unauthenticated users even though they'd trigger a login if necessary.

I agree that it could be beneficial to always allow for these links to be shown but I am interested in other opinions.
Comment 1 Paul Derscheid 2025-06-12 09:04:11 UTC
Created attachment 183191 [details] [review]
Bug 40129: Always show the "Not finding what you're looking for" links in opac-results.tt

This patch simplifies the logic for displaying the "make a purchase
suggestion" and "interlibrary loan request" links on the OPAC search results page.

Previously, the visibility of the purchase suggestion link was tied to a
complex set of conditions evaluated in C4/Auth.pm, involving user login status and
permissions. This was unintuitive, as the authorization to make a
suggestion should be handled by the suggestions page itself
(opac-suggestions.pl), I think.

This patch alters the template (opac-results.tt) to check the
'suggestion' and 'IllModule' system preferences directly. If suggestions are allowed
system-wide or the master switch for the 'IllModule' is on, the links will be shown
shown to all patrons, regardless of login status.

To test:
1. Go to Administration > System Preferences > OPAC.
2. Ensure 'Suggestion' is set to 'Enable'.
3. Log out of the OPAC if previously logged in.
4. Perform a search that won't yield any results and verify
   the "Make a purchase suggestion" link appears on the results page.
5. Click the link and verify that you are prompted to log in.
6. Now set the 'AnonSuggestions' system preference to 'Allow'.
7. Make sure that the 'AnonmousPatron' borrowernumber is set to
   something other than 0 (is this right, though)?
8. Click the link and verify that you are able to make an anonymous
   suggestion.
9. Log in as a patron who is NOT allowed to make suggestions (check their
   patron category permissions).
10. Perform a search and verify the link is still visible.
11. Here we then get a 404, this should be handled more gracefully, but
    still in opac-suggestions.pl to not make opac-results dependent on
    a patron object. Ideas very welcome!
11. Go back to System Preferences and set 'suggestion' to 'Don't allow'.
12. Refresh the OPAC search results page.
13. Verify the "Make a purchase suggestion" link is now hidden for both
   anonymous and logged-in users.
14. This confirms the link's visibility is controlled solely by the
    'suggestion' system preference.
15. Now the simpler aspect of 'IllModule', first set everything related
    to suggestions back to defaults. Then set 'IllModule' to 'Enable'.
16. Make sure the link to place an "interlibrary loan request" is now
    shown for unauthenticated patrons as well.
17. Leave some comments regarding the unsolved issue in 11) or other
    problems that you might anticipate through this change.

I first thought this was trivial, but it is not :_D!
Comment 2 Katrin Fischer 2025-06-16 09:16:18 UTC
I think always showing the links make sense.
Comment 3 Esther Melander 2025-06-18 18:25:05 UTC
Everything appeared to work. I also tested having both the purchase suggestion link and the ILL link enabled at the same time. The links worked as they should while logged in and logged out.

Signed off by: Esther Melander <esther@bywatersolutions.com>
Comment 4 Marcel de Rooy 2025-06-24 12:01:46 UTC
Just a dumb question:

+                    [% IF Koha.Preference( 'suggestion' ) || Koha.Preference( 'ILLModule' ) %]
-                                [% IF Koha.Preference( 'ILLModule' ) == 1 && ( loggedinusername || Koha.Preference( 'ILLOpacUnauthenticatedRequest' ) ) %]
+                                [% IF Koha.Preference( 'ILLModule' ) %]
                                     [% IF Koha.Preference( 'AutoILLBackendPriority' ) %]

Any reason to keep the BackendPriority here?
Comment 5 Marcel de Rooy 2025-06-24 12:17:23 UTC
Created attachment 183446 [details] [review]
Bug 40129: Always show the "Not finding what you're looking for" links in opac-results.tt

This patch simplifies the logic for displaying the "make a purchase
suggestion" and "interlibrary loan request" links on the OPAC search results page.

Previously, the visibility of the purchase suggestion link was tied to a
complex set of conditions evaluated in C4/Auth.pm, involving user login status and
permissions. This was unintuitive, as the authorization to make a
suggestion should be handled by the suggestions page itself
(opac-suggestions.pl), I think.

This patch alters the template (opac-results.tt) to check the
'suggestion' and 'IllModule' system preferences directly. If suggestions are allowed
system-wide or the master switch for the 'IllModule' is on, the links will be shown
shown to all patrons, regardless of login status.

To test:
1. Go to Administration > System Preferences > OPAC.
2. Ensure 'Suggestion' is set to 'Enable'.
3. Log out of the OPAC if previously logged in.
4. Perform a search that won't yield any results and verify
   the "Make a purchase suggestion" link appears on the results page.
5. Click the link and verify that you are prompted to log in.
6. Now set the 'AnonSuggestions' system preference to 'Allow'.
7. Make sure that the 'AnonmousPatron' borrowernumber is set to
   something other than 0 (is this right, though)?
8. Click the link and verify that you are able to make an anonymous
   suggestion.
9. Log in as a patron who is NOT allowed to make suggestions (check their
   patron category permissions).
10. Perform a search and verify the link is still visible.
11. Here we then get a 404, this should be handled more gracefully, but
    still in opac-suggestions.pl to not make opac-results dependent on
    a patron object. Ideas very welcome!
11. Go back to System Preferences and set 'suggestion' to 'Don't allow'.
12. Refresh the OPAC search results page.
13. Verify the "Make a purchase suggestion" link is now hidden for both
   anonymous and logged-in users.
14. This confirms the link's visibility is controlled solely by the
    'suggestion' system preference.
15. Now the simpler aspect of 'IllModule', first set everything related
    to suggestions back to defaults. Then set 'IllModule' to 'Enable'.
16. Make sure the link to place an "interlibrary loan request" is now
    shown for unauthenticated patrons as well.
17. Leave some comments regarding the unsolved issue in 11) or other
    problems that you might anticipate through this change.

I first thought this was trivial, but it is not :_D!

Signed off by: Esther Melander <esther@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 6 Marcel de Rooy 2025-06-24 12:18:05 UTC
(In reply to Marcel de Rooy from comment #4)
> Just a dumb question:
> 
> +                    [% IF Koha.Preference( 'suggestion' ) ||
> Koha.Preference( 'ILLModule' ) %]
> -                                [% IF Koha.Preference( 'ILLModule' ) == 1
> && ( loggedinusername || Koha.Preference( 'ILLOpacUnauthenticatedRequest' )
> ) %]
> +                                [% IF Koha.Preference( 'ILLModule' ) %]
>                                      [% IF Koha.Preference(
> 'AutoILLBackendPriority' ) %]
> 
> Any reason to keep the BackendPriority here?

Reading the context in the template answered my question..
Comment 7 Lucas Gass (lukeg) 2025-06-24 21:53:08 UTC
Nice work everyone!

Pushed to main for 25.11