LP 791546: advanced search ISBN/ISSN in .staff mode
authorDan Scott <dan@coffeecode.net>
Mon, 6 Jun 2011 16:11:58 +0000 (12:11 -0400)
committerDan Wells <dbw2@calvin.edu>
Mon, 6 Jun 2011 19:09:41 +0000 (15:09 -0400)
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 <dscott@laurentian.ca>
Signed-off-by: Dan Wells <dbw2@calvin.edu>

Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
Open-ILS/web/opac/common/js/config.js

index bef8eb7..b0d4fc8 100644 (file)
@@ -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'} };
index 287a126..3011c4a 100644 (file)
@@ -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';