From dffc072c0324381d6a5628f58604aa34ca8af553 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Wed, 14 Sep 2011 16:02:14 -0400 Subject: [PATCH] Add and use a patron search that overrides opt-in invisibility Something like this is required for API calls that need to operate against a number of libraries in a given instance that are using opt-in; otherwise, attempts to search for users will fail and you may end up creating near-duplicates etc. The implementation adds an open-ils.actor.search.patron.advanced.opt_in_override method to open-ils.actor, which, if invoked, checks to see if the caller has the OPT_IN_OVERRIDE permission. If so, then the crazy_search ignores the normal opt-in limits and searches all pertinent users in the database. As a global permission, OPT_IN_OVERRIDE is a blunt instrument. Others might want to put together a more refined version that uses OU depths to define boundaries. Signed-off-by: Dan Scott --- .../src/perlmods/lib/OpenILS/Application/Actor.pm | 27 ++++++++++++++++------ .../OpenILS/Application/Storage/Publisher/actor.pm | 3 ++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index 4b1619c052..c24efe153f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -1220,16 +1220,29 @@ __PACKAGE__->register_method( method => "patron_adv_search", api_name => "open-ils.actor.patron.search.advanced" ); +__PACKAGE__->register_method( + method => "patron_adv_search", + api_name => "open-ils.actor.patron.search.advanced.opt_in_override" +); sub patron_adv_search { - my( $self, $client, $auth, $search_hash, + my( $self, $client, $auth, $search_hash, $search_limit, $search_sort, $include_inactive, $search_depth ) = @_; - my $e = new_editor(authtoken=>$auth); - return $e->event unless $e->checkauth; - return $e->event unless $e->allowed('VIEW_USER'); - return $U->storagereq( - "open-ils.storage.actor.user.crazy_search", $search_hash, - $search_limit, $search_sort, $include_inactive, $e->requestor->ws_ou, $search_depth); + my $ignore_opt_in = 0; + my $e = new_editor(authtoken=>$auth); + return $e->event unless $e->checkauth; + return $e->event unless $e->allowed('VIEW_USER'); + + # Override opt-in permissions + if ($self->api_name =~ /opt_in_override/) { + if ($e->allowed('OPT_IN_OVERRIDE')) { + $ignore_opt_in = 1; + } + } + return $U->storagereq( + "open-ils.storage.actor.user.crazy_search", $search_hash, + $search_limit, $search_sort, $include_inactive, + $e->requestor->ws_ou, $search_depth, $ignore_opt_in); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm index 1cb3dce467..e7d2565fe5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm @@ -640,6 +640,7 @@ sub patron_search { my $inactive = shift; my $ws_ou = shift; my $ws_ou_depth = shift || 0; + my $opt_in_override = shift; my $penalty_sort = 0; @@ -759,7 +760,7 @@ sub patron_search { my $opt_in_join = ''; my $opt_in_where = ''; - if (lc($strict_opt_in) eq 'true') { + if (lc($strict_opt_in) eq 'true' && (!$opt_in_override)) { $opt_in_join = "LEFT JOIN $opt_in_table oi ON (oi.org_unit = $ws_ou AND users.id = oi.usr)"; $opt_in_where = "AND (oi.id IS NOT NULL OR users.home_ou = $ws_ou)"; } -- 2.11.0