Bug 6154: Default sorting by title doesn't work
authorJared Camins-Esakov <jcamins@bywatersolutions.com>
Sun, 10 Apr 2011 21:28:05 +0000 (17:28 -0400)
committerChris Nighswonger <chris.nighswonger@gmail.com>
Sat, 16 Apr 2011 19:15:28 +0000 (15:15 -0400)
If you have the default sorting set to title ascending or title descending,
your search results will not automatically be sorted because the syspref uses
title_asc and title_dsc, whereas Search.pm wants title_az and title_za. The same
issue is present when the default sort is on author.

Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
(cherry picked from commit 499c694daf408571cc8370b4c20568336ba35cde)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
C4/Search.pm

index c681452..b9867ee 100644 (file)
@@ -350,10 +350,10 @@ sub getRecords {
         # Note: sort will override rank
         my $sort_by;
         foreach my $sort (@sort_by) {
-            if ( $sort eq "author_az" ) {
+            if ( $sort eq "author_az" || $sort eq "author_asc" ) {
                 $sort_by .= "1=1003 <i ";
             }
-            elsif ( $sort eq "author_za" ) {
+            elsif ( $sort eq "author_za" || $sort eq "author_dsc" ) {
                 $sort_by .= "1=1003 >i ";
             }
             elsif ( $sort eq "popularity_asc" ) {
@@ -380,10 +380,10 @@ sub getRecords {
             elsif ( $sort eq "acqdate_dsc" ) {
                 $sort_by .= "1=32 >i ";
             }
-            elsif ( $sort eq "title_az" ) {
+            elsif ( $sort eq "title_az" || $sort eq "title_asc" ) {
                 $sort_by .= "1=4 <i ";
             }
-            elsif ( $sort eq "title_za" ) {
+            elsif ( $sort eq "title_za" || $sort eq "title_dsc" ) {
                 $sort_by .= "1=4 >i ";
             }
             else {
@@ -2210,7 +2210,7 @@ sub NZorder {
     # sort the hash and return the same structure as GetRecords (Zebra querying)
         my $result_hash;
         my $numbers = 0;
-        if ( $ordering eq 'author_za' ) {    # sort by author desc
+        if ( $ordering eq 'author_za' || $ordering eq 'author_dsc' ) {    # sort by author desc
             foreach my $key ( sort { $b cmp $a } ( keys %result ) ) {
                 $result_hash->{'RECORDS'}[ $numbers++ ] =
                   $result{$key}->as_usmarc();