[Koha-patches] [PATCH] Fixes bug 5232: Shelfname won't display on high-numbered lists

Nicole Engard nengard at bywatersolutions.com
Tue Nov 30 08:25:30 CET 2010


From: Ian Walls <ian.walls at bywatersolutions.com>

This bugfix adds an explicit GetShelf for the specific shelfnumber when viewing that individual shelfnumber.  This captures the
shelfname, which was originally pulled from shelflist->{$shelfnumber}, which may not have been populated if the List in question was
beyond the 20th private or public list in the system.

Also adds a more explicit sort: the sort from the CGI takes top priority, then it falls back to the default sort for the list, and
ultimate falls to 'title' if neither CGI nor default sort exist.

Signed-off-by: Ian Walls <ian.walls at bywatersolutions.com>
Signed-off-by: Nicole Engard <nengard at bywatersolutions.com>
---
 C4/VirtualShelves/Page.pm |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm
index e772db8..80d8f3c 100644
--- a/C4/VirtualShelves/Page.pm
+++ b/C4/VirtualShelves/Page.pm
@@ -174,13 +174,22 @@ sub shelfpage ($$$$$) {
             last SWITCH;
         }
         if ( $shelfnumber = $query->param('viewshelf') ) {
+            # explicitly fetch this shelf
+            my ($shelfnumber2,$shelfname,$owner,$category,$sorton) = GetShelf($shelfnumber);
 
             #check that the user can view the shelf
             if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
                 my $items;
                 my $authorsort;
                 my $yearsort;
-                my $sortfield = ( $query->param('sortfield') ? $query->param('sortfield') : 'title' );
+                my $sortfield;
+                if ( $query->param('sortfield')) {
+                   $sortfield = $query->param('sortfield');
+                } elsif ($sorton) {
+                   $sortfield = $sorton;
+                } else {
+                   $sortfield = 'title';
+                }
                 if ( $sortfield eq 'author' ) {
                     $authorsort = 'author';
                 }
@@ -210,7 +219,7 @@ sub shelfpage ($$$$$) {
                 my $i = 0;
                 my $manageshelf = ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' );
                 $template->param(
-                    shelfname => $shelflist->{$shelfnumber}->{'shelfname'} || $privshelflist->{$shelfnumber}->{'shelfname'},
+                    shelfname   => $shelfname,
                     shelfnumber => $shelfnumber,
                     viewshelf   => $shelfnumber,
                     authorsort  => $authorsort,
-- 
1.5.6.5



More information about the Koha-patches mailing list