From 4595b5940e555e5719c6c2b63c67a2ae93c3dfe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Mon, 20 Apr 2015 22:13:04 +0200 Subject: [PATCH] Bug 14024 - add reports to action logs This patch sets adds the possibility to log new, update and delete actions for saved reports. To test: -Apply patch -Run updatedatabase.pl -Enable system preference ReportsLog -Create, duplicate, edit and delete saved reports -Go to Home > Tools > Logs -Verify that you can select "Reports" in Modules list -Verify that your actions were logged Signed-off-by: Nicole Engard Signed-off-by: Nicole Engard --- C4/Reports/Guided.pm | 6 +++++- .../data/mysql/atomicupdate/bug_14024_add_reportslog_syspref.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../intranet-tmpl/prog/en/modules/admin/preferences/logs.pref | 6 ++++++ koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt | 3 ++- reports/guided_reports.pl | 4 ++++ 6 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_14024_add_reportslog_syspref.sql diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index 1b27e9c..9791f87 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -33,6 +33,7 @@ use XML::Dumper; use C4::Debug; # use Smart::Comments; # use Data::Dumper; +use C4::Log; BEGIN { # set the version for version checking @@ -632,6 +633,10 @@ sub format_results { sub delete_report { my (@ids) = @_; return unless @ids; + foreach my $id (@ids) { + my $data = get_saved_report($id); + logaction( "REPORTS", "DELETE", $id, "Name: $data->{'report_name'} SQL: $data->{'savedsql'} " ) if C4::Context->preference("ReportsLog"); + } my $dbh = C4::Context->dbh; my $query = 'DELETE FROM saved_sql WHERE id IN (' . join( ',', ('?') x @ids ) . ')'; my $sth = $dbh->prepare($query); @@ -639,7 +644,6 @@ sub delete_report { } sub get_saved_reports_base_query { - my $area_name_sql_snippet = get_area_name_sql_snippet; return <All [% END %] - [% FOREACH modx IN [ 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' ] %] + [% FOREACH modx IN [ 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' 'REPORTS' ] %] [% IF modules.grep(modx).size %] [% ELSE %] diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index 2238259..b74866f 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -31,6 +31,8 @@ use C4::Dates qw/format_date/; use C4::Debug; use C4::Branch; # XXX subfield_is_koha_internal_p use C4::Koha qw/IsAuthorisedValueCategory GetFrameworksLoop/; +use C4::Context; +use C4::Log; =head1 NAME @@ -237,6 +239,7 @@ elsif ( $phase eq 'Update SQL'){ 'reportname' => $reportname, 'id' => $id, ); + logaction( "REPORTS", "MODIFY", $id, "$reportname: SQL: $sql" ) if C4::Context->preference("ReportsLog"); } if ( $usecache ) { $template->param( @@ -594,6 +597,7 @@ elsif ( $phase eq 'Save Report' ) { cache_expiry => $cache_expiry, public => $public, } ); + logaction( "REPORTS", "ADD", 0, "Name: $name: SQL: $sql" ) if C4::Context->preference("ReportsLog"); $template->param( 'save_successful' => 1, 'reportname' => $name, -- 1.7.10.4