Bugzilla – Attachment 168748 Details for
Bug 35630
Add ability to log changes to authorized values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35630: Add ability to log creation, modification, and deletion of authorized values
Bug-35630-Add-ability-to-log-creation-modification.patch (text/plain), 7.32 KB, created by
Sam Lau
on 2024-07-10 15:15:38 UTC
(
hide
)
Description:
Bug 35630: Add ability to log creation, modification, and deletion of authorized values
Filename:
MIME Type:
Creator:
Sam Lau
Created:
2024-07-10 15:15:38 UTC
Size:
7.32 KB
patch
obsolete
>From 8ab464f38cdc429e9a9d5b318c260919f4aa6566 Mon Sep 17 00:00:00 2001 >From: Sam Lau <samalau@gmail.com> >Date: Wed, 10 Jul 2024 14:36:14 +0000 >Subject: [PATCH] Bug 35630: Add ability to log creation, modification, and > deletion of authorized values > >These patches enable librarians to log any changes to authorized values. The feature is dependent on the new 'AuthorizedValuesLog' system preference. > >To test: >1) Apply patch, updatedatabase, restart_all >2) In Administration->System preferences, search for 'AuthorizedValuesLog' and change to 'Log'. Save your changes. >3) Now go to Administration->Authorized values. Keep this tab open >4) In a new tab, go to Tools -> Log viewer. Ensure that "Authorized values" is checked. >5) Now in AV, click on a category and create a new authorized value. >6) Refresh your log viewer, and the creation should be logged appropiately. >7) Modify an authroized value, this should also be logged correctly. >8) Now delete and authorized value, ensure the logging is correct here as well. >9) Now turn off the system preferece. >10) In the log viewer, 'Authorized values' should have a black triangle next to it, indicating the preference is turned off. >11) Change an AV, this should not be logged. >--- > Koha/AuthorisedValue.pm | 14 ++++++++++++++ > admin/authorised_values.pl | 2 +- > .../intranet-tmpl/prog/en/modules/tools/viewlog.tt | 5 ++++- > tools/viewlog.pl | 13 +++++++++++++ > 4 files changed, 32 insertions(+), 2 deletions(-) > >diff --git a/Koha/AuthorisedValue.pm b/Koha/AuthorisedValue.pm >index 5669ab6086..d096f17a7f 100644 >--- a/Koha/AuthorisedValue.pm >+++ b/Koha/AuthorisedValue.pm >@@ -19,6 +19,8 @@ package Koha::AuthorisedValue; > > use Modern::Perl; > >+use C4::Log qw(logaction); >+ > use Koha::Caches; > use Koha::Database; > use Koha::Exceptions; >@@ -53,6 +55,8 @@ sub store { > > my $flush = 0; > >+ my $new_authorized_value = !$self->in_storage; >+ > if ( !$self->in_storage ) { > $flush = 1; > } >@@ -70,6 +74,11 @@ sub store { > > $self = $self->SUPER::store; > >+ if ( C4::Context->preference("AuthorizedValuesLog") ) { >+ my $action = $new_authorized_value ? 'CREATE' : 'MODIFY'; >+ logaction( 'AUTHORIZEDVALUE', $action, $self->id, $self ); >+ } >+ > if ($flush) { > my $key = "AV_descriptions:".$self->category; > $cache->clear_from_cache($key); >@@ -86,6 +95,11 @@ AuthorisedValue specific C<delete> to clear relevant caches on delete. > > sub delete { > my $self = shift @_; >+ >+ if ( C4::Context->preference("AuthorizedValuesLog") ) { >+ logaction( 'AUTHORIZEDVALUE', "DELETE", $self->id, $self ); >+ } >+ > my $key = "AV_descriptions:".$self->category; > $cache->clear_from_cache($key); > $self->SUPER::delete(@_); >diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl >index 9513ce7eda..7809a24cdd 100755 >--- a/admin/authorised_values.pl >+++ b/admin/authorised_values.pl >@@ -138,7 +138,7 @@ if ( $op eq 'add_form' or $op eq 'edit_form' ) { > lib_opac => scalar $input->param('lib_opac') || undef, > imageurl => $imageurl, > } >- )->store; >+ ); > $av->replace_library_limits( \@branches ); > $av->store; > }; >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 10b65cfdb3..dda7dd54eb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt >@@ -102,6 +102,7 @@ > [% CASE 'NEWS' %]<span>News</span>[% UNLESS Koha.Preference('NewsLog') %] <i class="fa-solid fa-triangle-exclamation" title="Log not enabled"></i>[% END %] > [% CASE 'RECALLS' %]<span>Recalls</span>[% UNLESS Koha.Preference('RecallsLog') %] <i class="fa-solid fa-triangle-exclamation" title="Log not enabled"></i>[% END %] > [% CASE 'SUGGESTION' %]<span>Suggestions</span>[% UNLESS Koha.Preference('SuggestionsLog') %] <i class="fa-solid fa-triangle-exclamation" title="Log not enabled"></i>[% END %] >+[% CASE 'AUTHORIZEDVALUE' %]<span>Authorized values</span>[% UNLESS Koha.Preference('AuthorizedValuesLog') %] <i class="fa-solid fa-triangle-exclamation" title="Log not enabled"></i>[% END %] > > [% CASE %][% module | html %] > [% END %] >@@ -222,7 +223,7 @@ > [% ELSE %] > <label for="moduleALL" class="viewlog"><input type="checkbox" id="moduleALL" name="modules" value=""> All</label> > [% END %] >- [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS', 'SUGGESTION' ] %] >+ [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS', 'SUGGESTION', 'AUTHORIZEDVALUE' ] %] > [% IF modules.grep(modx).size %] > <label for="module[% modx | html %]" class="viewlog"><input type="checkbox" id="module[% modx | html %]" name="modules" value="[% modx | html %]" checked="checked"> [% PROCESS translate_log_module module=modx %]</label> > [% ELSE %] >@@ -390,6 +391,8 @@ > [% END %] > [% ELSIF ( loopro.module == "SUGGESTION" ) %] > <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loopro.object | uri %]&op=show">[% loopro.object | html %]</a> >+ [% ELSIF ( loopro.module == "AUTHORIZEDVALUE" ) %] >+ <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% loopro.av.category | uri %]">[% loopro.object| html %]</a> > [% ELSE %] > [% loopro.object | html %] > [% END %] >diff --git a/tools/viewlog.pl b/tools/viewlog.pl >index 91cd65df25..60936d3aeb 100755 >--- a/tools/viewlog.pl >+++ b/tools/viewlog.pl >@@ -29,6 +29,7 @@ use C4::Serials qw( CountSubscriptionFromBiblionumber ); > use C4::Search qw( enabled_staff_search_views ); > > use Koha::ActionLogs; >+use Koha::AuthorisedValues; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Items; >@@ -202,6 +203,18 @@ if ($do_it) { > } > } > } >+ >+ if ( $log->module eq "AUTHORIZEDVALUE" ) { >+ if ( $log->object ) { >+ my $av = Koha::AuthorisedValues->find( $log->object ); >+ if ( $av && $output eq 'screen' ) { >+ my $category = $av->category; >+ $result->{av} = { >+ category => $category, >+ }; >+ } >+ } >+ } > push @data, $result; > } > if ( $output eq "screen" ) { >-- >2.39.2
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 35630
:
168747
|
168748
|
169027
|
169044
|
169045
|
169046
|
172629