From eb645681e2e3ec65de1a2362e179c6803c21e7e3 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 Signed-off-by: David Nind Signed-off-by: Kyle M Hall --- installer/data/mysql/atomicupdate/bug_14233.perl | 5 +++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../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 d93a90ea3f..bc4d9ba21a 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -351,6 +351,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 33a56d5317..4f4945e1af 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: 1: Log 0: "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 64fe2ff76e..faf80e7d39 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.24.1 (Apple Git-126)