From b55b0ce2b17818d3658e65cc67fb0fd3dc6444d9 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 10 Nov 2020 15:51:24 +0100 Subject: [PATCH] Bug 26991: Add action logs to search engine administration Search engine administration is very important, we should log who/when it is changed. I don't add a preference system to disable it, like there is no for preference system logs. Test plan : 1) Use searchengine Elasticsearch 2) Go to Administation > Search engine configuration (Elasticsearch) 3) Click on 'Reset Mappings' and accept 4) Edit some lines and save 5) Go to 'Tools' > 'Log viewer' 6) Select only 'Search engine' in Modules and submit 7) Select only 'Edit mappings' in Actions 8) Check you see a log 9) Select only 'Reset mappings' in Actions 10) Check you see a log Signed-off-by: David Nind --- admin/searchengine/elasticsearch/mappings.pl | 5 +++++ koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/admin/searchengine/elasticsearch/mappings.pl b/admin/searchengine/elasticsearch/mappings.pl index e43c7a8516..89740f0c2b 100755 --- a/admin/searchengine/elasticsearch/mappings.pl +++ b/admin/searchengine/elasticsearch/mappings.pl @@ -22,6 +22,7 @@ use List::Util qw( first ); use C4::Koha; use C4::Output; use C4::Auth; +use C4::Log; use Koha::SearchEngine::Elasticsearch; use Koha::SearchMarcMaps; @@ -168,6 +169,9 @@ if ( $op eq 'edit' ) { $schema->storage->txn_rollback; } else { push @messages, { type => 'message', code => 'success_on_update' }; + + C4::Log::logaction( 'SEARCHENGINE', 'EDIT_MAPPINGS', undef, q{} ); + $schema->storage->txn_commit; Koha::SearchEngine::Elasticsearch->clear_search_fields_cache(); @@ -178,6 +182,7 @@ if ( $op eq 'edit' ) { elsif( $op eq 'reset_confirmed' ) { Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings; push @messages, { type => 'message', code => 'success_on_reset' }; + C4::Log::logaction( 'SEARCHENGINE', 'RESET_MAPPINGS', undef, q{} ); } elsif( $op eq 'reset_confirm' ) { $template->param( reset_confirm => 1 ); 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 01a99f0518..961f3cc08e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -94,6 +94,8 @@ [% CASE 'REPORTS' %]Reports[% UNLESS Koha.Preference('ReportsLog') %] [% END %] +[% CASE 'SEARCHENGINE' %]Search engine + [% CASE %][% module | html %] [% END %] [% END %] @@ -117,6 +119,8 @@ [% CASE 'STATUS_CHANGE' %]Change ILL request status [% CASE 'PATRON_NOTICE' %]ILL notice sent to patron [% CASE 'Run' %]Run +[% CASE 'EDIT_MAPPINGS' %]Edit mappings +[% CASE 'RESET_MAPPINGS' %]Reset mappings [% CASE %][% action | html %] [% END %] [% END %] @@ -168,7 +172,7 @@ [% ELSE %] [% END %] - [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS' ] %] + [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE' ] %] [% IF modules.grep(modx).size %] [% ELSE %] @@ -190,7 +194,7 @@ [% END %] - [% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'RENEW' 'CREATE' 'CANCEL' 'SUSPEND' 'RESUME' 'ADDCIRCMESSAGE' 'DELCIRCMESSAGE' 'STATUS_CHANGE' 'PATRON_NOTICE' 'CHANGE PASS' 'Run' ] %] + [% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'RENEW' 'CREATE' 'CANCEL' 'SUSPEND' 'RESUME' 'ADDCIRCMESSAGE' 'DELCIRCMESSAGE' 'STATUS_CHANGE' 'PATRON_NOTICE' 'CHANGE PASS' 'Run' 'EDIT_MAPPINGS' 'RESET_MAPPINGS' ] %] [% IF actions.grep(actx).size %] [% ELSE %] -- 2.11.0