Bug 24254: Implement separate filters and add patron param
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 21 Dec 2020 18:50:13 +0000 (15:50 -0300)
committerVictor Grousset/tuxayo <victor@tuxayo.net>
Mon, 1 Feb 2021 20:15:36 +0000 (21:15 +0100)
commit809b3308ef2e27076dd89e4e1d751ef27b525f9c
tree7ccdb97db8b91ac8b5b1efa870cc03be7c456f3b
parentf2872b7fa81f4ff78cde641918b0a63ef635984f
Bug 24254: Implement separate filters and add patron param

This patch introduces two new methods for stacking filters on
Koha::Items:

- filter_out_lost
_ filter_out_opachiddenitems

This two filters are what actually happened inside the
filter_by_visible_in_opac. Everything is covered by tests.

In the process I added a Koha::Patron param to the method that is
internally used to decide if the OPACHiddenItems syspref needs to be
honoured or not. This *could* be better done with a fallback to
C4::Context->userenv if no param is passed.

I decided to leave that part for later, if we really find it would help
(e.g. if bug 10589 gets some action and we really need something here to
 handle that).

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Items.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
(cherry picked from commit 172747f9adc0c39440dfe3f7930e2ad87b387d75)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Koha/Items.pm
t/db_dependent/Koha/Items.t