From e53efc7f6ae931530c9f1fba5856f1efc4fb91d1 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 6 Mar 2026 17:34:13 +0000 Subject: [PATCH] Bug 36698: (20956 follow-up) Fix display of permission logs [ALTERNATIVE] This is an alternative to attachment 194534 on bug 20956. Depends on Bug 20956. For MEMBERS/MODIFY log entries, pretty-print the JSON stored in the info and diff columns (viewlog.pl), and render them in
 blocks
in the log viewer template (viewlog.tt).

The diff block additionally receives a 'permissions-diff' CSS class
which triggers a JavaScript colorizer that annotates Struct::Diff
output with human-readable Added/Removed/Modifications/Old/New labels
and color highlights.
---
 .../prog/en/modules/tools/viewlog.tt          | 50 ++++++++++++++++++-
 tools/viewlog.pl                              | 15 ++++++
 2 files changed, 63 insertions(+), 2 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 42634a034e8..60aff8d6862 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
@@ -406,11 +406,23 @@
                                             >
                                         
                                     [% ELSE %]
-                                        
[% loopro.info | html %]
+
+ [% IF ( loopro.module == 'MEMBERS' ) %] +
[% loopro.info | html %]
+ [% ELSE %] + [% loopro.info | html %] + [% END %] +
[% END %] [% PROCESS translate_log_interface log_interface=loopro.interface %] - [% loopro.diff | html %] + + [% IF ( loopro.module == 'MEMBERS' ) %] +
[% loopro.diff | html %]
+ [% ELSE %] + [% loopro.diff | html %] + [% END %] + [% END %] @@ -474,6 +486,40 @@ [% Asset.js("js/viewlog.js") | $raw %] [% END %] diff --git a/tools/viewlog.pl b/tools/viewlog.pl index 2ea2feb3592..caba48e5f13 100755 --- a/tools/viewlog.pl +++ b/tools/viewlog.pl @@ -234,6 +234,21 @@ if ($do_it) { } } } + + if ( $result->{module} eq 'MEMBERS' ) { + my $json_engine = JSON->new->utf8->canonical(1)->pretty(1); + + if ( $result->{info} && $result->{info} =~ /^[{\[]/ ) { + my $perl_info = $json_engine->decode( $result->{info} ); + $result->{info} = $json_engine->encode($perl_info); + } + + if ( $result->{diff} && $result->{diff} =~ /^[{\[]/ ) { + my $perl_diff = $json_engine->decode( $result->{diff} ); + $result->{diff} = $json_engine->encode($perl_diff); + } + } + push @data, $result; } if ( $output eq "screen" ) { -- 2.53.0