From 338e8f23209f705463064d084673a3e5bb4b9aaa Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 1 Nov 2006 19:39:25 +0000 Subject: [PATCH] full visibility check for copies in the public opac git-svn-id: svn://svn.open-ils.org/ILS/trunk@6539 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Search/Biblio.pm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index 0ae48cd25a..0d7e20ca7e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -1303,12 +1303,31 @@ __PACKAGE__->register_method( api_name => 'open-ils.search.asset.copy.retrieve_by_cn_label', ); +__PACKAGE__->register_method( + method => 'copies_by_cn_label', + api_name => 'open-ils.search.asset.copy.retrieve_by_cn_label.staff', +); + sub copies_by_cn_label { my( $self, $conn, $record, $label, $circ_lib ) = @_; my $e = new_editor(); my $cns = $e->search_asset_call_number({record => $record, label => $label, deleted => 'f'}, {idlist=>1}); return [] unless @$cns; - return $e->search_asset_copy({call_number => $cns, circ_lib => $circ_lib, deleted => 'f'}, {idlist=>1}); + + # show all non-deleted copies in the staff client ... + if ($self->api_name =~ /staff$/o) { + return $e->search_asset_copy({call_number => $cns, circ_lib => $circ_lib, deleted => 'f'}, {idlist=>1}); + } + + # ... otherwise, grab the copies ... + my $copies = $e->search_asset_copy( + [ {call_number => $cns, circ_lib => $circ_lib, deleted => 'f', opac_visible => 't'}, + {flesh => 1, flesh_fields => { acp => [ qw/location status/] } } + ] + ); + + # ... and test for location and status visibility + return [ map { ($U->is_true($_->location->opac_visible) && $U->is_true($_->status->holdable)) ? ($_->id) : () } @$copies ]; } -- 2.11.0