Bug 14708: Enforce restriction in delete_patrons.pl

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Kyle Hall 2019-02-27 12:00:03 -05:00 committed by Jonathan Druart
parent c1af56eb54
commit b0ce0d6463

View file

@ -94,6 +94,7 @@ unless ($confirm) {
say scalar(@$members) . " patrons to delete" if $verbose;; say scalar(@$members) . " patrons to delete" if $verbose;;
my $anonymous_patron = C4::Context->preference("AnonymousPatron");
my $deleted = 0; my $deleted = 0;
for my $member (@$members) { for my $member (@$members) {
print "Trying to delete patron $member->{borrowernumber}... " print "Trying to delete patron $member->{borrowernumber}... "
@ -110,6 +111,13 @@ for my $member (@$members) {
next; next;
} }
if ( $anonymous_patron ) {
if ( $patron->id eq $anonymous_patron ) {
say "Failed to delete patron $borrowernumber: patron is AnonymousPatron";
next;
}
}
if ( $confirm ) { if ( $confirm ) {
my $deleted = eval { $patron->move_to_deleted; }; my $deleted = eval { $patron->move_to_deleted; };
if ($@ or not $deleted) { if ($@ or not $deleted) {