Bugzilla – Attachment 7877 Details for
Bug 7310
Improving permissions on lists (virtual shelves)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7310: Improving list permissions: Deleting patron
Bug-7310-Improving-list-permissions-Deleting-patro.patch (text/plain), 4.85 KB, created by
Jared Camins-Esakov
on 2012-02-25 21:35:25 UTC
(
hide
)
Description:
Bug 7310: Improving list permissions: Deleting patron
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2012-02-25 21:35:25 UTC
Size:
4.85 KB
patch
obsolete
>From b6553a3c2456772a52c910f7bea49fde03cc94f9 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 13 Feb 2012 12:14:18 +0100 >Subject: [PATCH] Bug 7310: Improving list permissions: Deleting patron >Content-Type: text/plain; charset="UTF-8" > >Implements following points from the wiki page List permissions: >5) Delete or move list information when deleting a patron. > >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >--- > C4/VirtualShelves.pm | 40 ++++++++++++++++++++++++++++++++++++++-- > members/deletemem.pl | 2 ++ > tools/cleanborrowers.pl | 5 ++++- > 3 files changed, 44 insertions(+), 3 deletions(-) > >diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm >index 99c3f6f..5808269 100644 >--- a/C4/VirtualShelves.pm >+++ b/C4/VirtualShelves.pm >@@ -522,8 +522,10 @@ sub DelFromShelf { > } > } > if($del_oth) { >- $query = qq(DELETE FROM virtualshelfcontents >- WHERE shelfnumber=? AND biblionumber=? AND borrowernumber<>?); >+ #includes a check if borrowernumber is null (deleted patron) >+ $query = qq/DELETE FROM virtualshelfcontents >+ WHERE shelfnumber=? AND biblionumber=? AND >+ (borrowernumber IS NULL OR borrowernumber<>?)/; > $sth= $dbh->prepare($query); > foreach my $biblionumber (@$bibref) { > $sth->execute($shelfnumber, $biblionumber, $user); >@@ -591,6 +593,40 @@ sub ShelvesMax { > return SHELVES_MASTHEAD_MAX; > } > >+sub HandleDelBorrower { >+#when a member is deleted (DelMember in Members.pm), you should call me first >+#this routine deletes/moves lists and entries for the deleted member/borrower >+#you could just delete everything (and lose more than you want) >+#instead we now try to save all public/shared stuff and keep others happy >+ my ($borrower)= @_; >+ my $query; >+ my $dbh = C4::Context->dbh; >+ >+ #Delete shares of this borrower (not lists !) >+ $query="DELETE FROM virtualshelfshares WHERE borrowernumber=?"; >+ $dbh->do($query,undef,($borrower)); >+ >+ #Delete private lists without owner that now have no shares anymore >+ $query="DELETE vs.* FROM virtualshelves vs LEFT JOIN virtualshelfshares sh USING (shelfnumber) WHERE category=1 AND vs.owner IS NULL AND sh.shelfnumber IS NULL"; >+ $dbh->do($query); >+ >+ #Change owner for private lists which have shares >+ $query="UPDATE virtualshelves LEFT JOIN virtualshelfshares sh USING (shelfnumber) SET owner=NULL where owner=? AND category=1 AND sh.borrowernumber IS NOT NULL"; >+ $dbh->do($query,undef,($borrower)); >+ >+ #Delete unshared private lists >+ $query="DELETE FROM virtualshelves WHERE owner=? AND category=1"; >+ $dbh->do($query,undef,($borrower)); >+ >+ #Handle public lists owned by borrower >+ $query="UPDATE virtualshelves SET owner=NULL WHERE owner=? AND category=2"; >+ $dbh->do($query,undef,($borrower)); >+ >+ #Handle entries added by borrower to lists of others >+ $query="UPDATE virtualshelfcontents SET borrowernumber=NULL WHERE borrowernumber=?"; >+ $dbh->do($query,undef,($borrower)); >+} >+ > # internal subs > > sub _shelf_count { >diff --git a/members/deletemem.pl b/members/deletemem.pl >index 924245a..a813cd6 100755 >--- a/members/deletemem.pl >+++ b/members/deletemem.pl >@@ -30,6 +30,7 @@ use C4::Output; > use C4::Auth; > use C4::Members; > use C4::Branch; # GetBranches >+use C4::VirtualShelves (); #no import > > my $input = new CGI; > >@@ -117,6 +118,7 @@ output_html_with_http_headers $input, $cookie, $template->output; > > } else { > MoveMemberToDeleted($member); >+ C4::VirtualShelves::HandleDelBorrower($member); > DelMember($member); > print $input->redirect("/cgi-bin/koha/members/members-home.pl"); > } >diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl >index 4fde0f2..0b37c20 100755 >--- a/tools/cleanborrowers.pl >+++ b/tools/cleanborrowers.pl >@@ -40,6 +40,7 @@ use C4::Output; > use C4::Dates qw/format_date format_date_in_iso/; > use C4::Members; # GetBorrowersWhoHavexxxBorrowed. > use C4::Circulation; # AnonymiseIssueHistory. >+use C4::VirtualShelves (); #no import > use Date::Calc qw/Today Add_Delta_YM/; > > my $cgi = new CGI; >@@ -117,13 +118,15 @@ if ( $params->{'step3'} ) { > my $i; > for ( $i = 0 ; $i < $totalDel ; $i++ ) { > MoveMemberToDeleted( $membersToDelete->[$i]->{'borrowernumber'} ); >+ C4::VirtualShelves::HandleDelBorrower($membersToDelete->[$i]->{'borrowernumber'}); > DelMember( $membersToDelete->[$i]->{'borrowernumber'} ); > } > } > else { # delete completly. > my $i; > for ( $i = 0 ; $i < $totalDel ; $i++ ) { >- DelMember($membersToDelete->[$i]->{'borrowernumber'}); >+ C4::VirtualShelves::HandleDelBorrower($membersToDelete->[$i]->{'borrowernumber'}); >+ DelMember($membersToDelete->[$i]->{'borrowernumber'}); > } > } > $template->param( >-- >1.7.2.5
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 7310
:
7092
|
7678
|
7679
|
7680
|
7681
|
7682
|
7769
|
7819
|
7820
|
7821
|
7823
|
7824
|
7825
|
7828
|
7873
|
7874
|
7875
|
7876
|
7877
|
7878
|
7879
|
7909
|
7910
|
7925
|
7926
|
7939
|
7940
|
7942
|
7953
|
8006
|
8007
|
8008
|
8009
|
8259
|
8260
|
8261
|
8262
|
8263
|
8264
|
8265
|
8266
|
8267
|
8410
|
8411
|
8412
|
8467
|
8519