From: Lebbeous Fogle-Weekley Date: Thu, 28 Jul 2011 20:59:59 +0000 (-0400) Subject: If there's no sort org unit, just fall back to the usual sorting X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1b044475a898838b57bbf92235303e8f2e5c1516;p=evergreen%2Fpines.git If there's no sort org unit, just fall back to the usual sorting Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index f3391ddfab..dbfad54ee2 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -78,12 +78,6 @@ sub mk_copy_query { my $copy_limit = shift; my $copy_offset = shift; - # XXX In the future, $sort_org should be understood to be an abstration - # that refers to something configurable, not necessariyl orig_loc. - - my $sort_org = $self->ctx->{orig_loc} || $org || - $self->ctx->{aou_tree}->()->id; - my $query = { select => { acp => ['id', 'barcode', 'circ_lib', 'create_date', 'age_protect', 'holdable'], @@ -139,8 +133,6 @@ sub mk_copy_query { # Order is: copies with circ_lib=org, followed by circ_lib name, followed by call_number label order_by => [ - {class => 'acp', field => 'circ_lib', transform => 'numeric_eq', - params => [$sort_org], direction => 'desc'}, {class => 'aou', field => 'name'}, {class => 'acn', field => 'label'} ], @@ -149,6 +141,16 @@ sub mk_copy_query { offset => $copy_offset }; + # XXX In the future, $sort_org should be understood to be an abstration + # that refers to something configurable, not necessariyl orig_loc. + + if (my $sort_org = $self->ctx->{orig_loc}) { + unshift @{$query->{order_by}}, { + class => 'acp', field => 'circ_lib', transform => 'numeric_eq', + params => [$sort_org], direction => 'desc' + }; + } + # Filter hidden items if this is the public catalog unless($self->ctx->{is_staff}) { $query->{where}->{'+acp'}->{opac_visible} = 't';