]> git.koha-community.org Git - koha.git/commit
Bug 24254: Add Koha::Items->filter_by_visible_in_opac
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 3 Dec 2020 18:11:14 +0000 (15:11 -0300)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 19 Jan 2021 07:44:34 +0000 (08:44 +0100)
commit2fbd16dbed45d630ec7ac5ac6c64f243aaa07c95
treeeddef53621500241c50793a239d58aff3861e7c4
parentf58377a659b38f0083c64cde6487d28936dd9aaa
Bug 24254: Add Koha::Items->filter_by_visible_in_opac

This patch adds a method based on the original idea from Nick, but on
Koha::Items.

The idea is to build a proper filter, based on the current rules for
hiding things, directly on the DBIC query. The caller takes care of
knowing if the filtering should apply (i.e. checking the patron category
exceptions) and then it would do something like:

    my @items;
    if ( <patron_category_does_not_have_exception> ) {
        @items = $biblio->items->filter_by_visible_in_opac(
            {
                rules => $rules
            }
        );
    }
    else {
        # still want to enforce 'hidelostitems'
        @items = $biblio->items->filter_by_visible_in_opac;
    }

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Items.t
=> SUCCESS: Tests pass!
3. Look at the use cases on the tests, read the code
=> SUCCESS: It all makes sense
4. Compare with Koha::Item->hidden_in_opac
=> SUCCESS: It all makes sense
5. 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: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 2250cf0293c690c6d1e79090aa3cec7b43cb2797)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Koha/Items.pm