https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29168

--- Comment #23 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
Created attachment 202849
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202849&action=edit
Bug 29168: Disable 'Request article' link when patron has reached the limit

Stash patron_can_request_article in get_template_and_user so all OPAC
pages get it for free. The two template includes that render the
'Request article' link (opac-detail-sidebar.inc and
title-actions-menu.inc) now check this variable.

When the patron has reached their limit, the link is shown disabled
with a tooltip ('You have reached your open article requests limit.')
rather than hidden entirely. The disabled state only shows when circ
rules would otherwise allow the request (artreqpossible is truthy) —
if circ rules say 'no' for this patron category/itemtype, no link is
shown at all.

Template logic (both includes):
  artreqpossible (circ rules allow) AND patron_can_request_article
    → active link
  artreqpossible (circ rules allow) AND NOT patron_can_request_article
    → disabled link with tooltip
  NOT artreqpossible (circ rules deny)
    → no link

Note: artreqpossible is computed per-biblio by each script. On search
results it uses guess_article_requestable_itemtypes (itemtype-only,
category-agnostic), while detail pages use can_article_request($patron)
which is patron-category-aware. This means a record might show a
disabled link in search results but no link at all on the detail page
if the patron's category doesn't match the circ rules. This is a
pre-existing inconsistency unrelated to this patch.

The server-side check in opac-request-article.pl remains as a fallback
for bookmarked/direct URLs.

Community poll result: 5 votes for disabled+tooltip, 2 for hiding.

The check runs once per request in C4::Auth, gated on the
ArticleRequests syspref being enabled and a patron being logged in.
Defaults to 1 for anonymous sessions so the link remains active and
redirects to login on click.

Test plan:
1. Apply patch
2. ktd --name bug29168 --shell
   k$ restart_all
3. Enable ArticleRequests syspref
4. Set article request limit to 1:
   Administration > Circulation and fine rules >
   Default open article requests limit > All > Total: 1 > Add
5. Ensure the 'All' circ rule has article_requests set to 'yes'
   (Default checkout, hold and return policy > Article requests > Yes)
6. Place an article request for a patron via the staff interface
7. Log in as that patron in the OPAC
8. Look at a record detail page
=> SUCCESS: 'Request article' link is disabled with tooltip
9. Search for records
=> SUCCESS: 'Request article' link is disabled in search results
10. Hover over the disabled link
=> SUCCESS: Tooltip says 'You have reached your open article requests limit.'
11. Log out of the OPAC
12. Look at same detail page and search results
=> SUCCESS: 'Request article' link is active (anonymous user)
13. Delete the article request via staff interface
14. Log back in as the patron, refresh the OPAC detail page
=> SUCCESS: 'Request article' link is active again
15. Sign off :-D

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to