$rec_id, undef, undef, $copy_limit, $copy_offset, $self->ctx->{is_staff}
);
- if($org != $self->ctx->{aou_tree}->()->id) {
+ my $lasso_orgs = $self->search_lasso_orgs;
+
+ if($lasso_orgs || $org != $self->ctx->{aou_tree}->()->id) {
# no need to add the org join filter if we're not actually filtering
+
+ my $filter_orgs = $lasso_orgs || $org;
$query->{from}->{acp}->[1] = { aou => {
fkey => 'circ_lib',
field => 'id',
params => [$depth]
}]},
from => 'aou',
- where => {id => $org}
+ where => {id => $filter_orgs}
}
}
}
if ($grp =~ /^lasso\(([^)]+)\)/) {
$ctx->{search_lasso} = $1;
$ctx->{search_scope} = $grp;
+ $self->search_lasso_orgs;
} elsif ($grp) {
$ctx->{copy_location_group} = $grp;
$ctx->{search_scope} = "location_groups($grp)";
) : [];
}
+sub search_lasso_orgs {
+ my $self = shift;
+ my $ctx = $self->ctx;
+ return $ctx->{search_lasso_orgs} if defined $ctx->{search_lasso_orgs};
+ return undef unless $ctx->{search_lasso};
+
+ # User can access global lassos and those at the current search lib
+ my $lasso_maps = $self->editor->search_actor_org_lasso_map(
+ { lasso => $ctx->{search_lasso} }
+ );
+ $ctx->{search_lasso_orgs} = [ map { $_->org_unit } @$lasso_maps];
+}
+
sub load_lassos {
my $self = shift;
my $ctx = $self->ctx;