View | Details | Raw Unified | Return to bug 11889
Collapse All | Expand All

(-)a/Koha/Patron.pm (-17 / +20 lines)
Lines 369-376 $patron->delete Link Here
369
369
370
Delete patron's holds, lists and finally the patron.
370
Delete patron's holds, lists and finally the patron.
371
371
372
Lists owned by the borrower are deleted, but entries from the borrower to
372
Lists owned by the borrower are deleted or ownership is transfered depending on the
373
other lists are kept.
373
ListOwnershipUponPatronDeletion pref, but entries from the borrower to other lists are kept.
374
374
375
=cut
375
=cut
376
376
Lines 388-408 sub delete { Link Here
388
                $hold->cancel;
388
                $hold->cancel;
389
            }
389
            }
390
390
391
            # Delete all lists and all shares of this borrower
391
            # If ListOwnershipUponPatronDeletion = transfer, change ownership of all
392
            # Consistent with the approach Koha uses on deleting individual lists
392
            # public and shared lists to the user who deleted them.
393
            # Note that entries in virtualshelfcontents added by this borrower to
393
            if ( C4::Context->preference('ListOwnershipUponPatronDeletion') eq 'transfer' ) {
394
            # lists of others will be handled by a table constraint: the borrower
394
                my $userenv = C4::Context->userenv();
395
            # is set to NULL in those entries.
395
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : 0;
396
            # NOTE:
396
                my @publiclists = Koha::Virtualshelves->get_public_shelves;
397
            # We could handle the above deletes via a constraint too.
397
                my @sharedlists = Koha::Virtualshelves->search({ 'me.owner' => $self->borrowernumber, 'me.shelfnumber' => { -ident => 'virtualshelfshares.shelfnumber' }  }, { prefetch => 'virtualshelfshares' });
398
            # But a new BZ report 11889 has been opened to discuss another approach.
398
                foreach my $plist ( @publiclists ) {
399
            # Instead of deleting we could also disown lists (based on a pref).
399
                    $plist->set({ owner => $usernumber })->store;
400
            # In that way we could save shared and public lists.
400
                }
401
            # The current table constraints support that idea now.
401
                foreach my $slist ( @sharedlists ) {
402
            # This pref should then govern the results of other routines/methods such as
402
                    $slist->set({ owner => $usernumber })->store;
403
            # Koha::Virtualshelf->new->delete too.
403
                }
404
            # FIXME Could be $patron->get_lists
404
            }
405
            $_->delete for Koha::Virtualshelves->search( { owner => $self->borrowernumber } )->as_list;
405
406
            # Delete any remaining lists that this user is an owner of (always private lists,
407
            # only public and shared lists if ListOwnershipUponPatronDeletion = delete)
408
            $_->delete for Koha::Virtualshelves->search({ owner => $self->borrowernumber });
406
409
407
            # We cannot have a FK on borrower_modifications.borrowernumber, the table is also used
410
            # We cannot have a FK on borrower_modifications.borrowernumber, the table is also used
408
            # for patron selfreg
411
            # for patron selfreg
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +6 lines)
Lines 27-32 Patrons: Link Here
27
               1: "Allow"
27
               1: "Allow"
28
               0: "Don't allow"
28
               0: "Don't allow"
29
         - "staff to access a patron's checkout and hold history (checkout history is still stored, regardless of staff being allowed access or not)."
29
         - "staff to access a patron's checkout and hold history (checkout history is still stored, regardless of staff being allowed access or not)."
30
     -
31
         - "When deleting a patron who owns public or shared lists,"
32
         - pref: ListOwnershipUponPatronDeletion
33
           choices:
34
            delete: "delete all of their public and shared lists."
35
            transfer: "transfer ownership of their public and shared lists to the patron who deleted the owner."
30
     -
36
     -
31
         - The late fine for all checkouts will only go up to
37
         - The late fine for all checkouts will only go up to
32
         - pref: MaxFine
38
         - pref: MaxFine
33
- 

Return to bug 11889