From 6d328afcc86a28fdd9cf43294b4c630b02807a95 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 14 Feb 2014 17:25:44 -0500 Subject: [PATCH] LP#1053397 filter MR icons/formats by org scope Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander Signed-off-by: Dan Wells --- .../lib/OpenILS/Application/Circ/Holds.pm | 33 ++++++++++--------- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 5 +-- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index 66b6391cfe..3eaec7a03f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -2478,7 +2478,7 @@ sub do_possibility_checks { } elsif( $hold_type eq OILS_HOLD_TYPE_METARECORD ) { - my ($recs) = __PACKAGE__->method_lookup('open-ils.circ.holds.metarecord.filterd_records')->run($mrid, $holdable_formats, $selection_ou, $depth); + my ($recs) = __PACKAGE__->method_lookup('open-ils.circ.holds.metarecord.filtered_records')->run($mrid, $holdable_formats, $selection_ou, $depth); my @status = (); for my $rec (@$recs) { @status = _check_title_hold_is_possible( @@ -2504,7 +2504,7 @@ sub MR_filter_records { } __PACKAGE__->register_method( method => 'MR_filter_records', - api_name => 'open-ils.circ.holds.metarecord.filterd_records', + api_name => 'open-ils.circ.holds.metarecord.filtered_records', ); @@ -4227,6 +4227,7 @@ __PACKAGE__->register_method( /, params => [ {desc => 'Metarecord ID', type => 'number'}, + {desc => 'Context Org ID', type => 'number'}, {desc => 'Hold ID List', type => 'array'}, ], return => { @@ -4241,18 +4242,19 @@ __PACKAGE__->register_method( } ); -sub mr_hold_filter_attrs { - my ($self, $client, $mr_id, $hold_ids) = @_; +sub mr_hold_filter_attrs { + my ($self, $client, $mr_id, $org_id, $hold_ids) = @_; my $e = new_editor(); + # providing a context org means we filter out records that + # cannot possibly be held. + my $org_depth = $U->ou_ancestor_setting_value( + $org_id, OILS_SETTING_HOLD_HARD_BOUNDARY) if $org_id; - my $mr = $e->retrieve_metabib_metarecord($mr_id) or return $e->event; - my $bre_ids = $e->json_query({ - select => {mmrsm => ['source']}, - from => 'mmrsm', - where => {'+mmrsm' => {metarecord => $mr_id}} - }); - $bre_ids = [map {$_->{source}} @$bre_ids]; + # get all org-scoped records w/ holdable copies for this metarecord + my ($bre_ids) = $self->method_lookup( + 'open-ils.circ.holds.metarecord.filtered_records')->run( + $mr_id, undef, $org_id, $org_depth); my $item_lang_attr = 'item_lang'; # configurable? my $format_attr = $e->retrieve_config_global_flag( @@ -4302,10 +4304,10 @@ sub mr_hold_filter_attrs { } }; - # collect the ccvm's for the selected formats / language ( + # collect the ccvm's for the selected formats / language # (i.e. the holdable formats) on the MR. # this assumes a two-key structure for format / language, - # though assumption is made about the keys themselves. + # though no assumption is made about the keys themselves. my $hformats = OpenSRF::Utils::JSON->JSON2perl($hold->holdable_formats); my $lang_vals = []; my $format_vals = []; @@ -4329,8 +4331,9 @@ sub mr_hold_filter_attrs { # find all of the bib records within this metarcord whose # format / language match the holdable formats on the hold my ($bre_ids) = $self->method_lookup( - 'open-ils.circ.holds.metarecord.filterd_records')->run( - $hold->target, $hold->holdable_formats); + 'open-ils.circ.holds.metarecord.filtered_records')->run( + $hold->target, $hold->holdable_formats, + $hold->selection_ou, $hold->selection_depth); # now find all of the 'icon' attributes for the records $resp->{hold}{icons} = get_batch_ccvms($e, $icon_attr, $bre_ids); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 3961984cac..d992fdad38 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -586,7 +586,7 @@ sub fetch_user_holds { my $filter_data = $U->simplereq( 'open-ils.circ', 'open-ils.circ.mmr.holds.filters.authoritative.atomic', - $hold->target, [$hold->id] + $hold->target, $hold->selection_ou, [$hold->id] ); $blob->{metarecord_filters} = @@ -818,9 +818,10 @@ sub load_place_hold { for my $id (@targets) { my ($mr) = grep {$_->id eq $id} @$mrecs; + my $ou_id = $cgi->param('pickup_lib') || $self->ctx->{search_ou}; my $filter_data = $U->simplereq( 'open-ils.circ', - 'open-ils.circ.mmr.holds.filters.authoritative', $mr->id); + 'open-ils.circ.mmr.holds.filters.authoritative', $mr->id, $ou_id); my $holdable_formats = $self->compile_holdable_formats($mr->id); -- 2.43.2