From 94513d0739757f0c5db4b7d1040aaae40622a60e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 10 Jul 2017 14:18:12 -0300 Subject: [PATCH] Bug 17829: Update CanUserManageBasket to fix tests Signed-off-by: Jonathan Druart --- C4/Acquisition.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index ee382853aa..346fb4546c 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -823,7 +823,10 @@ sub CanUserManageBasket { my ($borrower, $basket, $userflags) = @_; if (!ref $borrower) { - $borrower = Koha::Patrons->find( $borrower ); + # FIXME This needs to be replaced + # We should not accept both scalar and array + # Tests need to be updated + $borrower = Koha::Patrons->find( $borrower )->unblessed; } if (!ref $basket) { $basket = GetBasket($basket); @@ -831,7 +834,7 @@ sub CanUserManageBasket { return 0 unless ($basket and $borrower); - my $borrowernumber = $borrower->borrowernumber; + my $borrowernumber = $borrower->{borrowernumber}; my $basketno = $basket->{basketno}; my $AcqViewBaskets = C4::Context->preference('AcqViewBaskets'); @@ -843,7 +846,7 @@ sub CanUserManageBasket { my ($flags) = $sth->fetchrow_array; $sth->finish; - $userflags = C4::Auth::getuserflags($flags, $borrower->userid, $dbh); + $userflags = C4::Auth::getuserflags($flags, $borrower->{userid}, $dbh); } unless ($userflags->{superlibrarian} @@ -866,7 +869,7 @@ sub CanUserManageBasket { } if ($AcqViewBaskets eq 'branch' && defined $basket->{branch} - && $basket->{branch} ne $borrower->branchcode) { + && $basket->{branch} ne $borrower->{branchcode}) { return 0; } } -- 2.39.5