From ebffbab52a7d239e0b393759979b65e9d9b6cef9 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Sat, 10 Mar 2012 21:14:15 -0500 Subject: [PATCH] TPAC: Add preferred library to search result ordering Now that unapi.bre/unapi.holdings_xml has learned how to order copies by ranked library, teach TPAC how to tell unapi what the preferred library is. We do this by parsing the preferred search library separately from the scoped search library, as follows (1st match wins): 1) A new GET param, "plib", specifying the number of the OU 2) User's library preference setting; 3) User's home OU; 4) Physical location in which the search is being issued Signed-off-by: Dan Scott --- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm | 10 ++++++++-- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index ecf8ef0b04..d96bbca20b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -279,6 +279,7 @@ sub load_rresults { my @facets = $cgi->param('facet'); my $limit = $self->_get_search_limit; $ctx->{search_ou} = $self->_get_search_lib(); + $ctx->{pref_ou} = $self->_get_pref_lib() || $ctx->{search_ou}; my $offset = $page * $limit; my $metarecord = $cgi->param('metarecord'); my $results; @@ -375,7 +376,8 @@ sub load_rresults { { flesh => '{holdings_xml,mra,acp,acnp,acns,bmp}', site => $site, - depth => $depth + depth => $depth, + pref_lib => $ctx->{pref_ou}, } ); @@ -525,6 +527,7 @@ sub marc_expert_search { my $page = $self->cgi->param("page") || 0; my $limit = $self->_get_search_limit; $self->ctx->{search_ou} = $self->_get_search_lib(); + $self->ctx->{pref_ou} = $self->_get_pref_lib(); my $offset = $page * $limit; $self->ctx->{records} = []; @@ -572,7 +575,10 @@ sub marc_expert_search { } my ($facets, @data) = $self->get_records_and_facets( - $self->ctx->{ids}, undef, {flesh => "{holdings_xml,mra,acnp,acns}"} + $self->ctx->{ids}, undef, { + flesh => "{holdings_xml,mra,acnp,acns}", + pref_lib => $self->ctx->{pref_ou}, + } ); $self->ctx->{records} = [@data]; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index 66923874dd..5aced5b0c3 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -210,6 +210,7 @@ sub get_records_and_facets { $unapi_args->{site}, $unapi_args->{depth}, 'acn=>' . $unapi_args->{flesh_depth} . ',acp=>' . $unapi_args->{flesh_depth}, + undef, undef, $unapi_args->{pref_lib} ]} ) for @$rec_ids; @@ -292,6 +293,20 @@ sub _get_search_lib { $loc = $self->cgi->param('loc'); return $loc if $loc; + my $pref_lib = $self->_get_pref_lib(); + return $pref_lib if $pref_lib; + + return $ctx->{aou_tree}->()->id; +} + +sub _get_pref_lib { + my $self = shift; + my $ctx = $self->ctx; + + # plib param takes precedence + my $plib = $self->cgi->param('plib'); + return $plib if $plib; + if ($ctx->{user}) { # See if the user has a search library preference my $lset = $self->editor->search_actor_user_setting({ @@ -308,7 +323,6 @@ sub _get_search_lib { return $self->cgi->param('physical_loc'); } - return $ctx->{aou_tree}->()->id; } # This is defensively coded since we don't do much manual reading from the -- 2.11.0