);
sub register_workstation {
- my( $self, $conn, $authtoken, $name, $owner ) = @_;
+ my( $self, $conn, $authtoken, $name, $owner, $oargs ) = @_;
my $e = new_editor(authtoken=>$authtoken, xact=>1);
return $e->die_event unless $e->checkauth;
return $e->die_event unless $e->allowed('REGISTER_WORKSTATION', $owner);
my $existing = $e->search_actor_workstation({name => $name})->[0];
+ $oargs = { all => 1 } unless defined $oargs;
if( $existing ) {
- if( $self->api_name =~ /override/o ) {
+ if( $self->api_name =~ /override/o && ($oargs->{all} || grep { $_ eq 'WORKSTATION_NAME_EXISTS' } @{$oargs->{events}}) ) {
# workstation with the given name exists.
if($owner ne $existing->owning_lib) {
);
sub really_delete_user {
- my($self, $conn, $auth, $user_id, $dest_user_id) = @_;
+ my($self, $conn, $auth, $user_id, $dest_user_id, $oargs) = @_;
my $e = new_editor(authtoken => $auth, xact => 1);
return $e->die_event unless $e->checkauth;
+ $oargs = { all => 1 } unless defined $oargs;
# Find all unclosed billings for for user $user_id, thereby, also checking for open circs
my $open_bills = $e->json_query({
# No deleting patrons with open billings or checked out copies, unless perm-enabled override
if (@$open_bills) {
return $e->die_event(OpenILS::Event->new('ACTOR_USER_DELETE_OPEN_XACTS'))
- unless $self->api_name =~ /override/o
+ unless $self->api_name =~ /override/o && ($oargs->{all} || grep { $_ eq 'ACTOR_USER_DELETE_OPEN_XACTS' } @{$oargs->{events}})
&& $e->allowed('ACTOR_USER_DELETE_OPEN_XACTS.override', $user->home_ou);
}
# No deleting yourself - UI is supposed to stop you first, though.
);
sub create_record_xml {
- my( $self, $client, $login, $xml, $source ) = @_;
+ my( $self, $client, $login, $xml, $source, $oargs ) = @_;
my $override = 1 if $self->api_name =~ /override/;
+ $oargs = { all => 1 } unless defined $oargs;
my( $user_obj, $evt ) = $U->checksesperm($login, 'CREATE_MARC');
return $evt if $evt;
$meth = $self->method_lookup(
"open-ils.cat.biblio.record.xml.import.override") if $override;
- my ($s) = $meth->run($login, $xml, $source);
+ my ($s) = $meth->run($login, $xml, $source, $oargs);
return $s;
}
);
sub biblio_record_replace_marc {
- my( $self, $conn, $auth, $recid, $newxml, $source ) = @_;
+ my( $self, $conn, $auth, $recid, $newxml, $source, $oargs ) = @_;
my $e = new_editor(authtoken=>$auth, xact=>1);
return $e->die_event unless $e->checkauth;
return $e->die_event unless $e->allowed('CREATE_MARC', $e->requestor->ws_ou);
my $fix_tcn = $self->api_name =~ /replace/o;
- my $override = $self->api_name =~ /override/o;
+ if($self->api_name =~ /override/o) {
+ $oargs = { all => 1 } unless defined $oargs;
+ } else {
+ $oargs = {};
+ }
my $res = OpenILS::Application::Cat::BibCommon->biblio_record_replace_marc(
- $e, $recid, $newxml, $source, $fix_tcn, $override);
+ $e, $recid, $newxml, $source, $fix_tcn, $oargs);
$e->commit unless $U->event_code($res);
sub biblio_record_xml_import {
- my( $self, $client, $authtoken, $xml, $source, $auto_tcn) = @_;
+ my( $self, $client, $authtoken, $xml, $source, $auto_tcn, $oargs) = @_;
my $e = new_editor(xact=>1, authtoken=>$authtoken);
return $e->die_event unless $e->checkauth;
return $e->die_event unless $e->allowed('IMPORT_MARC', $e->requestor->ws_ou);
- my $override = $self->api_name =~ /override/;
+ if ($self->api_name =~ /override/) {
+ $oargs = { all => 1 } unless defined $oargs;
+ } else {
+ $oargs = {};
+ }
my $record = OpenILS::Application::Cat::BibCommon->biblio_record_xml_import(
- $e, $xml, $source, $auto_tcn, $override);
+ $e, $xml, $source, $auto_tcn, $oargs);
return $record if $U->event_code($record);
sub fleshed_copy_update {
- my( $self, $conn, $auth, $copies, $delete_stats ) = @_;
+ my( $self, $conn, $auth, $copies, $delete_stats, $oargs ) = @_;
return 1 unless ref $copies;
my( $reqr, $evt ) = $U->checkses($auth);
return $evt if $evt;
my $editor = new_editor(requestor => $reqr, xact => 1);
- my $override = $self->api_name =~ /override/;
+ if ($self->api_name =~ /override/) {
+ $oargs = { all => 1 } unless defined $oargs;
+ } else {
+ $oargs = {};
+ }
my $retarget_holds = [];
$evt = OpenILS::Application::Cat::AssetCommon->update_fleshed_copies(
- $editor, $override, undef, $copies, $delete_stats, $retarget_holds, undef);
+ $editor, $oargs, undef, $copies, $delete_stats, $retarget_holds, undef);
if( $evt ) {
$logger->info("fleshed copy update failed with event: ".OpenSRF::Utils::JSON->perl2JSON($evt));
api_name => "open-ils.cat.asset.volume.fleshed.batch.update.override",);
sub fleshed_volume_update {
- my( $self, $conn, $auth, $volumes, $delete_stats, $options ) = @_;
+ my( $self, $conn, $auth, $volumes, $delete_stats, $options, $oargs ) = @_;
my( $reqr, $evt ) = $U->checkses($auth);
return $evt if $evt;
$options ||= {};
- my $override = ($self->api_name =~ /override/);
+ if ($self->api_name =~ /override/) {
+ $oargs = { all => 1 } unless defined $oargs;
+ } else {
+ $oargs = {};
+ }
my $editor = new_editor( requestor => $reqr, xact => 1 );
my $retarget_holds = [];
my $auto_merge_vols = $options->{auto_merge_vols};
return $editor->die_event unless
$editor->allowed('UPDATE_VOLUME', $vol->owning_lib);
- if(my $evt = $assetcom->delete_volume($editor, $vol, $override, $$options{force_delete_copies})) {
+ if(my $evt = $assetcom->delete_volume($editor, $vol, $oargs, $$options{force_delete_copies})) {
$editor->rollback;
return $evt;
}
} elsif( $vol->isnew ) {
$logger->info("vol-update: creating volume");
- $evt = $assetcom->create_volume( $override, $editor, $vol );
+ $evt = $assetcom->create_volume( $oargs, $editor, $vol );
return $evt if $evt;
} elsif( $vol->ischanged ) {
$logger->info("vol-update: update volume");
- my $resp = update_volume($vol, $editor, ($override or $auto_merge_vols));
+ my $resp = update_volume($vol, $editor, ($oargs->{all} or grep { $_ eq 'VOLUME_LABEL_EXISTS' } @{$oargs->{events}} or $auto_merge_vols));
return $resp->{evt} if $resp->{evt};
$vol = $resp->{merge_vol};
}
if( $copies and @$copies and !$vol->isdeleted ) {
$_->call_number($vol->id) for @$copies;
$evt = $assetcom->update_fleshed_copies(
- $editor, $override, $vol, $copies, $delete_stats, $retarget_holds, undef);
+ $editor, $oargs, $vol, $copies, $delete_stats, $retarget_holds, undef);
return $evt if $evt;
}
}
sub batch_volume_transfer {
- my( $self, $conn, $auth, $args ) = @_;
+ my( $self, $conn, $auth, $args, $oargs ) = @_;
my $evt;
my $rec = $$args{docid};
my $vol_ids = $$args{volumes};
my $override = 1 if $self->api_name =~ /override/;
+ $oargs = { all => 1 } unless defined $oargs;
$logger->info("merge: transferring volumes to lib=$o_lib and record=$rec");
# for each volume, see if there are any copies that have a
# remote circ_lib (circ_lib != vol->owning_lib and != $o_lib ).
# if so, warn them
- unless( $override ) {
+ unless( $override && ($oargs->{all} || grep { $_ eq 'COPY_REMOTE_CIRC_LIB' } @{$oargs->{events}}) ) {
for my $v (@all) {
$logger->debug("merge: searching for copies with remote circ_lib for volume ".$v->id);
);
sub create_serial_record_xml {
- my( $self, $client, $login, $source, $owning_lib, $record_id, $xml ) = @_;
+ my( $self, $client, $login, $source, $owning_lib, $record_id, $xml, $oargs ) = @_;
my $override = 1 if $self->api_name =~ /override/; # not currently used
+ $oargs = { all => 1 } unless defined $oargs; # Not currently used, but here for consistency.
my $e = new_editor(xact=>1, authtoken=>$login);
return $e->die_event unless $e->checkauth;
sub update_copy {
my($class, $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib) = @_;
+ $override = { all => 1 } if($override && !ref $override);
+ $override = { all => 0 } if(!ref $override);
+
my $evt;
my $org = (ref $copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;
return $evt if ( $evt = $class->org_cannot_have_vols($editor, $org) );
sub update_fleshed_copies {
my($class, $editor, $override, $vol, $copies, $delete_stats, $retarget_holds, $force_delete_empty_bib) = @_;
+ $override = { all => 1 } if($override && !ref $override);
+ $override = { all => 0 } if(!ref $override);
+
my $evt;
my $fetchvol = ($vol) ? 0 : 1;
return $editor->event unless
$editor->allowed('DELETE_COPY', $class->copy_perm_org($vol, $copy));
+ $override = { all => 1 } if($override && !ref $override);
+ $override = { all => 0 } if(!ref $override);
+
my $stat = $U->copy_status($copy->status);
if ($U->is_true($stat->restrict_copy_delete)) {
- if ($override) {
+ if ($override->{all} || grep { $_ eq 'COPY_DELETE_WARNING' } @{$override->{events}}) {
return $editor->event unless $editor->allowed('COPY_DELETE_WARNING.override', $class->copy_perm_org($vol, $copy))
} else {
return OpenILS::Event->new('COPY_DELETE_WARNING', payload => $copy->id )
return $evt if ( $evt = $class->org_cannot_have_vols($editor, $vol->owning_lib) );
+ $override = { all => 1 } if($override && !ref $override);
+ $override = { all => 0 } if(!ref $override);
+
# see if the record this volume references is marked as deleted
my $rec = $editor->retrieve_biblio_record_entry($vol->record)
or return $editor->die_event;
my $label = undef;
if(@$vols) {
# we've found an exising volume
- if($override) {
+ if($override->{all} || grep { $_ eq 'VOLUME_LABEL_EXISTS' } @{$override->{events}}) {
$label = $vol->label;
} else {
return OpenILS::Event->new(
sub remove_empty_objects {
my($class, $editor, $override, $vol, $force_delete_empty_bib) = @_;
+ $override = { all => 1 } if($override && !ref $override);
+ $override = { all => 0 } if(!ref $override);
+
my $koe = $U->ou_ancestor_setting_value(
$editor->requestor->ws_ou, 'cat.bib.keep_on_empty', $editor);
my $aoe = $U->ou_ancestor_setting_value(
}
return OpenILS::Event->new('TITLE_LAST_COPY', payload => $vol->record )
- if $aoe and not $override and not $force_delete_empty_bib;
+ if $aoe and not ($override->{all} || grep { $_ eq 'TITLE_LAST_COPY' } @{$override->{events}}) and not $force_delete_empty_bib;
unless($koe and not $force_delete_empty_bib) {
# delete the bib record if the keep-on-empty setting is not set (and we're not otherwise forcing things, say through acq settings)
sub biblio_record_replace_marc {
my($class, $e, $recid, $newxml, $source, $fixtcn, $override) = @_;
+ $override = { all => 1 } if($override && !ref $override);
+ $override = { all => 0 } if(!ref $override);
+
my $rec = $e->retrieve_biblio_record_entry($recid)
or return $e->die_event;
my( $tcn, $tsource, $marcdoc, $evt);
- if($fixtcn or $override) {
+ if($fixtcn or $override->{all} or $override->{events}) {
($tcn, $tsource, $marcdoc, $evt) =
_find_tcn_info($e, $newxml, $override, $recid);
sub biblio_record_xml_import {
my($class, $e, $xml, $source, $auto_tcn, $override) = @_;
+ $override = { all => 1 } if($override && !ref $override);
+ $override = { all => 0 } if(!ref $override);
+
my( $evt, $tcn, $tcn_source, $marcdoc );
my $use_id = $e->retrieve_config_global_flag('cat.bib.use_id_for_tcn');
my $override = shift;
my $existing_rec = shift || 0;
+ $override = { all => 1 } if($override && !ref $override);
+ $override = { all => 0 } if(!ref $override);
+
# parse the XML
my $marcxml = __make_marc_doc($xml);
$tcn = find_free_tcn( $marcxml, $editor, $existing_rec );
# if we're overriding, try to find a different TCN to use
- if( $override ) {
+ if( $override->{all} || grep { $_ eq 'TCN_EXISTS' } @{$override->{events}} ) {
# XXX Create ALLOW_ALT_TCN permission check support
);
sub set_circ_claims_returned {
- my( $self, $conn, $auth, $args ) = @_;
+ my( $self, $conn, $auth, $args, $oargs ) = @_;
my $e = new_editor(authtoken=>$auth, xact=>1);
return $e->die_event unless $e->checkauth;
+ $oargs = { all => 1 } unless defined $oargs;
+
my $barcode = $$args{barcode};
my $backdate = $$args{backdate};
# 0 means all attempts require an override
if(defined $max_count and $patron->claims_returned_count >= $max_count) {
- if($self->api_name =~ /override/) {
+ if($self->api_name =~ /override/ && ($oargs->{all} || grep { $_ eq 'PATRON_EXCEEDS_CLAIMS_RETURN_COUNT' } @{$oargs->{events}})) {
# see if we're allowed to override
return $e->die_event unless
}
}
- my ($res) = $self->method_lookup('open-ils.circ.checkout.full.override')->run($e->authtoken,$co_params);
+ my ($res) = $self->method_lookup('open-ils.circ.checkout.full.override')->run($e->authtoken,$co_params,{ all => 1 });
if (ref $res ne 'ARRAY') { $res = [ $res ]; }
if ( $res->[0]->{textcode} eq 'SUCCESS' ) {
$logger->info('open-ils.circ.mark_item_missing_pieces: successful checkout');
sub run_method {
- my( $self, $conn, $auth, $args ) = @_;
+ my( $self, $conn, $auth, $args, $oargs ) = @_;
translate_legacy_args($args);
+ $oargs = { all => 1 } unless defined $oargs;
my $api = $self->api_name;
my $circulator =
- OpenILS::Application::Circ::Circulator->new($auth, %$args);
+ OpenILS::Application::Circ::Circulator->new($auth, %$args, $oargs);
return circ_events($circulator) if $circulator->bail_out;
hold_as_transit
fake_hold_dest
limit_groups
+ override_args
/;
sub new {
- my( $class, $auth, %args ) = @_;
+ my( $class, $auth, %args, $oargs ) = @_;
$class = ref($class) || $class;
my $self = bless( {}, $class );
$self->events([]);
$self->editor(new_editor(xact => 1, authtoken => $auth));
+ $self->override_args($oargs);
unless( $self->editor->checkauth ) {
$self->bail_on_events($self->editor->event);
my $self = shift;
my @events = @{$self->events};
return unless @events;
+ my $oargs = $self->override_args;
if(!$self->override) {
return $self->bail_out(1)
$self->events([]);
- for my $e (@events) {
- my $tc = $e->{textcode};
- next if $tc eq 'SUCCESS';
- my $ov = "$tc.override";
- $logger->info("circulator: attempting to override event: $ov");
+ for my $e (@events) {
+ my $tc = $e->{textcode};
+ next if $tc eq 'SUCCESS';
+ if($oargs->{all} || grep { $_ eq $tc } @{$oargs->{events}}) {
+ my $ov = "$tc.override";
+ $logger->info("circulator: attempting to override event: $ov");
- return $self->bail_on_events($self->editor->event)
- unless( $self->editor->allowed($ov) );
+ return $self->bail_on_events($self->editor->event)
+ unless( $self->editor->allowed($ov) );
+ } else {
+ return $self->bail_out(1);
+ }
}
}
my $evt;
# - If the caller has set the override flag, we will check the item in
- if($self->override) {
+ if($self->override && ($self->override_args->{all} || grep { $_ eq 'CIRC_CLAIMS_RETURNED' } @{$self->override_args->{events}}) ) {
$CR->checkin_time('now');
$CR->checkin_scan_time('now');
sub test_and_create_hold_batch {
- my( $self, $conn, $auth, $params, $target_list ) = @_;
+ my( $self, $conn, $auth, $params, $target_list, $oargs ) = @_;
my $override = 1 if $self->api_name =~ /override/;
+ $oargs = { all => 1 } unless defined $oargs;
my $e = new_editor(authtoken=>$auth);
return $e->die_event unless $e->checkauth;
foreach (@$target_list) {
$$params{$target_field} = $_;
my $res;
- if (! $override) {
- ($res) = $self->method_lookup(
- 'open-ils.circ.title_hold.is_possible')->run($auth, $params);
- }
- if ($override || $res->{'success'} == 1) {
+ ($res) = $self->method_lookup(
+ 'open-ils.circ.title_hold.is_possible')->run($auth, $params, $override ? $oargs : {});
+ if ($res->{'success'} == 1) {
my $ahr = construct_hold_request_object($params);
my ($res2) = $self->method_lookup(
$override
? 'open-ils.circ.holds.create.override'
: 'open-ils.circ.holds.create'
- )->run($auth, $ahr);
+ )->run($auth, $ahr, $oargs);
$res2 = {
'target' => $$params{$target_field},
'result' => $res2
sub create_hold_batch {
- my( $self, $conn, $auth, $hold_list ) = @_;
+ my( $self, $conn, $auth, $hold_list, $oargs ) = @_;
(my $method = $self->api_name) =~ s/\.batch//og;
foreach (@$hold_list) {
- my ($res) = $self->method_lookup($method)->run($auth, $_);
+ my ($res) = $self->method_lookup($method)->run($auth, $_, $oargs);
$conn->respond($res);
}
return undef;
);
sub create_hold {
- my( $self, $conn, $auth, $hold ) = @_;
+ my( $self, $conn, $auth, $hold, $oargs ) = @_;
return -1 unless $hold;
my $e = new_editor(authtoken=>$auth, xact=>1);
return $e->die_event unless $e->checkauth;
my $override = 1 if $self->api_name =~ /override/;
+ $oargs = { all => 1 } unless defined $oargs;
my @events;
for my $evt (@events) {
next unless $evt;
my $name = $evt->{textcode};
- return $e->die_event unless $e->allowed("$name.override", $porg);
+ if($oargs->{all} || grep { $_ eq $name } @{$oargs->{events}}) {
+ return $e->die_event unless $e->allowed("$name.override", $porg);
+ } else {
+ $e->rollback;
+ return \@events;
+ }
}
}
);
sub check_title_hold_batch {
- my($self, $client, $authtoken, $param_list) = @_;
+ my($self, $client, $authtoken, $param_list, $oargs) = @_;
foreach (@$param_list) {
- my ($res) = $self->method_lookup('open-ils.circ.title_hold.is_possible')->run($authtoken, $_);
+ my ($res) = $self->method_lookup('open-ils.circ.title_hold.is_possible')->run($authtoken, $_, $oargs);
$client->respond($res);
}
return undef;
# FIXME: specify proper usage/interaction of selection_ou and pickup_lib
sub check_title_hold {
- my( $self, $client, $authtoken, $params ) = @_;
+ my( $self, $client, $authtoken, $params, $oargs ) = @_;
my $e = new_editor(authtoken=>$authtoken);
return $e->event unless $e->checkauth;
+ $oargs = {} unless defined $oargs;
+
+ if($oargs->{events}) {
+ @{$oargs->{events}} = grep { $e->allowed($_ . '.override', $e->requestor->ws_ou); } @{$oargs->{events}};
+ }
my %params = %$params;
my $depth = $params{depth} || 0;
my $depth = $soft_boundary;
while($depth >= $min_depth) {
$logger->info("performing hold possibility check with soft boundary $depth");
- @status = do_possibility_checks($e, $patron, $request_lib, $depth, %params);
+ @status = do_possibility_checks($e, $patron, $request_lib, $depth, %params, $oargs);
if ($status[0]) {
$return_depth = $depth;
last;
} elsif(defined $hard_boundary and $depth < $hard_boundary) {
# there is no soft boundary, enforce the hard boundary if it exists
$logger->info("performing hold possibility check with hard boundary $hard_boundary");
- @status = do_possibility_checks($e, $patron, $request_lib, $hard_boundary, %params);
+ @status = do_possibility_checks($e, $patron, $request_lib, $hard_boundary, %params, $oargs);
} else {
# no boundaries defined, fall back to user specifed boundary or no boundary
$logger->info("performing hold possibility check with no boundary");
- @status = do_possibility_checks($e, $patron, $request_lib, $params{depth}, %params);
+ @status = do_possibility_checks($e, $patron, $request_lib, $params{depth}, %params, $oargs);
}
my $place_unfillable = 0;
sub do_possibility_checks {
- my($e, $patron, $request_lib, $depth, %params) = @_;
+ my($e, $patron, $request_lib, $depth, %params, $oargs) = @_;
my $issuanceid = $params{issuanceid} || "";
my $partid = $params{partid} || "";
return (1, 1, []) if( $hold_type eq OILS_HOLD_TYPE_RECALL || $hold_type eq OILS_HOLD_TYPE_FORCE);
return verify_copy_for_hold(
- $patron, $e->requestor, $title, $copy, $pickup_lib, $request_lib
+ $patron, $e->requestor, $title, $copy, $pickup_lib, $request_lib, $oargs
);
} elsif( $hold_type eq OILS_HOLD_TYPE_VOLUME ) {
return $e->event unless $title = $e->retrieve_biblio_record_entry($volume->record);
return _check_volume_hold_is_possible(
- $volume, $title, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou
+ $volume, $title, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou, $oargs
);
} elsif( $hold_type eq OILS_HOLD_TYPE_TITLE ) {
return _check_title_hold_is_possible(
- $titleid, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou
+ $titleid, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou, $oargs
);
} elsif( $hold_type eq OILS_HOLD_TYPE_ISSUANCE ) {
return _check_issuance_hold_is_possible(
- $issuanceid, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou
+ $issuanceid, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou, $oargs
);
} elsif( $hold_type eq OILS_HOLD_TYPE_MONOPART ) {
return _check_monopart_hold_is_possible(
- $partid, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou
+ $partid, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou, $oargs
);
} elsif( $hold_type eq OILS_HOLD_TYPE_METARECORD ) {
my @status = ();
for my $rec (@recs) {
@status = _check_title_hold_is_possible(
- $rec, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou, $holdable_formats
+ $rec, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou, $holdable_formats, $oargs
);
last if $status[0];
}
sub _check_title_hold_is_possible {
- my( $titleid, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou, $holdable_formats ) = @_;
+ my( $titleid, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou, $holdable_formats, $oargs ) = @_;
my ($types, $formats, $lang);
if (defined($holdable_formats)) {
}
@status = verify_copy_for_hold(
- $patron, $requestor, $title, $copy, $pickup_lib, $request_lib);
+ $patron, $requestor, $title, $copy, $pickup_lib, $request_lib, $oargs);
$age_protect_only ||= $status[3];
last OUTER if $status[0];
}
sub _check_issuance_hold_is_possible {
- my( $issuanceid, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou ) = @_;
+ my( $issuanceid, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou, $oargs ) = @_;
my $e = new_editor();
my %org_filter = create_ranged_org_filter($e, $selection_ou, $depth);
}
@status = verify_copy_for_hold(
- $patron, $requestor, $title, $copy, $pickup_lib, $request_lib);
+ $patron, $requestor, $title, $copy, $pickup_lib, $request_lib, $oargs);
$age_protect_only ||= $status[3];
last OUTER if $status[0];
}
sub _check_monopart_hold_is_possible {
- my( $partid, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou ) = @_;
+ my( $partid, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou, $oargs ) = @_;
my $e = new_editor();
my %org_filter = create_ranged_org_filter($e, $selection_ou, $depth);
}
@status = verify_copy_for_hold(
- $patron, $requestor, $title, $copy, $pickup_lib, $request_lib);
+ $patron, $requestor, $title, $copy, $pickup_lib, $request_lib, $oargs);
$age_protect_only ||= $status[3];
last OUTER if $status[0];
sub _check_volume_hold_is_possible {
- my( $vol, $title, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou ) = @_;
+ my( $vol, $title, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou, $oargs ) = @_;
my %org_filter = create_ranged_org_filter(new_editor(), $selection_ou, $depth);
my $copies = new_editor->search_asset_copy({call_number => $vol->id, %org_filter});
$logger->info("checking possibility of volume hold for volume ".$vol->id);
my $age_protect_only = 0;
for my $copy ( @$copies ) {
@status = verify_copy_for_hold(
- $patron, $requestor, $title, $copy, $pickup_lib, $request_lib );
+ $patron, $requestor, $title, $copy, $pickup_lib, $request_lib, $oargs );
$age_protect_only ||= $status[3];
last if $status[0];
}
sub verify_copy_for_hold {
- my( $patron, $requestor, $title, $copy, $pickup_lib, $request_lib ) = @_;
+ my( $patron, $requestor, $title, $copy, $pickup_lib, $request_lib, $oargs ) = @_;
+ $oargs = {} unless defined $oargs;
$logger->info("checking possibility of copy in hold request for copy ".$copy->id);
my $permitted = OpenILS::Utils::PermitHold::permit_copy_hold(
{ patron => $patron,
show_event_list => 1
}
);
+
+ # All overridden?
+ my $permit_anyway = 0;
+ foreach my $permit_event (@$permitted) {
+ if (grep { $_ eq $permit_event->{textcode} } @{$oargs->{events}}) {
+ $permit_anyway = 1;
+ last;
+ }
+ }
+ $permitted = [] if $permit_anyway;
+
my $age_protect_only = 0;
if (@$permitted == 1 && @$permitted[0]->{textcode} eq 'ITEM_AGE_PROTECTED') {
$age_protect_only = 1;
);
sub delete_survey {
- my($self, $conn, $auth, $survey_id) = @_;
+ my($self, $conn, $auth, $survey_id, $oargs) = @_;
my $e = new_editor(authtoken => $auth, xact => 1);
return $e->die_event unless $e->checkauth;
+ $oargs = { all => 1 } unless defined $oargs;
my $survey = $e->retrieve_action_survey($survey_id)
or return $e->die_event;
my $responses = $e->search_action_survey_response({survey => $survey_id});
return OpenILS::Event->new('SURVEY_RESPONSES_EXIST')
- if @$responses and $self->api_name =! /override/;
+ if @$responses and ($self->api_name =! /override/ || !($oargs->{all} || grep { $_ eq 'SURVEY_RESPONSES_EXIST' } @{$oargs->{events}}));
for my $resp (@$responses) {
$e->delete_action_survey_response($resp) or return $e->die_event;