From: Josh Stompro Date: Mon, 15 Feb 2016 23:42:01 +0000 (-0600) Subject: LP#1534979 - Add an Org Unit Setting to disable setting X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=41f2819f7b620d9504747a46efcb47003b80ef4e;p=working%2FEvergreen.git 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 --- 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;