Bugzilla – Attachment 160265 Details for
Bug 35597
Purchase suggestion changes aren't logged
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35597: logaction when modifying or deleteing suggestions
Bug-35597-logaction-when-modifying-or-deleteing-su.patch (text/plain), 8.36 KB, created by
Lucas Gass (lukeg)
on 2023-12-22 17:12:02 UTC
(
hide
)
Description:
Bug 35597: logaction when modifying or deleteing suggestions
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2023-12-22 17:12:02 UTC
Size:
8.36 KB
patch
obsolete
>From 85236312c0b10163628383ef7116fd8aa373ef12 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 21 Dec 2023 23:05:19 +0000 >Subject: [PATCH] Bug 35597: logaction when modifying or deleteing suggestions > >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. Modify the suggestion and check the logs again, the modification should be logged. >7. Delete the suggestion, the deletion should be logged. >8. Do a purchase suggestion via the OPAC. >9. Check the logs to see the newly created suggestion, the interface should be OPAC. >10. Turn of SuggestionsLog >11. No changes of any kind should be logged. >--- > C4/Suggestions.pm | 7 +++++++ > Koha/Suggestion.pm | 5 ++++- > .../data/mysql/atomicupdate/bug_35597.pl | 19 +++++++++++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../en/modules/admin/preferences/logs.pref | 6 ++++++ > .../prog/en/modules/tools/viewlog.tt | 5 ++++- > 6 files changed, 41 insertions(+), 2 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_35597.pl > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 14c6b203c1..fae1c650a3 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -27,6 +27,7 @@ use C4::Letters; > use C4::Biblio qw( GetMarcFromKohaField ); > use Koha::DateUtils qw( dt_from_string ); > use Koha::Suggestions; >+use C4::Log qw(logaction); > > use base qw(Exporter); > >@@ -290,6 +291,9 @@ sub ModSuggestion { > ) 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 > } > >@@ -343,6 +347,9 @@ sub DelSuggestion { > }; > $sth = $dbh->prepare($queryDelete); > my $suggestiondeleted = $sth->execute($suggestionid); >+ if (C4::Context->preference("SuggestionsLog")) { >+ logaction('SUGGESTION', 'DELETE', $suggestionid, '' ); >+ } > return $suggestiondeleted; > } > } >diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm >index 631c1f662a..162671dd83 100644 >--- a/Koha/Suggestion.pm >+++ b/Koha/Suggestion.pm >@@ -27,6 +27,7 @@ use Koha::DateUtils qw( dt_from_string ); > use Koha::Patrons; > use Koha::AuthorisedValues; > use Koha::Exceptions::Suggestion; >+use C4::Log qw(logaction); > > use base qw(Koha::Object); > >@@ -111,7 +112,9 @@ sub store { > ) or warn "can't enqueue letter $letter"; > } > } >- >+ if (C4::Context->preference("NewsLog")) { >+ logaction('SUGGESTION', 'CREATE', $result->suggestionid, '' ); >+ } > return $result; > } > >diff --git a/installer/data/mysql/atomicupdate/bug_35597.pl b/installer/data/mysql/atomicupdate/bug_35597.pl >new file mode 100755 >index 0000000000..3101b2fcc8 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_35597.pl >@@ -0,0 +1,19 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "35597", >+ description => "Add SuggestionsLog system preference ", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ # sysprefs >+ $dbh->do( >+ q{ >+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) >+ VALUES ('SuggestionsLog', '0', 'If enabled, log purchase suggestion changes', '' , 'YesNo') >+ } >+ ); >+ say $out "Added new system preference 'SuggestionsLog'"; >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index b58114d802..3d03fbb116 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -724,6 +724,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'), > ('SubscriptionLog','1',NULL,'If ON, enables subscriptions log','YesNo'), > ('suggestion','1','','If ON, enables patron suggestions feature in OPAC','YesNo'), >+('SuggestionsLog','0',NULL,'If ON, log pirchase suggestion changes','YesNo'), > ('suggestionPatronCategoryExceptions', '', '', 'List the patron categories not affected by suggestion system preference if on', 'Free'), > ('SuspendHoldsIntranet','1','Allow holds to be suspended from the intranet.',NULL,'YesNo'), > ('SuspendHoldsOpac','1','Allow holds to be suspended from the OPAC.',NULL,'YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref >index 8337b78279..c3571768a6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref >@@ -114,6 +114,12 @@ Logging: > 1: Log > 0: "Don't log" > - any actions on recalls (create, cancel, expire, fulfill). >+ - >+ - pref: SuggestionsLog >+ choices: >+ 1: Log >+ 0: "Don't log" >+ - any changes to purchase suggestions (create, modify, delete ). > > Debugging: > - >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt >index e2a897fd51..a369fd081c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt >@@ -101,6 +101,7 @@ > [% CASE 'NOTICES' %]<span>Notices</span>[% UNLESS Koha.Preference('NoticesLog') %] <i class="fa-solid fa-triangle-exclamation" title="Log not enabled"></i>[% END %] > [% CASE 'NEWS' %]<span>News</span>[% UNLESS Koha.Preference('NewsLog') %] <i class="fa-solid fa-triangle-exclamation" title="Log not enabled"></i>[% END %] > [% CASE 'RECALLS' %]<span>Recalls</span>[% UNLESS Koha.Preference('RecallsLog') %] <i class="fa-solid fa-triangle-exclamation" title="Log not enabled"></i>[% END %] >+[% CASE 'SUGGESTION' %]<span>Suggestions</span>[% UNLESS Koha.Preference('SuggestionsLog') %] <i class="fa-solid fa-triangle-exclamation" title="Log not enabled"></i>[% END %] > > [% CASE %][% module | html %] > [% END %] >@@ -217,7 +218,7 @@ > [% ELSE %] > <label for="moduleALL" class="viewlog"><input type="checkbox" id="moduleALL" name="modules" value=""> All</label> > [% END %] >- [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS' ] %] >+ [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS', 'SUGGESTION' ] %] > [% IF modules.grep(modx).size %] > <label for="module[% modx | html %]" class="viewlog"><input type="checkbox" id="module[% modx | html %]" name="modules" value="[% modx | html %]" checked="checked"> [% PROCESS translate_log_module module=modx %]</label> > [% ELSE %] >@@ -383,6 +384,8 @@ > [% ELSE %] > Basket [% loopro.object | html %] > [% END %] >+ [% ELSIF ( loopro.module == "SUGGESTION" ) %] >+ <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loopro.object | uri %]&op=show">[% loopro.object | html %]</a> > [% ELSE %] > [% loopro.object | html %] > [% END %] >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35597
:
160223
|
160253
|
160265
|
161114
|
161115
|
161116
|
164536
|
164537
|
166890
|
166891
|
166892
|
166893
|
166894
|
166895
|
166896