From 85633155f48494c2495d4bf261c7f7f453399425 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 21 Jan 2016 12:37:41 +0000 Subject: [PATCH] Bug 15635: Koha::Patron::Images - Remove RmPatronImage The C4::Members::RmPatronImage just removed a row in patronimage. This can be accomplished using the delete method of Koha::Patron::Image. Test plan: From the patron defail page, try to delete the image of a patron. Signed-off-by: Josef Moravec Signed-off-by: Kyle M Hall Signed-off-by: Kyle M Hall --- C4/Members.pm | 21 --------------------- tools/picture-upload.pl | 9 ++++++--- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 220b1ef0b7..60a97f2d42 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -75,7 +75,6 @@ BEGIN { &GetTitles &GetPatronImage - &RmPatronImage &GetHideLostItemsPreference @@ -1849,26 +1848,6 @@ sub GetPatronImage { return $imagedata, $sth->errstr; } -=head2 RmPatronImage - - my ($dberror) = RmPatronImage($borrowernumber); - -Removes the image for the patron with the supplied borrowernumber. - -=cut - -sub RmPatronImage { - my ($borrowernumber) = @_; - warn "Borrowernumber passed to GetPatronImage is $borrowernumber" if $debug; - my $dbh = C4::Context->dbh; - my $query = "DELETE FROM patronimage WHERE borrowernumber = ?;"; - my $sth = $dbh->prepare($query); - $sth->execute($borrowernumber); - my $dberror = $sth->errstr; - warn "Database error!" if $sth->errstr; - return $dberror; -} - =head2 GetHideLostItemsPreference $hidelostitemspref = &GetHideLostItemsPreference($borrowernumber); diff --git a/tools/picture-upload.pl b/tools/picture-upload.pl index ea058dc021..d1d8ba7867 100755 --- a/tools/picture-upload.pl +++ b/tools/picture-upload.pl @@ -160,9 +160,12 @@ elsif ( ( $op eq 'Upload' ) && !$uploadfile ) { $template->param( filetype => $filetype ); } elsif ( $op eq 'Delete' ) { - my $dberror = RmPatronImage($borrowernumber); - $debug and warn "Patron image deleted for $borrowernumber"; - warn "Database returned $dberror" if $dberror; + my $deleted = eval { + Koha::Patron::Images->find( $borrowernumber )->delete; + }; + if ( $@ or not $deleted ) { + warn "Image for patron '$borrowernumber' has not been deleted"; + } } if ( $borrowernumber && !%errors && !$template->param('ERRORS') ) { print $input->redirect( -- 2.39.5