From a818ec73ebfc8785eb34bc939ac3d4ecc1d7194a Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 17 Feb 2025 10:20:11 +0000 Subject: [PATCH] Bug 39145: Apply new pref values to ->disown_or_delete Test plan: Set ListOwnershipUponPatronDeletion to 'change owner of these lists'. Create a public list1 and a private list2 for patron A. Enable sharing lists and share list2 with another patron. Remove patron A. Check that list1 and list2 are transferred. Set ListOwnershipUponPatronDeletion to 'change owner of public lists, delete shared lists'. Create a public list3 and a private list4 for patron B. Share list4 with another patron. Remove patron B. Check that list3 is transferred and list4 is deleted. Signed-off-by: Marcel de Rooy Signed-off-by: David Nind Signed-off-by: Martin Renvoize --- Koha/Virtualshelves.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm index d0c9a923d34..366f67ecb48 100644 --- a/Koha/Virtualshelves.pm +++ b/Koha/Virtualshelves.pm @@ -45,9 +45,10 @@ just delete them if not possible. sub disown_or_delete { my ($self) = @_; + my $list_pref = C4::Context->preference('ListOwnershipUponPatronDeletion'); $self->_resultset->result_source->schema->txn_do( sub { - if ( C4::Context->preference('ListOwnershipUponPatronDeletion') eq 'transfer' ) { + if ( $list_pref ne 'delete' ) { # transfer or transfer_public my $new_owner; $new_owner = C4::Context->preference('ListOwnerDesignated') @@ -59,9 +60,11 @@ sub disown_or_delete { } while ( my $list = $self->next ) { - if ( $new_owner && ( $list->is_public or $list->is_shared ) ) { + if ( $new_owner && $list->is_public ) { $list->transfer_ownership($new_owner); - } else { + } elsif ( $new_owner && $list->is_shared && $list_pref eq 'transfer' ) { + $list->transfer_ownership($new_owner); + } else { # private list, or shared list with transfer_public $list->delete; } } -- 2.51.0