1 package Koha::Old::Holds;
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
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
26 use base qw(Koha::Holds);
30 Koha::Old::Holds - Koha Old Hold object set class
32 This object represents a set of holds that have been filled or canceled
38 =head3 filter_by_anonymizable
40 my $holds = $patron->old_holds;
41 my $anonymizable_holds = $holds->filter_by_anonymizable;
43 This method filters a I<Koha::Old::Holds> resultset, so it only contains holds that can be
44 anonymized given the patron privacy settings.
48 sub filter_by_anonymizable {
49 my ( $self, $params ) = @_;
51 my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef;
55 'me.borrowernumber' => { 'not' => undef },
56 'patron.privacy' => { '<>' => 0 },
59 ? ( 'me.borrowernumber' => { '!=' => $anonymous_patron } )
65 order_by => ['me.reserve_id'],
72 $patron->old_holds->anonymize();
74 Anonymize the given I<Koha::Old::Holds> resultset.
79 my ( $self, $params ) = @_;
81 my $anonymous_id = C4::Context->preference('AnonymousPatron');
83 Koha::Exceptions::SysPref::NotSet->throw( syspref => 'AnonymousPatron' )
86 return $self->update( { borrowernumber => $anonymous_id }, { no_triggers => 1 } );
89 =head2 Internal methods
104 return 'Koha::Old::Hold';
109 Kyle M Hall <kyle@bywatersolutions.com>