From: dbs Date: Fri, 1 May 2009 00:30:44 +0000 (+0000) Subject: Enable org_unit-scoped SRU searches X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ffd9a5ea080989a4870edf51eb43e4d3cf052665;p=Evergreen.git Enable org_unit-scoped SRU searches http://example.com/opac/extras/sru/SHORTNAME will set a search scope of SHORTNAME if the search string does not already contain a site: parameter Combined with simple2zoom configuration, this gives us the ability to surface different Z39.50 "databases" that correspond to various org_units. git-svn-id: svn://svn.open-ils.org/ILS/trunk@13026 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index 6679f710ff..9e6ee71856 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -1599,10 +1599,20 @@ sub sru_search { my $req = SRU::Request->newFromCGI( $cgi ); my $resp = SRU::Response->newFromRequest( $req ); + # Find the org_unit shortname, if passed as part of the URL + # http://example.com/opac/extras/sru/SHORTNAME + my $url = $cgi->path_info; + my ($shortname) = $url =~ m#/?(.*)#; + if ( $resp->type eq 'searchRetrieve' ) { my $cql_query = $req->query; my $search_string = $req->cql->toEvergreen; + # Ensure the search string overrides the default site + if ($shortname and $search_string !~ m#site:#) { + $search_string .= " site:$shortname"; + } + my $offset = $req->startRecord; $offset-- if ($offset); $offset ||= 0; @@ -1762,3 +1772,5 @@ sub sru_search { } 1; + +# vim: noet:ts=4:sw=4