LP#1534979 - Add an Org Unit Setting to disable setting user/stompro/lp1534979_skip_search_lib_to_pref_lib
authorJosh Stompro <stomproj@larl.org>
Mon, 15 Feb 2016 23:42:01 +0000 (17:42 -0600)
committerJosh Stompro <stomproj@larl.org>
Mon, 15 Feb 2016 23:42:01 +0000 (17:42 -0600)
  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 <stomproj@larl.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
Open-ILS/src/sql/Pg/upgrade/xxxx.opac_skip_search_lib_to_pref_lib [new file with mode: 0644]

index 69bb898..3827729 100644 (file)
@@ -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 (file)
index 0000000..10748c4
--- /dev/null
@@ -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;