From: erickson Date: Mon, 9 Jun 2008 19:39:10 +0000 (+0000) Subject: added support for setting an org unit setting to disable auto-record deletion when... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=038151d33b5c4276703091133922c54c79e0d6ed;p=Evergreen.git added support for setting an org unit setting to disable auto-record deletion when the last copy for the record is deleted. also support for enabling an event to be returned when the last copy for a record is deleted git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2_2@9794 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm index 11f4c10681..e67a14d7e1 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm @@ -1046,26 +1046,30 @@ sub update_copy { sub remove_empty_objects { my( $editor, $override, $vol ) = @_; - if( title_is_empty($editor, $vol->record) ) { - # disable the TITLE_LAST_COPY event for now - # if( $override ) { - if( 1 ) { + my $koe = $U->ou_ancestor_setting_value( + $editor->requestor->ws_ou, 'cat.bib.keep_on_empty', $editor); + my $aoe = $U->ou_ancestor_setting_value( + $editor->requestor->ws_ou, 'cat.bib.alert_on_empty', $editor); - # delete this volume if it's not already marked as deleted - unless( $U->is_true($vol->deleted) || $vol->isdeleted ) { - $vol->deleted('t'); - $vol->editor($editor->requestor->id); - $vol->edit_date('now'); - $editor->update_asset_call_number($vol) or return $editor->event; - } + if( title_is_empty($editor, $vol->record) ) { + + # delete this volume if it's not already marked as deleted + unless( $U->is_true($vol->deleted) || $vol->isdeleted ) { + $vol->deleted('t'); + $vol->editor($editor->requestor->id); + $vol->edit_date('now'); + $editor->update_asset_call_number($vol) or return $editor->event; + } - my $evt = delete_rec($editor, $vol->record); - return $evt if $evt; + unless($koe) { + # delete the bib record if the keep-on-empty setting is not set + my $evt = delete_rec($editor, $vol->record); + return $evt if $evt; + } - } else { - return OpenILS::Event->new('TITLE_LAST_COPY', payload => $vol->record ); - } + # return the empty alert if the alert-on-empty setting is set + return OpenILS::Event->new('TITLE_LAST_COPY', payload => $vol->record ) if $aoe; } return undef;