Lines 565-572
sub DelFromShelf {
Link Here
|
565 |
} |
565 |
} |
566 |
} |
566 |
} |
567 |
if($del_oth) { |
567 |
if($del_oth) { |
568 |
$query = qq(DELETE FROM virtualshelfcontents |
568 |
#includes a check if borrowernumber is null (deleted patron) |
569 |
WHERE shelfnumber=? AND biblionumber=? AND borrowernumber<>?); |
569 |
$query = qq/DELETE FROM virtualshelfcontents |
|
|
570 |
WHERE shelfnumber=? AND biblionumber=? AND |
571 |
(borrowernumber IS NULL OR borrowernumber<>?)/; |
570 |
$sth= $dbh->prepare($query); |
572 |
$sth= $dbh->prepare($query); |
571 |
foreach my $biblionumber (@$bibref) { |
573 |
foreach my $biblionumber (@$bibref) { |
572 |
$sth->execute($shelfnumber, $biblionumber, $user); |
574 |
$sth->execute($shelfnumber, $biblionumber, $user); |
Lines 634-639
sub ShelvesMax {
Link Here
|
634 |
return SHELVES_MASTHEAD_MAX; |
636 |
return SHELVES_MASTHEAD_MAX; |
635 |
} |
637 |
} |
636 |
|
638 |
|
|
|
639 |
sub HandleDelBorrower { |
640 |
#when a member is deleted (DelMember in Members.pm), you should call me first |
641 |
#this routine deletes/moves lists and entries for the deleted member/borrower |
642 |
#you could just delete everything (and lose more than you want) |
643 |
#instead we now try to save all public/shared stuff and keep others happy |
644 |
my ($borrower)= @_; |
645 |
my $query; |
646 |
my $dbh = C4::Context->dbh; |
647 |
|
648 |
#Delete shares of this borrower (not lists !) |
649 |
$query="DELETE FROM virtualshelfshares WHERE borrowernumber=?"; |
650 |
$dbh->do($query,undef,($borrower)); |
651 |
|
652 |
#Delete private lists without owner that now have no shares anymore |
653 |
$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"; |
654 |
$dbh->do($query); |
655 |
|
656 |
#Change owner for private lists which have shares |
657 |
$query="UPDATE virtualshelves LEFT JOIN virtualshelfshares sh USING (shelfnumber) SET owner=NULL where owner=? AND category=1 AND sh.borrowernumber IS NOT NULL"; |
658 |
$dbh->do($query,undef,($borrower)); |
659 |
|
660 |
#Delete unshared private lists |
661 |
$query="DELETE FROM virtualshelves WHERE owner=? AND category=1"; |
662 |
$dbh->do($query,undef,($borrower)); |
663 |
|
664 |
#Handle public lists owned by borrower |
665 |
$query="UPDATE virtualshelves SET owner=NULL WHERE owner=? AND category=2"; |
666 |
$dbh->do($query,undef,($borrower)); |
667 |
|
668 |
#Handle entries added by borrower to lists of others |
669 |
$query="UPDATE virtualshelfcontents SET borrowernumber=NULL WHERE borrowernumber=?"; |
670 |
$dbh->do($query,undef,($borrower)); |
671 |
} |
672 |
|
637 |
# internal subs |
673 |
# internal subs |
638 |
|
674 |
|
639 |
sub _shelf_count { |
675 |
sub _shelf_count { |