From e40d8d01620c6277fb24372b8b2f5db64248c240 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 18 Aug 2015 10:50:06 +0100 Subject: [PATCH] Bug 14544: Move HandleDelBorrower to C4::Members Signed-off-by: Alex Arnaud Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- C4/Members.pm | 34 ++++++++++++++++++++++++++++++++++ C4/VirtualShelves.pm | 34 ---------------------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 9507b9f6cb..171f3c0d34 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1816,6 +1816,40 @@ sub DelMember { return $sth->rows; } +=head2 HandleDelBorrower + + HandleDelBorrower($borrower); + +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. +Lists owned by the borrower are deleted, but entries from the borrower to +other lists are kept. + +=cut + +sub HandleDelBorrower { + my ($borrower)= @_; + my $query; + my $dbh = C4::Context->dbh; + + #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. + $query="DELETE FROM virtualshelves WHERE owner=?"; + $dbh->do($query,undef,($borrower)); + + #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. +} + =head2 ExtendMemberSubscriptionTo (OUEST-PROVENCE) $date = ExtendMemberSubscriptionTo($borrowerid, $date); diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm index 29126cc0be..6c7415589d 100644 --- a/C4/VirtualShelves.pm +++ b/C4/VirtualShelves.pm @@ -83,40 +83,6 @@ sub ShelvesMax { return SHELVES_MASTHEAD_MAX; } -=head2 HandleDelBorrower - - HandleDelBorrower($borrower); - -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. -Lists owned by the borrower are deleted, but entries from the borrower to -other lists are kept. - -=cut - -sub HandleDelBorrower { - my ($borrower)= @_; - my $query; - my $dbh = C4::Context->dbh; - - #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. - $query="DELETE FROM virtualshelves WHERE owner=?"; - $dbh->do($query,undef,($borrower)); - - #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. -} - sub GetShelfCount { my ($owner, $category) = @_; my @params; -- 2.39.5