From dafc8d3056ee4b163f24717a96d29c2518e61240 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 25 Feb 2021 10:10:22 +0000 Subject: [PATCH] Bug 14233: (follow-up) Add NoticesLog preference This patch adds a preference to enable/disable the notice template logging. Signed-off-by: Kelly McElligott --- installer/data/mysql/atomicupdate/bug_14233.perl | 5 +++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../intranet-tmpl/prog/en/modules/admin/preferences/logs.pref | 6 ++++++ tools/letter.pl | 10 +++++++--- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_14233.perl b/installer/data/mysql/atomicupdate/bug_14233.perl index 8a6caf0b25..ba78b924e3 100644 --- a/installer/data/mysql/atomicupdate/bug_14233.perl +++ b/installer/data/mysql/atomicupdate/bug_14233.perl @@ -24,5 +24,10 @@ q{ALTER TABLE letter ADD UNIQUE KEY letter_uniq_1 (`module`,`code`,`branchcode`, OR action = 'ACQUISITION CLAIM' )}); + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) + VALUES ('NoticesLog','',NULL,'If enabled, log changes to notice templates','YesNo') + }); + NewVersion( $DBversion, 14233, "Add id field to letter table" ); } diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index f3663e6608..81d399b5c1 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -350,6 +350,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('NotHighlightedWords','and|or|not',NULL,'List of words to NOT highlight when OpacHitHighlight is enabled','free'), ('NoticeBcc','','','Email address to bcc outgoing notices sent by email','free'), ('NoticeCSS','',NULL,'Notices CSS url.','free'), +('NoticesLog','',NULL,'If enabled, log changes to notice templates','YesNo'), ('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'), ('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content. Requires Novelist Profile and Password','YesNo'), ('NovelistSelectPassword','',NULL,'Novelist select user Password','free'), 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 f87b2be902..6e99b8795f 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 @@ -90,6 +90,12 @@ Logging: on: Log off: "Don't log" - " successful authentications." + - + - pref: NoticesLog + choices: + on: Log + off: "Don't log" + - " changes to notice templates." Debugging: - diff --git a/tools/letter.pl b/tools/letter.pl index 19b6147a5b..2df8f0f505 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -318,7 +318,8 @@ sub add_validate { elsif ( $letter and $letter->{message_transport_type} eq $mtt and $letter->{lang} eq $lang ) { logaction( 'NOTICES', 'MODIFY', $letter->{id}, $content, 'Intranet' ) - unless ( $content eq $letter->{content} ); + if ( C4::Context->preference("NoticesLog") + && $content ne $letter->{content} ); $dbh->do( q{ UPDATE letter @@ -343,7 +344,9 @@ sub add_validate { lang => $lang } )->store; - logaction('NOTICES', 'CREATE', $letter->id, $letter->content, 'Intranet'); + logaction( 'NOTICES', 'CREATE', $letter->id, $letter->content, + 'Intranet' ) + if C4::Context->preference("NoticesLog"); } } # set up default display @@ -375,7 +378,8 @@ sub delete_confirmed { ); while ( my $letter = $letters->next ) { logaction( 'NOTICES', 'DELETE', $letter->id, $letter->content, - 'Intranet' ); + 'Intranet' ) + if C4::Context->preference("NoticesLog"); $letter->delete; } -- 2.11.0