From df0f53835f6e4a095af1a40c7eccf2fe821561c9 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 14 Aug 2020 12:42:24 -0400 Subject: [PATCH] LP 1890629: Make Self-Registration Opt-in Settings Lookup Tree Aware Patron self-registration in the OPAC only shows the opt-in settings if the events are owned specifically at one of the locations where patron self-registration is also allowed. The event could be owned higher up the org. tree from the libraries that allow self-registration, particularly in a consortium where not all members do self-registration. This patch changes the search for opt-in events to include the ancestor org. units of those that allow self-registration. Signed-off-by: Jason Stephenson --- Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm index 4949d10073..99b692bad5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm @@ -6,6 +6,7 @@ use OpenILS::Utils::Fieldmapper; use OpenILS::Application::AppUtils; use OpenILS::Utils::CStoreEditor qw/:funcs/; use OpenILS::Event; +use List::MoreUtils qw/uniq/; use Data::Dumper; $Data::Dumper::Indent = 0; my $U = 'OpenILS::Application::AppUtils'; @@ -135,13 +136,20 @@ sub collect_opt_in_settings { my $self = shift; my $e = $self->editor; + # Get the valid_orgs and their ancestors, because the event def + # may be owned higher up the tree. + my @opt_orgs = (); + for my $orgs (map { $U->get_org_ancestors($_) } @{ $self->ctx->{register}{valid_orgs} }) { + push(@opt_orgs, @{$orgs}); + } + my $types = $e->json_query({ select => {cust => ['name']}, from => {atevdef => 'cust'}, transform => 'distinct', where => { '+atevdef' => { - owner => [ map { $_ } @{ $self->ctx->{register}{valid_orgs} } ], + owner => [ uniq @opt_orgs ], active => 't' } } -- 2.11.0