From db3f54369c342aab59caa211fee33905f02f85bf Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 17 May 2024 08:12:57 -0400 Subject: [PATCH] Bug 35597: Log creation on suggestion from staff or OPAC To test: 1. Apply patch, restart services, updatedatabase 2. Search for the system preference 'SuggestionsLog', it should be off. Turn it on. 3. Create a purhase suggestion 4. Go to Tools > Log viewer. In modules check 'Suggestions' 5. You should see your newly created suggestion. 6. Create a suggestion from the OPAC. 7. You should see your newly created OPAC suggestion. 8. Modify the suggestion and check the logs again, the modification should be logged. 9. Delete the suggestion, the deletion should be logged. 10. Do a purchase suggestion via the OPAC. 11 Check the logs to see the newly created suggestion, the interface should be OPAC. 12. Turn off SuggestionsLog 13. No changes of any kind should be logged. Signed-off-by: Owen Leonard Signed-off-by: Ray Delahunty Signed-off-by: Kyle M Hall --- Koha/Suggestion.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm index a6dd3076719..3ba4bf75e3d 100644 --- a/Koha/Suggestion.pm +++ b/Koha/Suggestion.pm @@ -70,6 +70,8 @@ sub store { my $emailpurchasesuggestions = C4::Context->preference("EmailPurchaseSuggestions"); + my $new_suggestion = !$self->in_storage; + my $result = $self->SUPER::store(); if ( $emailpurchasesuggestions && $self->STATUS eq 'ASKED' ) { @@ -112,8 +114,9 @@ sub store { ) or warn "can't enqueue letter $letter"; } } - if (C4::Context->preference("NewsLog")) { - logaction('SUGGESTION', 'CREATE', $result->suggestionid, '' ); + my $suggestion_object = Koha::Suggestions->find( $result->suggestionid ); + if ( $new_suggestion && C4::Context->preference("SuggestionsLog") ) { + logaction( 'SUGGESTION', 'CREATE', $result->suggestionid, $suggestion_object ); } return $result; } -- 2.30.2