Bugzilla – Attachment 194534 Details for
Bug 20956
BorrowersLog is not logging permission changes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20956: (QA follow-up) Fix display of permission logs
Bug-20956-QA-follow-up-Fix-display-of-permission-l.patch (text/plain), 9.84 KB, created by
Ayoub Glizi-Vicioso
on 2026-03-05 16:56:07 UTC
(
hide
)
Description:
Bug 20956: (QA follow-up) Fix display of permission logs
Filename:
MIME Type:
Creator:
Ayoub Glizi-Vicioso
Created:
2026-03-05 16:56:07 UTC
Size:
9.84 KB
patch
obsolete
>From a22aa83ddc2c5d0609c0ec1f3ab25c19c0ab4831 Mon Sep 17 00:00:00 2001 >From: Ayoub Glizi-Vicioso <ayoub.glizi-vicioso@inLibro.com> >Date: Thu, 5 Mar 2026 11:05:50 -0500 >Subject: [PATCH] Bug 20956: (QA follow-up) Fix display of permission logs > >--- > Koha/Patron.pm | 6 +- > .../prog/en/modules/tools/viewlog.tt | 50 +++++++++++++++- > t/db_dependent/Koha/Patron.t | 60 +++++++++++-------- > tools/viewlog.pl | 15 +++++ > 4 files changed, 100 insertions(+), 31 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 700a58a600..b1f9f161cf 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -3600,7 +3600,7 @@ my $flags = $patron->permissions > Returns a hashref of the patron's permissions. This method has the same > return structure as C4::Auth::getuserflags for consistency. > >-Exemple return structure: >+Example return structure: > { > "superlibrarian": 0, > "permissions": 0, >@@ -3633,8 +3633,8 @@ sub permissions { > > # Get userFlags using ORM > >- my $schema = Koha::Database->schema; >- my @userflags = $schema->resultset('Userflag')->search( {}, { order_by => 'bit'})->all; >+ my $schema = Koha::Database->schema; >+ my @userflags = $schema->resultset('Userflag')->search( {}, { order_by => 'bit' } )->all; > my %userflags_map = map { $_->bit => $_->flag } @userflags; > > my $flags = $self->flags // 0; >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 42634a034e..60aff8d686 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 @@ > > > </div> > [% ELSE %] >- <div class="loginfo" id="loginfo[% loopro.action_id | html %]"> [% loopro.info | html %] </div> >+ <div class="loginfo" id="loginfo[% loopro.action_id | html %]"> >+ [% IF ( loopro.module == 'MEMBERS' ) %] >+ <pre>[% loopro.info | html %]</pre> >+ [% ELSE %] >+ [% loopro.info | html %] >+ [% END %] >+ </div> > [% END %] > </td> > <td>[% PROCESS translate_log_interface log_interface=loopro.interface %]</td> >- <td>[% loopro.diff | html %]</td> >+ <td> >+ [% IF ( loopro.module == 'MEMBERS' ) %] >+ <pre class="permissions-diff">[% loopro.diff | html %]</pre> >+ [% ELSE %] >+ [% loopro.diff | html %] >+ [% END %] >+ </td> > </tr> > [% END %] > </tbody> >@@ -474,6 +486,40 @@ > <script> > var table_settings = [% TablesSettings.GetTableSettings('tools', 'logviewer', 'logst', 'json') | $raw %]; > var CAN_user_parameters_manage_sysprefs = "[% CAN_user_parameters_manage_sysprefs | html %]"; >+ $(document).ready(function() { >+ $("pre.permissions-diff").each(function() { >+ let text = $(this).html(); >+ let dCounter = 0; >+ >+ let added_label = _("Added "); >+ let removed_label = _("Removed "); >+ >+ let all_label = _("-- All --"); >+ >+ >+ text = text.replace(/^(\s{0,8}"[^"]+"\s*:\s*)\{\s*"A"\s*:\s*1\s*\}/gm, '$1<span style="color:#2ea44f; font-weight:bold;">' + added_label + all_label + '</span>'); >+ text = text.replace(/^(\s{0,8}"[^"]+"\s*:\s*)\{\s*"R"\s*:\s*1\s*\}/gm, '$1<span style="color:#cf222e; font-weight:bold;">' + removed_label + all_label + '</span>'); >+ >+ text = text.replace(/^(\s*"[^"]+"\s*:\s*)\{\s*"A"\s*:\s*1\s*\}/gm, '$1<span style="color:#2ea44f; font-weight:bold;">' + added_label + 'â</span>'); >+ text = text.replace(/^(\s*"[^"]+"\s*:\s*)\{\s*"R"\s*:\s*1\s*\}/gm, '$1<span style="color:#cf222e; font-weight:bold;">' + removed_label + 'â</span>'); >+ >+ text = text.replace(/"D"/g, function() { >+ dCounter++; >+ var label = (dCounter === 1) ? _("Modifications") : " â³"; >+ var color = (dCounter === 1) ? "#0056b3" : "#6e7781"; >+ return '<span style="color:' + color + '; font-weight:bold;">' + label + '</span>'; >+ }); >+ >+ text = text.replace(/"A"/g, '<span style="color:#2ea44f; font-weight:bold;">' + _("Added ") + 'â' + '</span>'); >+ text = text.replace(/"R"/g, '<span style="color:#cf222e; font-weight:bold;">' + _("Removed ") + 'â' + '</span>'); >+ text = text.replace(/"O"/g, '<span style="color:#6e7781; font-weight:bold;">' + _("Old value") + '</span>'); >+ text = text.replace(/"N"/g, '<span style="color:#0969da; font-weight:bold;">' + _("New value") + '</span>'); >+ >+ text = text.replace(/,\s*$/gm, ""); >+ >+ $(this).html(text); >+ }); >+ }); > </script> > [% Asset.js("js/viewlog.js") | $raw %] > [% END %] >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 9c256b95df..5e33d166aa 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -2386,21 +2386,24 @@ subtest 'alert_subscriptions tests' => sub { > > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > >- my $subscription1 = $builder->build_object( { >- class => 'Koha::Subscriptions', >- value => { >- librarian => $patron->borrowernumber, >+ my $subscription1 = $builder->build_object( >+ { >+ class => 'Koha::Subscriptions', >+ value => { >+ librarian => $patron->borrowernumber, >+ } > } >- }); >+ ); > $subscription1->add_subscriber($patron); > >- >- my $subscription2 = $builder->build_object( { >- class => 'Koha::Subscriptions', >- value => { >- librarian => $patron->borrowernumber, >+ my $subscription2 = $builder->build_object( >+ { >+ class => 'Koha::Subscriptions', >+ value => { >+ librarian => $patron->borrowernumber, >+ } > } >- }); >+ ); > $subscription2->add_subscriber($patron); > > my @subscriptions = $patron->alert_subscriptions->as_list; >@@ -2439,16 +2442,22 @@ subtest 'update_lastseen tests' => sub { > my $mock_cache = Test::MockModule->new('Koha::Cache'); > my %fake_cache; > >- $mock_cache->mock('set_in_cache', sub { >- my ( $self, $key, $value ) = @_; >- $fake_cache{$key} = $value; >- return; >- }); >+ $mock_cache->mock( >+ 'set_in_cache', >+ sub { >+ my ( $self, $key, $value ) = @_; >+ $fake_cache{$key} = $value; >+ return; >+ } >+ ); > >- $mock_cache->mock('get_from_cache', sub { >- my ( $self, $key ) = @_; >- return $fake_cache{$key}; >- }); >+ $mock_cache->mock( >+ 'get_from_cache', >+ sub { >+ my ( $self, $key ) = @_; >+ return $fake_cache{$key}; >+ } >+ ); > > my $cache = Koha::Caches->get_instance(); > >@@ -2457,12 +2466,12 @@ subtest 'update_lastseen tests' => sub { > 'creation,login,connection,check_in,check_out,renewal,hold,article' > ); > >- my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $patron_info = $patron->unblessed; > delete $patron_info->{borrowernumber}; > $patron->delete(); > $patron = Koha::Patron->new($patron_info)->store(); >- $patron->update_lastseen({ activity => 'creation' }); >+ $patron->update_lastseen( { activity => 'creation' } ); > $patron->discard_changes(); > > my $now = dt_from_string(); >@@ -2486,20 +2495,19 @@ subtest 'update_lastseen tests' => sub { > > $patron_no_trigger->lastseen(undef)->store(); > >- $patron_no_trigger->update_lastseen({ activity => 'login' }); >+ $patron_no_trigger->update_lastseen( { activity => 'login' } ); > $patron_no_trigger->discard_changes(); > >- is( $patron_no_trigger->lastseen, undef, >+ is( >+ $patron_no_trigger->lastseen, undef, > 'Patron should have not last seen when newly created if trigger not set' > ); > >- > t::lib::Mocks::mock_preference( > 'TrackLastPatronActivityTriggers', > 'login,connection,check_in,check_out,renewal,hold,article' > ); > >- > $now = dt_from_string(); > Time::Fake->offset( $now->epoch ); > >diff --git a/tools/viewlog.pl b/tools/viewlog.pl >index 2ea2feb359..caba48e5f1 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
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 20956
:
182955
|
185483
|
185491
|
186388
|
187592
|
187593
|
187594
|
188260
|
188261
|
188262
|
188263
|
190686
|
190687
|
190688
|
190689
|
190690
|
191472
|
191473
|
191474
|
191475
|
191476
|
191477
|
191478
|
192506
|
192507
|
192508
|
192509
|
192510
|
192511
|
192512
|
192604
|
192605
|
192606
|
192607
|
192608
|
192609
|
192610
|
194527
|
194528
|
194529
|
194530
|
194531
|
194532
|
194533
| 194534