LP1757507: Patron Opt-in Restriction Tightening user/jboyer/lp1757507-restrict-opt-in-for-real
authorJason Boyer <jboyer@library.in.gov>
Wed, 21 Mar 2018 19:08:19 +0000 (15:08 -0400)
committerJason Boyer <jboyer@library.in.gov>
Wed, 21 Mar 2018 19:08:19 +0000 (15:08 -0400)
The setting to restrict patron opt-in at a depth should
be take precedence over the overall opt-in boundary.
This allows locations to be selectively "walled off"
regardless of the depth of the regular opt-in boundary.

Signed-off-by: Jason Boyer <jboyer@library.in.gov>
Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm

index e62982e..29b6b10 100644 (file)
@@ -3179,14 +3179,6 @@ sub user_opt_in_at_org {
     # user is automatically opted-in if they are from the local org
     return 1 if $user->home_ou eq $ws_org;
 
-    # get the boundary setting
-    my $opt_boundary = $U->ou_ancestor_setting_value($e->requestor->ws_ou,'org.patron_opt_boundary');
-
-    # auto opt in if user falls within the opt boundary
-    my $opt_orgs = $U->get_org_descendants($ws_org, $opt_boundary);
-
-    return 1 if grep $_ eq $user->home_ou, @$opt_orgs;
-
     # check whether opt-in is restricted at the user's home library
     my $opt_restrict_depth = $U->ou_ancestor_setting_value($user->home_ou, 'org.restrict_opt_to_depth');
     if ($opt_restrict_depth) {
@@ -3198,6 +3190,14 @@ sub user_opt_in_at_org {
         return 2 unless grep $_ eq $e->requestor->ws_ou, @$unrestricted_orgs;
     }
 
+    # get the boundary setting
+    my $opt_boundary = $U->ou_ancestor_setting_value($e->requestor->ws_ou,'org.patron_opt_boundary');
+
+    # auto opt in if user falls within the opt boundary
+    my $opt_orgs = $U->get_org_descendants($ws_org, $opt_boundary);
+
+    return 1 if grep $_ eq $user->home_ou, @$opt_orgs;
+
     my $vals = $e->search_actor_usr_org_unit_opt_in(
         {org_unit=>$opt_orgs, usr=>$user_id},{idlist=>1});