Bug 16699: Remove requirement from borrowernumberQueryParam
[koha.git] / Koha / Patron / Modification.pm
blob54071723a64f34dd463456f5a935798727093d50
1 package Koha::Patron::Modification;
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
10 # version.
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.
20 use Modern::Perl;
22 use Carp;
24 use Koha::Database;
26 use base qw(Koha::Object);
28 =head1 NAME
30 Koha::Patron::Modification - Class represents a request to modify or create a patron
32 =head2 Class Methods
34 =cut
36 =head2 approve
38 $m->approve();
40 Commits the pending modifications to the borrower record and removes
41 them from the modifications table.
43 =cut
45 sub approve {
46 my ($self) = @_;
48 my $data = $self->unblessed();
50 delete $data->{timestamp};
51 delete $data->{verification_token};
53 foreach my $key ( keys %$data ) {
54 delete $data->{$key} unless ( defined( $data->{$key} ) );
57 my $patron = Koha::Patrons->find( $self->borrowernumber );
59 return unless $patron;
61 $patron->set($data);
63 if ( $patron->store() ) {
64 return $self->delete();
68 =head3 type
70 =cut
72 sub _type {
73 return 'BorrowerModification';
76 =head1 AUTHOR
78 Kyle M Hall <kyle@bywatersolutions.com>
80 =cut