[Koha-patches] [PATCH] Bug #2709 Cannot add from Search to New list

Allen Reinmeyer allen.reinmeyer at liblime.com
Thu Oct 23 21:16:18 CEST 2008


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.
---
 opac/opac-addbybiblionumber.pl |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/opac/opac-addbybiblionumber.pl b/opac/opac-addbybiblionumber.pl
index 1aab972..d72b7c0 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, at 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 "<html><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
@@ -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, at biblionumber);
 	RefreshShelvesSummary($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ? 20 : 10));
 	print $query->header;
 	print "<html><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
-- 
1.5.5.GIT




More information about the Koha-patches mailing list