From 5df3312d0cd274af2a6170924cc550a755212d83 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 17 Jan 2024 17:09:20 +0000 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 --- Koha/Suggestion.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm index 162671dd83..4925d30018 100644 --- a/Koha/Suggestion.pm +++ b/Koha/Suggestion.pm @@ -69,6 +69,8 @@ sub store { my $emailpurchasesuggestions = C4::Context->preference("EmailPurchaseSuggestions"); + my $new_suggestion = !$self->in_storage; + my $result = $self->SUPER::store(); if( $emailpurchasesuggestions ){ @@ -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