Bugzilla – Attachment 123964 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.57 KB, created by
Jonathan Druart
on 2021-08-18 16:01:59 UTC
(
hide
)
Description:
Bug 28717: Fix additional content logs
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-08-18 16:01:59 UTC
Size:
5.57 KB
patch
obsolete
>From 036584acf6d70af40741f0477ad28f9f641ee5ec 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. >--- > .../prog/en/modules/tools/viewlog.tt | 2 +- > tools/additional-contents.pl | 32 +++++++++++++++++-- > 2 files changed, 30 insertions(+), 4 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 3b0886d3690..6ea33bed706 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt >@@ -362,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" || 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 e4a409cb688..7a10bebf137 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; >@@ -119,10 +120,12 @@ elsif ( $op eq 'add_validate' ) { > # Delete if title or content is empty > unless ( $title and $content ) { > $additional_content->delete if $additional_content; >+ 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 +140,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 +174,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 +184,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.25.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