Bugzilla – Attachment 122231 Details for
Bug 26205
News changes aren't logged
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26205: Add logging of news items
Bug-26205-Add-logging-of-news-items.patch (text/plain), 8.80 KB, created by
Kyle M Hall (khall)
on 2021-06-21 14:35:29 UTC
(
hide
)
Description:
Bug 26205: Add logging of news items
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-06-21 14:35:29 UTC
Size:
8.80 KB
patch
obsolete
>From c0deb82e667d5bc9a416df461b9dccf08b2369ed Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Wed, 12 May 2021 18:20:16 +0000 >Subject: [PATCH] Bug 26205: Add logging of news items > >To test: > >1. Apply patch, updatedatabase, restart_all >2. Make sure the system pref 'NewsLog' is turned on. >3. Go to the Koha News tool and create a new news item. >4. View the logs and display only the OPAC News module >5. You should see your new news, it will include the lang ( > OPACheader_en ) and the content of the news item. >6. Filter the logs so the only action is 'Add', your new news item > should appear >7. Modify some news items >8. They should appear in the logs now as modification. >9. Make sure you can filter the action to 'Modify' and can confirm it > works >10. Delete some news items >11. They should appear in the logs now as deletinon >12. Make sure you can filter the action to 'Delete' and can confirm it > works > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/NewsChannels.pm | 22 +++++++++++++++++++ > .../bug_26205_add_newslog_system_pref.perl | 7 ++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../en/modules/admin/preferences/logs.pref | 7 +++++- > .../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 > >diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm >index 7c9df5b2e5..28a2d6074d 100644 >--- a/C4/NewsChannels.pm >+++ b/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 { >diff --git a/installer/data/mysql/atomicupdate/bug_26205_add_newslog_system_pref.perl b/installer/data/mysql/atomicupdate/bug_26205_add_newslog_system_pref.perl >new file mode 100644 >index 0000000000..2ffbb93231 >--- /dev/null >+++ b/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"); >+} >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 0a86168ee0..3430bc26e7 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/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'), >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 dd062935f4..5f04124ec8 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 >@@ -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 >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 9760ba6c40..444991761d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt >+++ b/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') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %] >+[% CASE 'OPACNEWS' %]OPAC News[% UNLESS Koha.Preference('NewsLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %] > [% CASE %][% module | html %] > [% END %] > [% END %] >@@ -200,7 +201,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' ] %] >+ [% 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 %] > <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 %] >@@ -361,7 +362,7 @@ > [% IF ( loopro.module == 'CIRCULATION' ) %] > <a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% loopro.info | uri %]&biblionumber=[% loopro.biblionumber | uri %]&bi=[% loopro.biblioitemnumber | uri %]#item[% loopro.info | uri %]" title="Display detail for this item">Item [% loopro.barcode | html %]</a> > [% ELSE %] >- [% IF loopro.module == "SYSTEMPREFERENCE" || loopro.module == "REPORTS" %] >+ [% IF loopro.module == "SYSTEMPREFERENCE" || loopro.module == "REPORTS" || loopro.module == "OPACNEWS" %] > <div class="loginfo" id="loginfo[% loopro.action_id | html %]">[% loopro.info | trim | html %]</div> > <div class="compare_info" id="compare_info[% loopro.action_id | html %]"> > <label><input type="checkbox" name="diff" id="action_id[% loopro.action_id | html %]" data-actionid="[% loopro.action_id | html %]" data-filter="[% FOREACH info IN loopro.info.split(' \| ') %][% IF loop.first %][% info | html %][% END %][% END %]" class="compare" /> Compare</label> >-- >2.30.1 (Apple Git-130)
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 26205
:
120895
|
121338
|
121603
|
121604
|
121605
|
121606
|
122229
| 122231 |
122232
|
122233
|
122234