From 80a80944deb39d8703ee4d138158970bf5da1fe3 Mon Sep 17 00:00:00 2001 From: dbs Date: Thu, 14 Jan 2010 03:21:25 +0000 Subject: [PATCH] Factor out the aou-fetching code into a useful subroutine, get_ou($org) Then use get_ou to make the bookbag_feed and changes_feed marginally smarter, so that you can now pass ?searchOrg=BR1 or ?searchOrg=4 to limit the holdings display scope. Useful stuff if you're plodding along with bookbags-as-reserves in a consortial environment. git-svn-id: svn://svn.open-ils.org/ILS/trunk@15318 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm | 60 ++++++++++++++++++--------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index 379320dc6d..6afdc0ca7d 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -819,6 +819,10 @@ sub bookbag_feed { my $skin = $cgi->param('skin') || 'default'; my $locale = $cgi->param('locale') || 'en-US'; + my $org = $cgi->param('searchOrg'); + + my $org_unit = get_ou($org); + my $scope = "l=" . $org_unit->[0]->id . "&"; $root =~ s{(?target_biblio_record_entry } @{ $bucket->items }) . "\n\n"; return 302; @@ -846,7 +850,7 @@ sub bookbag_feed { $type, [ map { $_->target_biblio_record_entry } @{ $bucket->items } ], $unapi, - undef, + $org_unit->[0]->shortname, $flesh_feed ); $feed->root($root); @@ -863,7 +867,7 @@ sub bookbag_feed { $feed->link( OPAC => - $host . "/opac/$locale/skin/$skin/xml/rresult.xml?rt=list&" . + "http://$host/opac/$locale/skin/$skin/xml/rresult.xml?$scope" . "rt=list&" . join('&', map { 'rl=' . $_->target_biblio_record_entry } @{$bucket->items} ), 'text/html' ); @@ -897,6 +901,10 @@ sub changes_feed { my $skin = $cgi->param('skin') || 'default'; my $locale = $cgi->param('locale') || 'en-US'; + my $org = $cgi->param('searchOrg'); + + my $org_unit = get_ou($org); + my $scope = "l=" . $org_unit->[0]->id . "&"; my $path = $cgi->path_info; #warn "URL breakdown: $url ($rel_name) -> $root -> $base -> $path -> $unapi"; @@ -917,7 +925,7 @@ sub changes_feed { # return 302; #} - my $feed = create_record_feed( 'record', $type, $list, $unapi, undef, $flesh_feed); + my $feed = create_record_feed( 'record', $type, $list, $unapi, $org_unit->[0]->shortname, $flesh_feed); $feed->root($root); if ($date) { @@ -936,7 +944,7 @@ sub changes_feed { $feed->link( OPAC => - $host . "/opac/$locale/skin/$skin/xml/rresult.xml?rt=list&" . + "http://$host/opac/$locale/skin/$skin/xml/rresult.xml?$scope" . "rt=list&" . join('&', map { 'rl=' . $_} @$list ), 'text/html' ); @@ -1120,20 +1128,7 @@ sub opensearch_feed { $log->debug("OpenSearch terms: $terms"); - my $org_unit; - if ($org eq '-') { - $org_unit = $actor->request( - 'open-ils.actor.org_unit_list.search' => parent_ou => undef - )->gather(1); - } elsif ($org !~ /^\d+$/o) { - $org_unit = $actor->request( - 'open-ils.actor.org_unit_list.search' => shortname => uc($org) - )->gather(1); - } else { - $org_unit = $actor->request( - 'open-ils.actor.org_unit_list.search' => id => $org - )->gather(1); - } + my $org_unit = get_ou($org); # Apostrophes break search and get indexed as spaces anyway my $safe_terms = $terms; @@ -1895,6 +1890,33 @@ sub sru_search { } } +=head2 get_ou($org_unit) + +Returns an aou object for a given actor.org_unit shortname or ID. + +=cut + +sub get_ou { + my $org = shift || '-'; + my $org_unit; + + if ($org eq '-') { + $org_unit = $actor->request( + 'open-ils.actor.org_unit_list.search' => parent_ou => undef + )->gather(1); + } elsif ($org !~ /^\d+$/o) { + $org_unit = $actor->request( + 'open-ils.actor.org_unit_list.search' => shortname => uc($org) + )->gather(1); + } else { + $org_unit = $actor->request( + 'open-ils.actor.org_unit_list.search' => id => $org + )->gather(1); + } + + return $org_unit; +} + 1; # vim: noet:ts=4:sw=4 -- 2.11.0