Bug 35597: Move modification logging to Koha::Suggestion

Some actions such as archiving a suggestion were not being logged.
By moving the logging to Koha::Suggestion we can ensure more
modifcations will be logged.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Kyle Hall 2024-05-17 08:46:30 -04:00 committed by Martin Renvoize
parent 3a8faef477
commit 8ee4fef42e
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F
2 changed files with 8 additions and 7 deletions

View file

@ -294,9 +294,7 @@ sub ModSuggestion {
) or warn "can't enqueue letter $letter"; ) or warn "can't enqueue letter $letter";
} }
} }
if ( C4::Context->preference("SuggestionsLog") ) {
logaction( 'SUGGESTION', 'MODIFY', $suggestion->{suggestionid}, $suggestion_object );
}
return 1; # No useful if the exception is raised earlier return 1; # No useful if the exception is raised earlier
} }

View file

@ -73,6 +73,12 @@ sub store {
my $new_suggestion = !$self->in_storage; my $new_suggestion = !$self->in_storage;
my $result = $self->SUPER::store(); my $result = $self->SUPER::store();
if ( C4::Context->preference("SuggestionsLog") ) {
my $action = $new_suggestion ? 'CREATE' : 'MODIFY';
logaction( 'SUGGESTION', $action, $result->suggestionid, $self );
}
if ( $emailpurchasesuggestions && $self->STATUS eq 'ASKED' ) { if ( $emailpurchasesuggestions && $self->STATUS eq 'ASKED' ) {
if ( if (
@ -114,10 +120,7 @@ sub store {
) or warn "can't enqueue letter $letter"; ) or warn "can't enqueue letter $letter";
} }
} }
my $suggestion_object = Koha::Suggestions->find( $result->suggestionid );
if ( $new_suggestion && C4::Context->preference("SuggestionsLog") ) {
logaction( 'SUGGESTION', 'CREATE', $result->suggestionid, $suggestion_object );
}
return $result; return $result;
} }