Bugzilla – Attachment 125637 Details for
Bug 28717
NewsLog doesn't work
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28717: Fix additional content logs
Bug-28717-Fix-additional-content-logs.patch (text/plain), 5.80 KB, created by
Lucas Gass (lukeg)
on 2021-10-01 16:57:30 UTC
(
hide
)
Description:
Bug 28717: Fix additional content logs
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2021-10-01 16:57:30 UTC
Size:
5.80 KB
patch
obsolete
>From 606af42d8b9e69560d1970bc4f425a343771e412 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 18 Aug 2021 17:58:38 +0200 >Subject: [PATCH] Bug 28717: Fix additional content logs > >The logging for additional contents added by bug 26205 has been broken >by but 22544. > >This patch is a revisited version as bug 24387 has been pushed. >It does not log MODIFY if no modification has been made on a template >(useful when only 1 version/lang of a content has been modified) > >Test plan: >Turn on NewsLog >Add/modify and delete additional contents/News and confirm that >modification are logged. > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > .../prog/en/modules/tools/viewlog.tt | 2 +- > tools/additional-contents.pl | 38 +++++++++++++++++-- > 2 files changed, 35 insertions(+), 5 deletions(-) > >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 0eba6b1611..b828dc3b55 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt >@@ -373,7 +373,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" || loopro.module == "OPACNEWS" %] >+ [% IF loopro.module == "SYSTEMPREFERENCE" || loopro.module == "REPORTS" || loopro.module == "NEWS" %] > <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> >diff --git a/tools/additional-contents.pl b/tools/additional-contents.pl >index bddbb844b9..b78fb90fee 100755 >--- a/tools/additional-contents.pl >+++ b/tools/additional-contents.pl >@@ -27,6 +27,7 @@ use CGI qw ( -utf8 ); > use C4::Auth qw(get_template_and_user); > use C4::Koha; > use C4::Context; >+use C4::Log qw( logaction ); > use C4::Output qw(output_html_with_http_headers); > use C4::Languages qw(getTranslatedLanguages); > use Koha::DateUtils; >@@ -118,11 +119,17 @@ elsif ( $op eq 'add_validate' ) { > ); > # Delete if title or content is empty > unless ( $title and $content ) { >- $additional_content->delete if $additional_content; >+ if ( $additional_content ) { >+ eval { $additional_content->delete }; >+ unless ($@) { >+ logaction('NEWS', 'DELETE' , undef, sprintf("%s|%s|%s|%s", $additional_content->code, $additional_content->title, $additional_content->lang, $additional_content->content)); >+ } >+ } > next; > } elsif ( $additional_content ) { >+ my $updated; > eval { >- $additional_content->update( >+ $additional_content->set( > { > category => $category, > code => $code, >@@ -137,12 +144,17 @@ elsif ( $op eq 'add_validate' ) { > borrowernumber => $borrowernumber, > } > ); >+ $updated = $additional_content->_result->get_dirty_columns; >+ $additional_content->store; > }; > if ($@) { > $success = 0; > push @messages, { type => 'error', code => 'error_on_update' }; > last; > } >+ >+ logaction('NEWS', 'MODIFY' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content)) >+ if C4::Context->preference("NewsLog") && $updated; > } > else { > my $additional_content = Koha::AdditionalContent->new( >@@ -166,6 +178,9 @@ elsif ( $op eq 'add_validate' ) { > push @messages, { type => 'error', code => 'error_on_insert' }; > last; > } >+ >+ logaction('NEWS', 'ADD' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content)) >+ if C4::Context->preference("NewsLog"); > } > > } >@@ -173,8 +188,23 @@ elsif ( $op eq 'add_validate' ) { > } > elsif ( $op eq 'delete_confirmed' ) { > my @ids = $cgi->multi_param('ids'); >- my $deleted = >- eval { Koha::AdditionalContents->search( { idnew => \@ids } )->delete; }; >+ my $deleted = eval { >+ >+ my $schema = Koha::Database->new->schema; >+ $schema->txn_do( >+ sub { >+ my $contents = >+ Koha::AdditionalContents->search( { idnew => \@ids } ); >+ >+ if ( C4::Context->preference("NewsLog") ) { >+ while ( my $c = $contents->next ) { >+ logaction('NEWS', 'DELETE' , undef, sprintf("%s|%s|%s|%s", $c->code, $c->title, $c->lang, $c->content)); >+ } >+ } >+ $contents->delete; >+ } >+ ); >+ }; > > if ( $@ or not $deleted ) { > push @messages, { type => 'error', code => 'error_on_delete' }; >-- >2.20.1
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 28717
:
122864
|
122921
|
122927
|
122941
|
122943
|
122944
|
122955
|
123964
|
125471
|
125543
|
125637
|
125659