Bugzilla – Attachment 60306 Details for
Bug 11889
Option to keep public or shared lists when deleting patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11889: Disown a list upon deletion of owner
Bug-11889-Disown-a-list-upon-deletion-of-owner.patch (text/plain), 6.96 KB, created by
Marcel de Rooy
on 2017-02-16 09:41:15 UTC
(
hide
)
Description:
Bug 11889: Disown a list upon deletion of owner
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-02-16 09:41:15 UTC
Size:
6.96 KB
patch
obsolete
>From 57205d9a3bc96a48afa44a8b84b043ac147bb317 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 14 Feb 2017 22:56:31 +0000 >Subject: [PATCH] Bug 11889: Disown a list upon deletion of owner >Content-Type: text/plain; charset=utf-8 > >This patch adds a syspref 'ListOwnershipUponPatronDeletion' which >decides if all the owner's lists (public and private) are deleted >when the owner is deleted, or if the ownership of their public and >shared lists are transfered to the user who deleted the owner (private >lists that are not shared are always deleted). > >To test: >1) Apply patch and update database >2) Set the ListOwnershipUponPatronDeletion syspref to 'Transfer...' >3) Set up a superlibrarian user >4) Log in as this superlibrarian user and set up three lists, a public >list (maybe named 'public'), and two private lists (named 'private' and >'shared') >5) Log in as this user to the opac (if you haven't already) and share >the 'shared' list with someone >6) View the virtualshelves table in mysql to see the three lists you >just created under your new user >7) Also view the virtualshelfshares table in mysql to see the 'shared' >list >8) Log into the staff client with your regular user (a different user to >the one you just created) >9) Search for the user you just created and delete them >10) Go to your lists >11) You should see the 'shared' list under your private lists, and their >'public' list under your public lists, both with you as the owner >12) if you view both the virtualshelves table and the virtualshelfshares >table in mysql again, youll see you are now the owner and the 'private' >list will no longer exist. >13) Set the ListOwnershipUponPatronDeletion syspref back to 'Delete...' >14) Repeat steps 3 - 10 again (it may help to delete the 'shared' and >'public' lists before you re-create them) >15) You should not see any of the lists you just made under private or >public lists this time. To confirm, check the virtualshelves table in >mysql and make sure that all three lists have been deleted. > >Sponsored-by: Catalyst IT > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Patron.pm | 37 ++++++++++++---------- > ...add_ListOwnershipUponPatronDeletion_syspref.sql | 1 + > .../prog/en/modules/admin/preferences/patrons.pref | 6 ++++ > 3 files changed, 27 insertions(+), 17 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_11889_-_add_ListOwnershipUponPatronDeletion_syspref.sql > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 5a1fe47..d821f23 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -54,8 +54,8 @@ $patron->delete > > Delete patron's holds, lists and finally the patron. > >-Lists owned by the borrower are deleted, but entries from the borrower to >-other lists are kept. >+Lists owned by the borrower are deleted or ownership is transfered depending on the >+ListOwnershipUponPatronDeletion pref, but entries from the borrower to other lists are kept. > > =cut > >@@ -68,21 +68,24 @@ sub delete { > # Delete Patron's holds > $self->holds->delete; > >- # Delete all lists and all shares of this borrower >- # Consistent with the approach Koha uses on deleting individual lists >- # Note that entries in virtualshelfcontents added by this borrower to >- # lists of others will be handled by a table constraint: the borrower >- # is set to NULL in those entries. >- # NOTE: >- # We could handle the above deletes via a constraint too. >- # But a new BZ report 11889 has been opened to discuss another approach. >- # Instead of deleting we could also disown lists (based on a pref). >- # In that way we could save shared and public lists. >- # The current table constraints support that idea now. >- # This pref should then govern the results of other routines/methods such as >- # Koha::Virtualshelf->new->delete too. >- # FIXME Could be $patron->get_lists >- $_->delete for Koha::Virtualshelves->search( { owner => $self->borrowernumber } ); >+ # If ListOwnershipUponPatronDeletion = transfer, change ownership of all >+ # public and shared lists to the user who deleted them. >+ if ( C4::Context->preference('ListOwnershipUponPatronDeletion') eq 'transfer' ) { >+ my $userenv = C4::Context->userenv(); >+ my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : 0; >+ my @publiclists = Koha::Virtualshelves->get_public_shelves; >+ my @sharedlists = Koha::Virtualshelves->search({ 'me.owner' => $self->borrowernumber, 'me.shelfnumber' => { -ident => 'virtualshelfshares.shelfnumber' } }, { prefetch => 'virtualshelfshares' }); >+ foreach my $plist ( @publiclists ) { >+ $plist->set({ owner => $usernumber })->store; >+ } >+ foreach my $slist ( @sharedlists ) { >+ $slist->set({ owner => $usernumber })->store; >+ } >+ } >+ >+ # Delete any remaining lists that this user is an owner of (always private lists, >+ # only public and shared lists if ListOwnershipUponPatronDeletion = delete) >+ $_->delete for Koha::Virtualshelves->search({ owner => $self->borrowernumber }); > > $deleted = $self->SUPER::delete; > >diff --git a/installer/data/mysql/atomicupdate/bug_11889_-_add_ListOwnershipUponPatronDeletion_syspref.sql b/installer/data/mysql/atomicupdate/bug_11889_-_add_ListOwnershipUponPatronDeletion_syspref.sql >new file mode 100644 >index 0000000..4bdcb15 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_11889_-_add_ListOwnershipUponPatronDeletion_syspref.sql >@@ -0,0 +1 @@ >+INSERT INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`) VALUES ('ListOwnershipUponPatronDeletion', 'delete', 'delete|transfer', 'When deleting a patron who owns public lists, either delete the public lists or transfer ownership to the patron who deleted the owner', 'Choice'); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index e0e36d8..6dd01d8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -77,6 +77,12 @@ Patrons: > no: "Don't allow" > - "staff to access a patron's checkout history (reading history is still stored, regardless of staff being allowed access or not)." > - >+ - "When deleting a patron who owns public or shared lists," >+ - pref: ListOwnershipUponPatronDeletion >+ choices: >+ delete: "delete all of their public and shared lists." >+ transfer: "transfer ownership of their public and shared lists to the patron who deleted the owner." >+ - > - The late fine for all checkouts will only go up to > - pref: MaxFine > class: currency >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11889
:
25972
|
60224
|
60306
|
60307
|
60308
|
60481
|
61319
|
61320
|
61321
|
61322
|
61451
|
61452
|
61453
|
61454
|
108244
|
108245
|
108246
|
108247
|
135808
|
135809
|
135810
|
135811
|
135812
|
135813
|
135814
|
135815
|
135816
|
135817
|
135818
|
135819
|
135820
|
135821
|
135857
|
135858
|
135859
|
135860
|
135861
|
135862
|
135863
|
135864
|
135865
|
135866
|
135867
|
135868
|
135869
|
135870
|
135871
|
135872
|
135873
|
135874
|
135875
|
135876
|
135891
|
135892
|
135893
|
135894
|
135895
|
135896
|
135897
|
135898
|
135899
|
135900
|
135901