From 091d78ad18ba311457c82dab3579444a3f6ecc89 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 22 Jan 2014 11:00:24 -0500 Subject: [PATCH] Check behavioral setting for Located URIs When the opac.located_uri.act_as_copy Global Flag is enabled, treat Located URIs like copies for visibility testing purposes. We use actor.org_unit_full_path instead of actor.org_unit_descendants so that we do not lose the desirable "licensed here" modeling that Located URIs provide. Signed-off-by: Mike Rylander Signed-off-by: Jeff Godin --- .../src/sql/Pg/300.schema.staged_search.sql | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql b/Open-ILS/src/sql/Pg/300.schema.staged_search.sql index 67740cf2e5..5b5774d436 100644 --- a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql +++ b/Open-ILS/src/sql/Pg/300.schema.staged_search.sql @@ -70,12 +70,15 @@ DECLARE visible_count INT := 0; excluded_count INT := 0; + luri_as_copy BOOL; BEGIN check_limit := COALESCE( param_check, 1000 ); core_limit := COALESCE( param_limit, 25000 ); core_offset := COALESCE( param_offset, 0 ); + SELECT COALESCE( enabled, FALSE ) INTO luri_as_copy FROM config.global_flag WHERE name = 'opac.located_uri.act_as_copy'; + -- core_skip_chk := COALESCE( param_skip_chk, 1 ); IF param_search_ou > 0 THEN @@ -85,13 +88,23 @@ BEGIN SELECT ARRAY_AGG(distinct id) INTO search_org_list FROM actor.org_unit_descendants( param_search_ou ); END IF; - SELECT ARRAY_AGG(distinct id) INTO luri_org_list FROM actor.org_unit_ancestors( param_search_ou ); + IF luri_as_copy THEN + SELECT ARRAY_AGG(distinct id) INTO luri_org_list FROM actor.org_unit_full_path( param_search_ou ); + ELSE + SELECT ARRAY_AGG(distinct id) INTO luri_org_list FROM actor.org_unit_ancestors( param_search_ou ); + END IF; ELSIF param_search_ou < 0 THEN SELECT ARRAY_AGG(distinct org_unit) INTO search_org_list FROM actor.org_lasso_map WHERE lasso = -param_search_ou; FOR tmp_int IN SELECT * FROM UNNEST(search_org_list) LOOP - SELECT ARRAY_AGG(distinct id) INTO tmp_int_list FROM actor.org_unit_ancestors( tmp_int ); + + IF luri_as_copy THEN + SELECT ARRAY_AGG(distinct id) INTO tmp_int_list FROM actor.org_unit_full_path( tmp_int ); + ELSE + SELECT ARRAY_AGG(distinct id) INTO tmp_int_list FROM actor.org_unit_ancestors( tmp_int ); + END IF; + luri_org_list := luri_org_list || tmp_int_list; END LOOP; @@ -102,7 +115,12 @@ BEGIN END IF; IF param_pref_ou IS NOT NULL THEN - SELECT array_agg(distinct id) INTO tmp_int_list FROM actor.org_unit_ancestors(param_pref_ou); + IF luri_as_copy THEN + SELECT ARRAY_AGG(distinct id) INTO tmp_int_list FROM actor.org_unit_full_path( param_pref_ou ); + ELSE + SELECT ARRAY_AGG(distinct id) INTO tmp_int_list FROM actor.org_unit_ancestors( param_pref_ou ); + END IF; + luri_org_list := luri_org_list || tmp_int_list; END IF; -- 2.43.2