Lines 352-359
$patron->delete
Link Here
|
352 |
|
352 |
|
353 |
Delete patron's holds, lists and finally the patron. |
353 |
Delete patron's holds, lists and finally the patron. |
354 |
|
354 |
|
355 |
Lists owned by the borrower are deleted, but entries from the borrower to |
355 |
Lists owned by the borrower are deleted or ownership is transfered depending on the |
356 |
other lists are kept. |
356 |
ListOwnershipUponPatronDeletion pref, but entries from the borrower to other lists are kept. |
357 |
|
357 |
|
358 |
=cut |
358 |
=cut |
359 |
|
359 |
|
Lines 368-388
sub delete {
Link Here
|
368 |
$hold->cancel; |
368 |
$hold->cancel; |
369 |
} |
369 |
} |
370 |
|
370 |
|
371 |
# Delete all lists and all shares of this borrower |
371 |
# If ListOwnershipUponPatronDeletion = transfer, change ownership of all |
372 |
# Consistent with the approach Koha uses on deleting individual lists |
372 |
# public and shared lists to the user who deleted them. |
373 |
# Note that entries in virtualshelfcontents added by this borrower to |
373 |
if ( C4::Context->preference('ListOwnershipUponPatronDeletion') eq 'transfer' ) { |
374 |
# lists of others will be handled by a table constraint: the borrower |
374 |
my $userenv = C4::Context->userenv(); |
375 |
# is set to NULL in those entries. |
375 |
my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : 0; |
376 |
# NOTE: |
376 |
my @publiclists = Koha::Virtualshelves->get_public_shelves; |
377 |
# We could handle the above deletes via a constraint too. |
377 |
my @sharedlists = Koha::Virtualshelves->search({ 'me.owner' => $self->borrowernumber, 'me.shelfnumber' => { -ident => 'virtualshelfshares.shelfnumber' } }, { prefetch => 'virtualshelfshares' }); |
378 |
# But a new BZ report 11889 has been opened to discuss another approach. |
378 |
foreach my $plist ( @publiclists ) { |
379 |
# Instead of deleting we could also disown lists (based on a pref). |
379 |
$plist->set({ owner => $usernumber })->store; |
380 |
# In that way we could save shared and public lists. |
380 |
} |
381 |
# The current table constraints support that idea now. |
381 |
foreach my $slist ( @sharedlists ) { |
382 |
# This pref should then govern the results of other routines/methods such as |
382 |
$slist->set({ owner => $usernumber })->store; |
383 |
# Koha::Virtualshelf->new->delete too. |
383 |
} |
384 |
# FIXME Could be $patron->get_lists |
384 |
} |
385 |
$_->delete for Koha::Virtualshelves->search( { owner => $self->borrowernumber } ); |
385 |
|
|
|
386 |
# Delete any remaining lists that this user is an owner of (always private lists, |
387 |
# only public and shared lists if ListOwnershipUponPatronDeletion = delete) |
388 |
$_->delete for Koha::Virtualshelves->search({ owner => $self->borrowernumber }); |
386 |
|
389 |
|
387 |
# We cannot have a FK on borrower_modifications.borrowernumber, the table is also used |
390 |
# We cannot have a FK on borrower_modifications.borrowernumber, the table is also used |
388 |
# for patron selfreg |
391 |
# for patron selfreg |