From 495c98466d2c05e900bd2fe4c5f81783cae71aa4 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Thu, 14 Oct 2021 09:57:15 -0400 Subject: [PATCH] Bug 20813: Remove flags references from Patron.pm, fix method has_permission --- Koha/Patron.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 731acdc03c4..9c736e213e3 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1671,7 +1671,7 @@ sub anonymize { split /\s*\|\s*/, C4::Context->preference('BorrowerMandatoryField') }; $mandatory->{userid} = 1; # needed since sub store does not clear field my @columns = $self->_result->result_source->columns; - @columns = grep { !/borrowernumber|branchcode|categorycode|^date|password|flags|updated_on|lastseen|lang|login_attempts|anonymized/ } @columns; + @columns = grep { !/borrowernumber|branchcode|categorycode|^date|password|updated_on|lastseen|lang|login_attempts|anonymized/ } @columns; push @columns, 'dateofbirth'; # add this date back in foreach my $col (@columns) { $self->_anonymize_column($col, $mandatory->{lc $col} ); @@ -1796,7 +1796,6 @@ sub to_api_mapping { debarred => undef, # replaced by 'restricted' debarredcomment => undef, # calculated, API consumers will use /restrictions instead emailpro => 'secondary_email', - flags => undef, # permissions manipulation handled in /permissions gonenoaddress => 'incorrect_address', guarantorid => 'guarantor_id', lastseen => 'last_seen', @@ -1913,6 +1912,7 @@ sub queue_notice { =head3 has_permission +my $bool = $patron->has_permission( { $top_level_perm => $sub_perm } ); my $bool = $patron->has_permission( $permission_code ); =cut @@ -1920,12 +1920,17 @@ my $bool = $patron->has_permission( $permission_code ); sub has_permission { my ( $self, $code ) = @_; - return Koha::Patron::Permissions->find( + if ( ref $code eq 'HASH' ) { + my ( $pri, $sec ) = %$code; + $code = $sec eq '1' ? $pri : { '-in' => [ $pri, $sec ] }; + } + + return Koha::Patron::Permissions->search( { borrowernumber => $self->id, code => $code, } - ) ? 1 : 0; + )->count; } =head3 set_permissions -- 2.30.2