3 # Copyright ByWater Solutions 2014
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 use base qw(Koha::Objects);
32 Koha::Items - Koha Item object set class
40 =head3 filter_by_visible_in_opac
42 my $filered_items = $items->filter_by_visible_in_opac(
48 Returns a new resultset, containing those items that are not expected to be hidden in OPAC
49 for the passed I<Koha::Patron> object that is passed.
51 The I<OpacHiddenItems>, I<hidelostitems> and I<OpacHiddenItemsExceptions> system preferences
56 sub filter_by_visible_in_opac {
57 my ($self, $params) = @_;
59 my $patron = $params->{patron};
63 # Filter out OpacHiddenItems unless disabled by OpacHiddenItemsExceptions
64 unless ( $patron and $patron->category->override_hidden_items ) {
65 my $rules = C4::Context->yaml_preference('OpacHiddenItems') // {};
68 foreach my $field ( keys %$rules ) {
69 $rules_params->{$field} =
70 [ { '-not_in' => $rules->{$field} }, undef ];
73 $result = $result->search( $rules_params );
76 if (C4::Context->preference('hidelostitems')) {
77 $result = $result->filter_out_lost;
83 =head3 filter_out_lost
85 my $filered_items = $items->filter_out_lost;
87 Returns a new resultset, containing those items that are not marked as lost.
94 my $params = { itemlost => 0 };
96 return $self->search( $params );
99 =head2 Internal methods
119 Kyle M Hall <kyle@bywatersolutions.com>
120 Tomas Cohen Arazi <tomascohen@theke.io>
121 Martin Renvoize <martin.renvoize@ptfs-europe.com>