Lines 54-61
$patron->delete
Link Here
|
54 |
|
54 |
|
55 |
Delete patron's holds, lists and finally the patron. |
55 |
Delete patron's holds, lists and finally the patron. |
56 |
|
56 |
|
57 |
Lists owned by the borrower are deleted, but entries from the borrower to |
57 |
Lists owned by the borrower are deleted or ownership is transfered depending on the |
58 |
other lists are kept. |
58 |
ListOwnershipUponPatronDeletion pref, but entries from the borrower to other lists are kept. |
59 |
|
59 |
|
60 |
=cut |
60 |
=cut |
61 |
|
61 |
|
Lines 68-88
sub delete {
Link Here
|
68 |
# Delete Patron's holds |
68 |
# Delete Patron's holds |
69 |
$self->holds->delete; |
69 |
$self->holds->delete; |
70 |
|
70 |
|
71 |
# Delete all lists and all shares of this borrower |
71 |
# If ListOwnershipUponPatronDeletion = transfer, change ownership of all |
72 |
# Consistent with the approach Koha uses on deleting individual lists |
72 |
# public and shared lists to the user who deleted them. |
73 |
# Note that entries in virtualshelfcontents added by this borrower to |
73 |
if ( C4::Context->preference('ListOwnershipUponPatronDeletion') eq 'transfer' ) { |
74 |
# lists of others will be handled by a table constraint: the borrower |
74 |
my $userenv = C4::Context->userenv(); |
75 |
# is set to NULL in those entries. |
75 |
my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : 0; |
76 |
# NOTE: |
76 |
my @publiclists = Koha::Virtualshelves->get_public_shelves; |
77 |
# We could handle the above deletes via a constraint too. |
77 |
my @sharedlists = Koha::Virtualshelves->search({ 'me.owner' => $self->borrowernumber, 'me.shelfnumber' => { -ident => 'virtualshelfshares.shelfnumber' } }, { prefetch => 'virtualshelfshares' }); |
78 |
# But a new BZ report 11889 has been opened to discuss another approach. |
78 |
foreach my $plist ( @publiclists ) { |
79 |
# Instead of deleting we could also disown lists (based on a pref). |
79 |
$plist->set({ owner => $usernumber })->store; |
80 |
# In that way we could save shared and public lists. |
80 |
} |
81 |
# The current table constraints support that idea now. |
81 |
foreach my $slist ( @sharedlists ) { |
82 |
# This pref should then govern the results of other routines/methods such as |
82 |
$slist->set({ owner => $usernumber })->store; |
83 |
# Koha::Virtualshelf->new->delete too. |
83 |
} |
84 |
# FIXME Could be $patron->get_lists |
84 |
} |
85 |
$_->delete for Koha::Virtualshelves->search( { owner => $self->borrowernumber } ); |
85 |
|
|
|
86 |
# Delete any remaining lists that this user is an owner of (always private lists, |
87 |
# only public and shared lists if ListOwnershipUponPatronDeletion = delete) |
88 |
$_->delete for Koha::Virtualshelves->search({ owner => $self->borrowernumber }); |
86 |
|
89 |
|
87 |
$deleted = $self->SUPER::delete; |
90 |
$deleted = $self->SUPER::delete; |
88 |
|
91 |
|