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;
}
--- /dev/null
+-- 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;