[open-ils-commits] r15318 - trunk/Open-ILS/src/perlmods/OpenILS/WWW (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jan 13 22:21:27 EST 2010
Author: dbs
Date: 2010-01-13 22:21:25 -0500 (Wed, 13 Jan 2010)
New Revision: 15318
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Log:
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.
Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm 2010-01-13 22:16:24 UTC (rev 15317)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm 2010-01-14 03:21:25 UTC (rev 15318)
@@ -819,7 +819,11 @@
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{(?<!http:)//}{/}go;
$base =~ s{(?<!http:)//}{/}go;
$unapi =~ s{(?<!http:)//}{/}go;
@@ -835,7 +839,7 @@
my $bucket_tag = "tag:$host,$year:record_bucket/$id";
if ($type eq 'opac') {
- print "Location: $root/../../$locale/skin/$skin/xml/rresult.xml?rt=list&" .
+ print "Location: $root/../../$locale/skin/$skin/xml/rresult.xml?$scope" . "rt=list&" .
join('&', map { "rl=" . $_->target_biblio_record_entry } @{ $bucket->items }) .
"\n\n";
return 302;
@@ -846,7 +850,7 @@
$type,
[ map { $_->target_biblio_record_entry } @{ $bucket->items } ],
$unapi,
- undef,
+ $org_unit->[0]->shortname,
$flesh_feed
);
$feed->root($root);
@@ -863,7 +867,7 @@
$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,7 +901,11 @@
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 @@
# 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 @@
$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 @@
$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 @@
}
}
+=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
More information about the open-ils-commits
mailing list