[open-ils-commits] r8380 - trunk/Open-ILS/src/perlmods/OpenILS/WWW
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Jan 14 17:34:53 EST 2008
Author: miker
Date: 2008-01-14 17:09:33 -0500 (Mon, 14 Jan 2008)
New Revision: 8380
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm
Log:
allow the exporter to accept a container id, for exporting buckets etc
Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm 2008-01-12 01:02:23 UTC (rev 8379)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm 2008-01-14 22:09:33 UTC (rev 8380)
@@ -83,11 +83,25 @@
}
}
+ my $ses = OpenSRF::AppSession->create('open-ils.cstore');
+
+ # still no records ...
+ my $container = $cgi->param('containerid');
+ if ($container) {
+ my $authid = $cgi->cookie('ses') || $cgi->param('ses');
+ my $auth = verify_login($authid);
+ if (!$auth) {
+ return 403;
+ }
+ my $recs = $ses->request( 'open-ils.cstore.direct.container.biblio_record_entry_bucket_item.search.atomic', { bucket => $cointainer } )->gather(1);
+ @records = map { ($_->target_biblio_record_entry) } @$recs;
+ }
+
return show_template($r) unless (@records);
my $type = $cgi->param('rectype') || 'biblio';
if ($type ne 'biblio' && $type ne 'authority') {
- die "Bad record type: $type";
+ return 400;
}
my $tcn_v = 'tcn_value';
@@ -113,9 +127,7 @@
binmode(STDOUT, ':utf8') if ($encoding eq 'UTF-8');
if (!grep { uc($format) eq $_ } @formats) {
- die "Please select a supported format. ".
- "Right now that means one of [".
- join('|', at formats). "]\n";
+ return 400;
}
if ($format ne 'XML') {
@@ -123,7 +135,6 @@
$ftype->require;
}
- my $ses = OpenSRF::AppSession->create('open-ils.cstore');
$r->headers_out->set("Content-Disposition" => "inline; filename=$filename");
@@ -147,7 +158,7 @@
my $req = $ses->request( 'open-ils.cstore.direct.actor.org_unit.search', { id => { '!=' => undef } } );
while (my $o = $req->recv) {
- die $req->failed->stringify if ($req->failed);
+ next if ($req->failed);
$o = $o->content;
last unless ($o);
$orgs{$o->id} = $o;
@@ -157,7 +168,7 @@
$req = $ses->request( 'open-ils.cstore.direct.asset.copy_location.search', { id => { '!=' => undef } } );
while (my $s = $req->recv) {
- die $req->failed->stringify if ($req->failed);
+ next if ($req->failed);
$s = $s->content;
last unless ($s);
$shelves{$s->id} = $s;
@@ -266,6 +277,23 @@
}
+sub verify_login {
+ my $auth_token = shift;
+ return undef unless $auth_token;
+
+ my $user = OpenSRF::AppSession
+ ->create("open-ils.auth")
+ ->request( "open-ils.auth.session.retrieve", $auth_token )
+ ->gather(1);
+
+ if (ref($user) eq 'HASH' && $user->{ilsevent} == 1001) {
+ return undef;
+ }
+
+ return $user if ref($user);
+ return undef;
+}
+
sub show_template {
my $r = shift;
More information about the open-ils-commits
mailing list