Lines 631-638
sub ShelvesMax {
Link Here
|
631 |
|
631 |
|
632 |
When a member is deleted (DelMember in Members.pm), you should call me first. |
632 |
When a member is deleted (DelMember in Members.pm), you should call me first. |
633 |
This routine deletes/moves lists and entries for the deleted member/borrower. |
633 |
This routine deletes/moves lists and entries for the deleted member/borrower. |
634 |
You could just delete everything (and lose more than you want), but instead we |
634 |
Lists owned by the borrower are deleted, but entries from the borrower to |
635 |
now try to save all public/shared stuff and keep others happy. |
635 |
other lists are kept. |
636 |
|
636 |
|
637 |
=cut |
637 |
=cut |
638 |
|
638 |
|
Lines 641-671
sub HandleDelBorrower {
Link Here
|
641 |
my $query; |
641 |
my $query; |
642 |
my $dbh = C4::Context->dbh; |
642 |
my $dbh = C4::Context->dbh; |
643 |
|
643 |
|
644 |
#Delete shares of this borrower (not lists !) |
644 |
#Delete all lists and all shares of this borrower |
645 |
#Although this would be done later via the FK cascaded delete, we do it now. |
645 |
#Consistent with the approach Koha uses on deleting individual lists |
646 |
#Because it makes the following delete statement on shelves more meaningful. |
646 |
#Note that entries in virtualshelfcontents added by this borrower to |
647 |
$query="DELETE FROM virtualshelfshares WHERE borrowernumber=?"; |
647 |
#lists of others will be handled by a table constraint: the borrower |
|
|
648 |
#is set to NULL in those entries. |
649 |
$query="DELETE FROM virtualshelves WHERE owner=?"; |
648 |
$dbh->do($query,undef,($borrower)); |
650 |
$dbh->do($query,undef,($borrower)); |
649 |
|
651 |
|
650 |
#Delete private lists without owner that now have no shares anymore |
652 |
#NOTE: |
651 |
$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"; |
653 |
#We could handle the above deletes via a constraint too. |
652 |
$dbh->do($query); |
654 |
#But a new BZ report 11889 has been opened to discuss another approach. |
653 |
|
655 |
#Instead of deleting we could also disown lists (based on a pref). |
654 |
#Change owner for private lists which have shares |
656 |
#In that way we could save shared and public lists. |
655 |
$query="UPDATE virtualshelves LEFT JOIN virtualshelfshares sh USING (shelfnumber) SET owner=NULL where owner=? AND category=1 AND sh.borrowernumber IS NOT NULL"; |
657 |
#The current table constraints support that idea now. |
656 |
$dbh->do($query,undef,($borrower)); |
658 |
#This pref should then govern the results of other routines such as |
657 |
|
659 |
#DelShelf too. |
658 |
#Delete unshared private lists |
|
|
659 |
$query="DELETE FROM virtualshelves WHERE owner=? AND category=1"; |
660 |
$dbh->do($query,undef,($borrower)); |
661 |
|
662 |
#Handle public lists owned by borrower |
663 |
$query="UPDATE virtualshelves SET owner=NULL WHERE owner=? AND category=2"; |
664 |
$dbh->do($query,undef,($borrower)); |
665 |
|
666 |
#Handle entries added by borrower to lists of others |
667 |
$query="UPDATE virtualshelfcontents SET borrowernumber=NULL WHERE borrowernumber=?"; |
668 |
$dbh->do($query,undef,($borrower)); |
669 |
} |
660 |
} |
670 |
|
661 |
|
671 |
=head2 AddShare |
662 |
=head2 AddShare |
672 |
- |
|
|