allow item status update if either status-specific perm is allowed or UPDATE_COPY...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 9 Feb 2011 18:22:14 +0000 (18:22 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 9 Feb 2011 18:22:14 +0000 (18:22 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@19414 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm

index 52e76bc..67b2dc1 100644 (file)
@@ -1138,9 +1138,6 @@ sub mark_item {
         ($copy->call_number->id == OILS_PRECAT_CALL_NUMBER) ? 
             $copy->circ_lib : $copy->call_number->owning_lib;
 
-    return $e->die_event unless $e->allowed('UPDATE_COPY', $owning_lib);
-
-
        my $perm = 'MARK_ITEM_MISSING';
        my $stat = OILS_COPY_STATUS_MISSING;
 
@@ -1150,9 +1147,6 @@ sub mark_item {
         my $evt = handle_mark_damaged($e, $copy, $owning_lib, $args);
         return $evt if $evt;
 
-        my $ses = OpenSRF::AppSession->create('open-ils.trigger');
-        $ses->request('open-ils.trigger.event.autocreate', 'damaged', $copy, $owning_lib);
-
        } elsif ( $self->api_name =~ /bindery/ ) {
                $perm = 'MARK_ITEM_BINDERY';
                $stat = OILS_COPY_STATUS_BINDERY;
@@ -1173,6 +1167,8 @@ sub mark_item {
                $stat = OILS_COPY_STATUS_DISCARD;
        }
 
+    # caller may proceed if either perm is allowed
+    return $e->die_event unless $e->allowed([$perm, 'UPDATE_COPY'], $owning_lib);
 
        $copy->status($stat);
        $copy->edit_date('now');
@@ -1190,6 +1186,12 @@ sub mark_item {
 
        $e->commit;
 
+       if( $self->api_name =~ /damaged/ ) {
+        # now that we've committed the changes, create related A/T events
+        my $ses = OpenSRF::AppSession->create('open-ils.trigger');
+        $ses->request('open-ils.trigger.event.autocreate', 'damaged', $copy, $owning_lib);
+    }
+
        $logger->debug("resetting holds that target the marked copy");
        OpenILS::Application::Circ::Holds->_reset_hold($e->requestor, $_) for @$holds;