From 41f2819f7b620d9504747a46efcb47003b80ef4e Mon Sep 17 00:00:00 2001 From: Josh Stompro Date: Mon, 15 Feb 2016 17:42:01 -0600 Subject: [PATCH] LP#1534979 - Add an Org Unit Setting to disable setting the Search Lib to equal Preferred Lib. Our system wishes to make use of preferred lib settings, but never wants to limit which locations get searched without user action. So this allows that tie to be removed on a per OU basis. Signed-off-by: Josh Stompro --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm | 21 +++++++++++++++++++-- .../upgrade/xxxx.opac_skip_search_lib_to_pref_lib | 15 +++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/xxxx.opac_skip_search_lib_to_pref_lib 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 69bb8986be..3827729280 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -549,8 +549,25 @@ sub _get_search_lib { return $self->apache->headers_in->get('OILS-Search-Lib'); } - my $pref_lib = $self->_get_pref_lib(); - return $pref_lib if $pref_lib; + #Should the search lib be set to the preferred lib? + my $ou; + if ($ctx->{user}) { #if logged in use home_ou as scope + $ou = $ctx->{user}->home_ou; + } + elsif($ctx->{physical_loc}) { #if not logged in use physical_loc as scope + $ou = $ctx->{physical_loc}; + } + else { #Set to the root OU + $ou = $ctx->{aou_tree}->()->id; + } + + # See if the user has a search library preference + my $yset = ($ctx->{get_org_setting}->($ou, 'opac.search.skip_search_lib_to_pref_lib')) ? 1 : 0; + + if(!$yset) { #if not set or false, then set search_lib to pref_lib. + my $pref_lib = $self->_get_pref_lib(); + return $pref_lib if $pref_lib; + } return $ctx->{aou_tree}->()->id; } diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.opac_skip_search_lib_to_pref_lib b/Open-ILS/src/sql/Pg/upgrade/xxxx.opac_skip_search_lib_to_pref_lib new file mode 100644 index 0000000000..10748c4f76 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.opac_skip_search_lib_to_pref_lib @@ -0,0 +1,15 @@ +-- LP#1534979 - YAOUS to enable skipping setting the Search lib to = pref lib + +BEGIN; + +-- INSERT INTO config.upgrade_log (version) VALUES ('xxxx'); + +INSERT INTO config.org_unit_setting_type (name, label, description, datatype) VALUES ( + 'opac.search.skip_search_lib_to_pref_lib', + 'Skip setting the Search Lib to equal the Preferred Search Lib in the catalog.', + 'Setting this to TRUE allows the catalog to easily have a different preferred library than the search library.', + 'bool' +); + + +COMMIT; -- 2.11.0