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

--- Comment #9 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
Created attachment 205892
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205892&action=edit
Bug 17921: Make the OPAC shelf browser respect OpacHiddenItems and
OpacSuppression

The shelf browser (C4::ShelfBrowser::GetNearbyItems) built raw SQL against the
items table and applied no OPAC visibility rules. As a result, items matching
OpacHiddenItems, and items belonging to records suppressed via OpacSuppression,
were displayed in the shelf browser. The links were blocked (opac-blocked or
404), but the items should not have been shown at all.

This patch rewrites GetNearbyItems to build the previous/next neighbour windows
using Koha::Items resultsets, so the visibility filtering is composed at the
Koha::Objects level:

- filter_by_visible_in_opac({ patron => $patron }) for OpacHiddenItems,
  OpacHiddenItemsExceptions and hidelostitems
- filter_by_not_suppressed for OpacSuppression, only when suppression is in
  effect for the current request (C4::Context->is_opac_suppressed)

Filters are applied before the neighbour window is sliced, so hidden and
suppressed items are never shown as items nor used as previous/next boundary
markers. The logged-in patron is now passed in from opac-detail.pl and
svc/shelfbrowser.pl so category exceptions are honoured.

Test plan:
1. Have OPACShelfBrowser enabled
2. Set OpacHiddenItems to hide some items, enable OpacSuppression and suppress
   a record whose items are shelved near a visible one
3. Open the OPAC detail page for a nearby visible item and open the shelf
   browser
=> FAIL: hidden and suppressed items are displayed in the shelf browser
4. Apply this patch, repeat from step 3
=> SUCCESS: hidden and suppressed items no longer appear
5. Run:
   $ ktd --shell
  k$ prove t/db_dependent/ShelfBrowser.t
=> SUCCESS: Tests pass!
6. 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