From 17e956aeedbd5964dd6da4c04c1758bd9784959f Mon Sep 17 00:00:00 2001 From: Allen Reinmeyer Date: Thu, 23 Oct 2008 14:16:18 -0500 Subject: [PATCH] Bug #2709 Cannot add from Search to New list While a new list was created, no subsequent call to add the biblio number was made, thus a new empty list would be created every time. Under the existing list add, the same code to add items would also apply to a new list, so I refactored out the logic to add items and made a new subroutine. Signed-off-by: Galen Charlton --- opac/opac-addbybiblionumber.pl | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/opac/opac-addbybiblionumber.pl b/opac/opac-addbybiblionumber.pl index 1aab972050..d72b7c0fc4 100755 --- a/opac/opac-addbybiblionumber.pl +++ b/opac/opac-addbybiblionumber.pl @@ -31,6 +31,19 @@ use C4::Output; use C4::Auth qw/get_session/; use C4::Debug; +#splits incoming biblionumber(s) to array and adds each to shelf. +sub AddBibliosToShelf { + my ($shelfnumber,@biblionumber)=@_; + + # multiple bibs might come in as '/' delimited string (from where, i don't see), or as array. + if (scalar(@biblionumber) == 1) { + @biblionumber = (split /\//,$biblionumber[0]); + } + for my $bib (@biblionumber){ + AddToShelfFromBiblio($bib, $shelfnumber); + } +} + my $query = new CGI; my @biblionumber = $query->param('biblionumber'); my $selectedshelf = $query->param('selectedshelf'); @@ -50,6 +63,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( if ($newvirtualshelf) { $shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category ); + AddBibliosToShelf($shelfnumber, @biblionumber); RefreshShelvesSummary($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ? 20 : 10)); print $query->header; print ""; @@ -62,17 +76,8 @@ if ($selectedshelf) { $authorized = 0 unless ShelfPossibleAction( $loggedinuser, $selectedshelf ); } -# multiple bibs might come in as '/' delimited string (from where, i don't see), or as array. - -my $multiple = 0; -my @bibs; -if (scalar(@biblionumber) == 1) { - @biblionumber = (split /\//,$biblionumber[0]); -} if ($shelfnumber && ($shelfnumber != -1)) { - for my $bib (@biblionumber){ - AddToShelfFromBiblio($bib,$shelfnumber); - } + AddBibliosToShelf($shelfnumber,@biblionumber); RefreshShelvesSummary($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ? 20 : 10)); print $query->header; print ""; -- 2.39.5