Bug 31095: Remove GetDebarments from Koha::Patron::Debarments
This patch finally removes GetDebarments from the codebase. Test plan 1. Confirm GetDebarments is no longer mentioned in the codebase. `git grep GetDebarments` 2. Confirm t/db_dependent/Patron/Borrower_Debarments.t continues to pass Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
52c786205e
commit
7c1ffd2b11
|
|
@ -27,8 +27,6 @@ BEGIN {
|
|||
require Exporter;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT_OK = qw(
|
||||
GetDebarments
|
||||
|
||||
AddDebarment
|
||||
DelDebarment
|
||||
ModDebarment
|
||||
|
|
@ -45,28 +43,6 @@ Koha::Patron::Debarments - Module for managing patron debarments
|
|||
|
||||
=cut
|
||||
|
||||
=head2 GetDebarments
|
||||
|
||||
my $arrayref = GetDebarments({ borrowernumber => $borrowernumber [, key => $value ] );
|
||||
|
||||
=cut
|
||||
|
||||
sub GetDebarments {
|
||||
my ($params) = @_;
|
||||
|
||||
return unless ( $params->{'borrowernumber'} );
|
||||
|
||||
my @keys = keys %$params;
|
||||
my @values = values %$params;
|
||||
|
||||
my $where = join( ' AND ', map { "$_ = ?" } @keys );
|
||||
my $sql = "SELECT * FROM borrower_debarments WHERE $where";
|
||||
my $sth = C4::Context->dbh->prepare($sql);
|
||||
$sth->execute(@values);
|
||||
|
||||
return $sth->fetchall_arrayref( {} );
|
||||
}
|
||||
|
||||
=head2 AddDebarment
|
||||
|
||||
my $success = AddDebarment({
|
||||
|
|
@ -197,18 +173,22 @@ sub AddUniqueDebarment {
|
|||
|
||||
return unless ( $borrowernumber && $type );
|
||||
|
||||
my $debarment = @{ GetDebarments( { borrowernumber => $borrowernumber, type => $type } ) }[0];
|
||||
my $patron = Koha::Patrons->find($borrowernumber);
|
||||
return unless $patron;
|
||||
|
||||
my $debarment =
|
||||
$patron->restrictions->search( { type => $type }, { rows => 1 } )->single;
|
||||
|
||||
my $r;
|
||||
if ($debarment) {
|
||||
|
||||
# We don't want to shorten a unique debarment's period, so if this 'update' would do so, just keep the current expiration date instead
|
||||
$params->{'expiration'} = $debarment->{'expiration'}
|
||||
if ( $debarment->{'expiration'}
|
||||
&& $debarment->{'expiration'} gt $params->{'expiration'} );
|
||||
$params->{'expiration'} = $debarment->expiration
|
||||
if ( $debarment->expiration
|
||||
&& $debarment->expiration gt $params->{'expiration'} );
|
||||
|
||||
$params->{'borrower_debarment_id'} =
|
||||
$debarment->{'borrower_debarment_id'};
|
||||
$debarment->borrower_debarment_id;
|
||||
$r = ModDebarment($params);
|
||||
} else {
|
||||
|
||||
|
|
@ -242,11 +222,15 @@ sub DelUniqueDebarment {
|
|||
|
||||
return unless ( $borrowernumber && $type );
|
||||
|
||||
my $debarment = @{ GetDebarments( { borrowernumber => $borrowernumber, type => $type } ) }[0];
|
||||
my $patron = Koha::Patrons->find($borrowernumber);
|
||||
return unless $patron;
|
||||
|
||||
my $debarment =
|
||||
$patron->restrictions->search( { type => $type }, { rows => 1 } )->single;
|
||||
|
||||
return unless ( $debarment );
|
||||
|
||||
return DelDebarment( $debarment->{'borrower_debarment_id'} );
|
||||
return DelDebarment( $debarment->borrower_debarment_id );
|
||||
}
|
||||
|
||||
=head2 UpdateBorrowerDebarmentFlags
|
||||
|
|
|
|||
Loading…
Reference in New Issue