From 71d4942c30f30fdbdf89a93f59e89a4f28e0dd3f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 11 Feb 2016 11:32:43 +0000 Subject: [PATCH] Bug 15760: Fix order by direction for shelves The order_by parameters should not be "$direction $order_by" with quote_names enabled. The correct syntax is { -$direction => $order_by } Test plan for Opac + Staff interfces: Sort list by title or whatever and change the direction Signed-off-by: Mirko Tietgen Signed-off-by: Tomas Cohen Arazi Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com --- Koha/Virtualshelves.pm | 2 +- opac/opac-shelves.pl | 3 ++- virtualshelves/shelves.pl | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm index 34b1003200..152d51787f 100644 --- a/Koha/Virtualshelves.pm +++ b/Koha/Virtualshelves.pm @@ -114,7 +114,7 @@ sub get_some_shelves { { join => [ 'virtualshelfshares' ], group_by => 'shelfnumber', - order_by => 'lastmodified desc', + order_by => { -desc => 'lastmodified' }, } ); } diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 2d810cb143..76d632a785 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -223,6 +223,7 @@ if ( $op eq 'view' ) { $category = $shelf->category; my $sortfield = $query->param('sortfield') || $shelf->sortfield; # Passed in sorting overrides default sorting my $direction = $query->param('direction') || 'asc'; + $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc'; my ( $page, $rows ); unless ( $query->param('print') or $query->param('rss') ) { $rows = C4::Context->preference('OPACnumSearchResults') || 20; @@ -235,7 +236,7 @@ if ( $op eq 'view' ) { prefetch => [ { 'biblionumber' => { 'biblioitems' => 'items' } } ], page => $page, rows => $rows, - order_by => "$order_by $direction", + order_by => { "-$direction" => $order_by }, } ); diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index 3dfa211953..74e31e4380 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -195,6 +195,7 @@ if ( $op eq 'view' ) { if ( $shelf->can_be_viewed( $loggedinuser ) ) { my $sortfield = $query->param('sortfield') || $shelf->sortfield || 'title'; # Passed in sorting overrides default sorting my $direction = $query->param('direction') || 'asc'; + $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc'; my ( $rows, $page ); unless ( $query->param('print') ) { $rows = C4::Context->preference('numSearchResults') || 20; @@ -208,7 +209,7 @@ if ( $op eq 'view' ) { prefetch => [ { 'biblionumber' => { 'biblioitems' => 'items' } } ], page => $page, rows => $rows, - order_by => "$order_by $direction", + order_by => { "-$direction" => $order_by }, } ); -- 2.39.5