@@ -, +, @@ OPACheader_en ) and the content of the news item. should appear works works --- C4/NewsChannels.pm | 22 ++++++++++++++++++++++ .../bug_26205_add_newslog_system_pref.perl | 7 +++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/logs.pref | 7 ++++++- .../intranet-tmpl/prog/en/modules/tools/viewlog.tt | 5 +++-- 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_26205_add_newslog_system_pref.perl --- a/C4/NewsChannels.pm +++ a/C4/NewsChannels.pm @@ -21,6 +21,8 @@ package C4::NewsChannels; use Modern::Perl; use C4::Context; use Koha::DateUtils; +use C4::Log qw(logaction); +use Koha::News; use vars qw(@ISA @EXPORT); @@ -68,6 +70,11 @@ sub add_opac_new { my $sth = $dbh->prepare("INSERT INTO opac_news ( $field_string ) VALUES ( $values_string )"); $sth->execute(@values); $retval = 1; + + #log the NEW OPAC news entry + if (C4::Context->preference("NewsLog")) { + logaction('OPACNEWS', 'ADD' , undef, $href_entry->{lang} . ' | ' . $href_entry->{content}); + } } return $retval; } @@ -108,12 +115,26 @@ sub upd_opac_new { $sth->execute(@values); $retval = 1; } + + #log new OPAC news modification + if (C4::Context->preference("NewsLog")) { + logaction('OPACNEWS', 'MODIFY' , undef, $href_entry->{lang} . ' | ' . $href_entry->{content}); + } return $retval; } sub del_opac_new { my ($ids) = @_; if ($ids) { + + #log new OPAC news deletion + if (C4::Context->preference("NewsLog")) { + foreach my $newsid ( split(/,/, $ids )) { + my $n = Koha::News->find( $newsid ); + logaction('OPACNEWS', 'DELETE', undef, $n->unblessed->{lang} . ' | ' . $n->unblessed->{content} ); + } + } + my $dbh = C4::Context->dbh; my $sth = $dbh->prepare("DELETE FROM opac_news WHERE idnew IN ($ids)"); $sth->execute(); @@ -121,6 +142,7 @@ sub del_opac_new { } else { return 0; } + } sub get_opac_new { --- a/installer/data/mysql/atomicupdate/bug_26205_add_newslog_system_pref.perl +++ a/installer/data/mysql/atomicupdate/bug_26205_add_newslog_system_pref.perl @@ -0,0 +1,7 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('NewsLog', '0', 'If enabled, log OPAC News changes', '', 'YesNo'); | ); + + # Always end with this (adjust the bug info) + NewVersion( $DBversion, 26205, "Log OPAC News changes"); +} --- a/installer/data/mysql/mandatory/sysprefs.sql +++ a/installer/data/mysql/mandatory/sysprefs.sql @@ -348,6 +348,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('minPasswordLength','8',NULL,'Specify the minimum length of a patron/staff password','free'), ('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''), ('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'), +('NewsLog','0',NULL,'If ON, log OPAC news changes','YesNo'), ('NewsToolEditor','tinymce','tinymce|codemirror','Choose tool for editing News.', 'Choice'), ('noissuescharge','5','','Define maximum amount withstanding before checkouts are blocked','Integer'), ('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before checkouts are blocked','Integer'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref @@ -102,7 +102,12 @@ Logging: on: Log off: "Don't log" - " changes to notice templates." - + - + - pref: NewsLog + choices: + on: Log + off: "Don't log" + - " changes to OPAC news" Debugging: - - pref: DumpTemplateVarsIntranet --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -95,6 +95,7 @@ [% CASE 'SEARCHENGINE' %]Search engine [% CASE 'NOTICES' %]Notices[% UNLESS Koha.Preference('NoticesLog') %] [% END %] +[% CASE 'OPACNEWS' %]OPAC News[% UNLESS Koha.Preference('NewsLog') %] [% END %] [% CASE %][% module | html %] [% END %] [% END %] @@ -200,7 +201,7 @@ [% ELSE %] [% END %] - [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES' ] %] + [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'OPACNEWS' ] %] [% IF modules.grep(modx).size %] [% ELSE %] @@ -361,7 +362,7 @@ [% IF ( loopro.module == 'CIRCULATION' ) %] Item [% loopro.barcode | html %] [% ELSE %] - [% IF loopro.module == "SYSTEMPREFERENCE" || loopro.module == "REPORTS" %] + [% IF loopro.module == "SYSTEMPREFERENCE" || loopro.module == "REPORTS" || loopro.module == "OPACNEWS" %]
[% loopro.info | trim | html %]
--