KMIG-57 : KCLSUPGRAD-33: Set all patron's Default Search Location to KCLS
authorBill Erickson <berickxx@gmail.com>
Wed, 29 Oct 2014 21:05:32 +0000 (17:05 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
    Cross-port: f194b73

KCLS/sql/kmig57-default_search_location_trigger.sql [new file with mode: 0644]
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm

diff --git a/KCLS/sql/kmig57-default_search_location_trigger.sql b/KCLS/sql/kmig57-default_search_location_trigger.sql
new file mode 100644 (file)
index 0000000..dfae375
--- /dev/null
@@ -0,0 +1,35 @@
+-- Function: actor.ignore_update_default_search_location()
+
+-- DROP FUNCTION actor.ignore_update_default_search_location();
+
+CREATE OR REPLACE FUNCTION actor.ignore_update_default_search_location()
+  RETURNS trigger AS
+$BODY$
+
+BEGIN          
+   
+    IF TG_OP = 'UPDATE' AND new.value NOT ILIKE '"1"' AND new.name ILIKE 'opac.default_search_location' THEN
+                SELECT '"1"' INTO new.value FROM actor.usr AS au WHERE au.id = new.usr;
+    ELSIF TG_OP = 'INSERT' AND new.value NOT ILIKE '"1"' AND new.name ILIKE 'opac.default_search_location' THEN
+                SELECT '"1"' INTO new.value FROM actor.usr AS au WHERE au.id = new.usr;
+    END IF;
+
+    RETURN new;
+
+END;
+$BODY$
+  LANGUAGE plpgsql VOLATILE
+  COST 500;
+ALTER FUNCTION actor.ignore_update_default_search_location()
+  OWNER TO evergreen;
+
+
+-- Trigger: actor_only_kcls_for_default_search_location on actor.usr_setting
+
+-- DROP TRIGGER actor_only_kcls_for_default_search_location ON actor.usr_setting;
+
+CREATE TRIGGER actor_only_kcls_for_default_search_location
+  BEFORE INSERT OR UPDATE
+  ON actor.usr_setting
+  FOR EACH ROW
+  EXECUTE PROCEDURE actor.ignore_update_default_search_location();
\ No newline at end of file
index 730586a..3d932c9 100644 (file)
@@ -600,18 +600,19 @@ sub _get_pref_lib {
         return $self->cgi->cookie('eg_pref_lib');
     }
 
-    if ($ctx->{user}) {
-        # See if the user has a search library preference
-        my $lset = $self->editor->search_actor_user_setting({
-            usr => $ctx->{user}->id, 
-            name => 'opac.default_search_location'
-        })->[0];
-        return OpenSRF::Utils::JSON->JSON2perl($lset->value) if $lset;
-
-        # Otherwise return the user's home library
-        my $ou = $ctx->{user}->home_ou;
-        return ref($ou) ? $ou->id : $ou;
-    }
+    #kmig57 - default search location is not used by KCLS
+    # if ($ctx->{user}) {
+    #    # See if the user has a search library preference
+    #    my $lset = $self->editor->search_actor_user_setting({
+    #        usr => $ctx->{user}->id, 
+    #        name => 'opac.default_search_location'
+    #    })->[0];
+    #    return OpenSRF::Utils::JSON->JSON2perl($lset->value) if $lset;
+
+    #    # Otherwise return the user's home library
+    #    my $ou = $ctx->{user}->home_ou;
+    #    return ref($ou) ? $ou->id : $ou;
+    #}
 
     if ($ctx->{physical_loc}) {
         return $ctx->{physical_loc};