From 19685ce120646a4eec75322f387d93d7d64a4e38 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Mon, 6 Jun 2011 12:11:58 -0400 Subject: [PATCH] LP 791546: advanced search ISBN/ISSN in .staff mode In 1.6, advanced search ISBN/ISSN searches always operated in .staff mode, returning results whether the results should have been visible to the user or not. This confused patrons who saw records to which they had no access. In 2.0, this behaviour changed so that advanced search ISBN/ISSN searches never operated in .staff mode. This confused staff who were used to retrieving records via the ISBN/ISSN search when they wanted to add holdings for their own library to the records. The pattern for addressing this problem and satisfying both use cases is the same - use the multiclass.query.staff method if we invoke the ISBN or ISSN searches with the .staff method name. One could easily refactor many of the search method bodies in this module to use the exact same logic, keying off the method name to identify the identifier field and the .staff portion of the method name to determine whether to invoke .staff mode or not. For now we just address the ISBN and ISSN entry points. Signed-off-by: Dan Scott Signed-off-by: Dan Wells --- .../lib/OpenILS/Application/Search/Biblio.pm | 32 ++++++++++++++++++---- Open-ILS/web/opac/common/js/config.js | 4 +-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index bef8eb7b59..b0d4fc872e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -2195,11 +2195,15 @@ sub marc_search { } +foreach my $isbn_method (qw/ + open-ils.search.biblio.isbn + open-ils.search.biblio.isbn.staff +/) { __PACKAGE__->register_method( method => "biblio_search_isbn", - api_name => "open-ils.search.biblio.isbn", + api_name => $isbn_method, signature => { - desc => 'Retrieve biblio IDs for a given ISBN', + desc => 'Retrieve biblio IDs for a given ISBN. The .staff version of the call includes otherwise hidden hits.', params => [ {desc => 'ISBN', type => 'string'} ], @@ -2209,6 +2213,7 @@ __PACKAGE__->register_method( } } ); +} sub biblio_search_isbn { my( $self, $client, $isbn ) = @_; @@ -2220,7 +2225,13 @@ sub biblio_search_isbn { # reworking 'open-ils.storage.id_list.biblio.record_entry.search.isbn', # which is functionally deprecated at this point, or a custom call to # 'open-ils.storage.biblio.multiclass.search_fts' - my $method = $self->method_lookup('open-ils.search.biblio.multiclass.query'); + + my $isbn_method = 'open-ils.search.biblio.multiclass.query'; + if ($self->api_name =~ m/.staff$/) { + $isbn_method .= '.staff'; + } + + my $method = $self->method_lookup($isbn_method); my ($search_result) = $method->run({'limit' => 1000000}, "identifier|isbn:$isbn"); my @recs = map { $_->[0] } @{$search_result->{'ids'}}; return { ids => \@recs, count => $search_result->{'count'} }; @@ -2250,9 +2261,13 @@ sub biblio_search_isbn_batch { return { ids => \@recs, count => scalar(@recs) }; } +foreach my $issn_method (qw/ + open-ils.search.biblio.issn + open-ils.search.biblio.issn.staff +/) { __PACKAGE__->register_method( method => "biblio_search_issn", - api_name => "open-ils.search.biblio.issn", + api_name => $issn_method, signature => { desc => 'Retrieve biblio IDs for a given ISSN', params => [ @@ -2264,6 +2279,7 @@ __PACKAGE__->register_method( } } ); +} sub biblio_search_issn { my( $self, $client, $issn ) = @_; @@ -2275,7 +2291,13 @@ sub biblio_search_issn { # reworking 'open-ils.storage.id_list.biblio.record_entry.search.issn', # which is functionally deprecated at this point, or a custom call to # 'open-ils.storage.biblio.multiclass.search_fts' - my $method = $self->method_lookup('open-ils.search.biblio.multiclass.query'); + + my $issn_method = 'open-ils.search.biblio.multiclass.query'; + if ($self->api_name =~ m/.staff$/) { + $issn_method .= '.staff'; + } + + my $method = $self->method_lookup($issn_method); my ($search_result) = $method->run({'limit' => 1000000}, "identifier|issn:$issn"); my @recs = map { $_->[0] } @{$search_result->{'ids'}}; return { ids => \@recs, count => $search_result->{'count'} }; diff --git a/Open-ILS/web/opac/common/js/config.js b/Open-ILS/web/opac/common/js/config.js index 287a126f6d..3011c4a776 100644 --- a/Open-ILS/web/opac/common/js/config.js +++ b/Open-ILS/web/opac/common/js/config.js @@ -336,8 +336,8 @@ var FETCH_TOC = "open-ils.search:open-ils.search.added_content.toc.retrieve var FETCH_ACONT_SUMMARY = "open-ils.search:open-ils.search.added_content.summary.retrieve"; var FETCH_USER_BYBARCODE = "open-ils.actor:open-ils.actor.user.fleshed.retrieve_by_barcode"; var FETCH_ADV_MARC_MRIDS = "open-ils.search:open-ils.search.biblio.marc:1"; -var FETCH_ADV_ISBN_RIDS = "open-ils.search:open-ils.search.biblio.isbn"; -var FETCH_ADV_ISSN_RIDS = "open-ils.search:open-ils.search.biblio.issn"; +var FETCH_ADV_ISBN_RIDS = "open-ils.search:open-ils.search.biblio.isbn:1"; +var FETCH_ADV_ISSN_RIDS = "open-ils.search:open-ils.search.biblio.issn:1"; var FETCH_ADV_TCN_RIDS = "open-ils.search:open-ils.search.biblio.tcn"; var FETCH_CNBROWSE = 'open-ils.search:open-ils.search.callnumber.browse'; var FETCH_CONTAINERS = 'open-ils.actor:open-ils.actor.container.retrieve_by_class'; -- 2.11.0