From: atz Date: Wed, 15 Sep 2010 05:25:06 +0000 (+0000) Subject: Allow noauth option for retrieval method to support EDI X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=945dba80a2e9d875652804537aa2f00783cbc6f8;p=evergreen%2Fbjwebb.git Allow noauth option for retrieval method to support EDI EDI scripts run from crontab, w/o an associated user to auth git-svn-id: svn://svn.open-ils.org/ILS/trunk@17689 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm index 9b4e43ee7..81e3fdfc2 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm @@ -501,7 +501,7 @@ sub process_jedi { $detail->estimated_unit_price($price) if $price; # $e->search_acq_edi_account([]); my $touches = 0; - my $eg_lids = $e->retrieve_acq_lineitem_detail({lineitem => $eg_line->id}); + my $eg_lids = $e->retrieve_acq_lineitem_detail({lineitem => $eg_line->id}); # should be the same as $eg_line->lineitem_details my $lidcount = scalar(@$eg_lids); $lidcount == $eg_line->item_count or $logger->warn( sprintf "EDI: LI %s itemcount (%d) mismatch, %d LIDs found", $eg_line->id, $eg_line->item_count, $lidcount @@ -598,7 +598,7 @@ sub message_object { =head2 ->eg_li($lineitem_object, [$server, $editor]) -my $line_item = OpenILS::Application::Acq::EDI->eg_li($edi_line); +my $line_item = OpenILS::Application::Acq::EDI->eg_li($edi_line, $server, $e); $server is a RemoteAccount object @@ -647,13 +647,13 @@ sub eg_li { my $li = OpenILS::Application::Acq::Lineitem::retrieve_lineitem_impl($e, $id, { flesh_li_details => 1, clear_marc => 1, - }); # Could send more {options} + }, 1); # Could send more {options}. The 1 is for no_auth. if (! $li or ref($li) ne 'Fieldmapper::acq::lineitem') { $logger->error("EDI failed to retrieve lineitem by id '$id' for server " . ($server->{remote_host} || $server->{host} || Dumper($server))); return; } - unless ((! $server) or (! $server->provider)) { + unless ((! $server) or (! $server->provider)) { # but here we want $server to be acq.edi_account instead of RemoteAccount/ if ($server->provider != $li->provider) { # links go both ways: acq.provider.edi_default and acq.edi_account.provider $logger->info("EDI acct provider (" . $server->provider. ") doesn't match lineitem provider(" diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm index 8bc40dfc0..5398ba1e8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm @@ -94,7 +94,7 @@ sub retrieve_lineitem { } sub retrieve_lineitem_impl { - my ($e, $li_id, $options) = @_; + my ($e, $li_id, $options, $no_auth) = @_; # no_auth needed for EDI scripts $options ||= {}; my $flesh = { @@ -151,12 +151,12 @@ sub retrieve_lineitem_impl { return $e->event unless ( $li->purchase_order and - $e->allowed(['VIEW_PURCHASE_ORDER', 'CREATE_PURCHASE_ORDER'], - $li->purchase_order->ordering_agency, $li->purchase_order) + ($no_auth or $e->allowed(['VIEW_PURCHASE_ORDER', 'CREATE_PURCHASE_ORDER'], + $li->purchase_order->ordering_agency, $li->purchase_order)) ) or ( $li->picklist and !$li->purchase_order and # user doesn't have view_po perms - $e->allowed(['VIEW_PICKLIST', 'CREATE_PICKLIST'], - $li->picklist->org_unit, $li->picklist) + ($no_auth or $e->allowed(['VIEW_PICKLIST', 'CREATE_PICKLIST'], + $li->picklist->org_unit, $li->picklist)) ); unless ($$options{flesh_po}) {