From 9af2edf0d0b0d75b74a78a54dfa0c7c0e5ca5466 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 Content-Type: text/plain; charset=utf-8 Signed-off-by: Alex Arnaud Signed-off-by: Marcel de Rooy --- 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 5fb1764..b8f413f 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1815,6 +1815,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 29126cc..6c74155 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; -- 1.7.10.4