From 0bf6039f7942c9e21ab45ef3f51005520e45b06d Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 29 Oct 2014 17:05:32 -0400 Subject: [PATCH] KMIG-57 : KCLSUPGRAD-33: Set all patron's Default Search Location to KCLS Cross-port: f194b73 --- .../sql/kmig57-default_search_location_trigger.sql | 35 ++++++++++++++++++++++ .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm | 25 ++++++++-------- 2 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 KCLS/sql/kmig57-default_search_location_trigger.sql diff --git a/KCLS/sql/kmig57-default_search_location_trigger.sql b/KCLS/sql/kmig57-default_search_location_trigger.sql new file mode 100644 index 0000000000..dfae375330 --- /dev/null +++ b/KCLS/sql/kmig57-default_search_location_trigger.sql @@ -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 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 730586a128..3d932c9727 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -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}; -- 2.11.0