Bugzilla – Attachment 94749 Details for
Bug 14806
Action Log for Modifying borrower messaging preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14806 - Action Log for Modifying message_transport_types
Bug-14806---Action-Log-for-Modifying-messagetransp.patch (text/plain), 3.87 KB, created by
Lari Taskula
on 2019-10-25 12:29:18 UTC
(
hide
)
Description:
Bug 14806 - Action Log for Modifying message_transport_types
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2019-10-25 12:29:18 UTC
Size:
3.87 KB
patch
obsolete
>From bc036979be12e146d89ea74675f26b9a35882d35 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Fri, 11 Sep 2015 17:18:04 +0300 >Subject: [PATCH] Bug 14806 - Action Log for Modifying message_transport_types > >This is a crude fix. >koha.action_logs-entries are generated when Borrower has been modified using >C4::Form::MessagingPreferences > >log entries look like this: > >| MEMBERS | MOD MTT | All message_transports removed >| MEMBERS | MOD MTT | [{'_name' => 'Advance_Notice','da' => '4','dig' => 1,'mtt' => ['email']},{'_name' => 'Item_Check_in','mtt' => ['email']},{'_name' => 'Item_Checkout','mtt' => ['email']}] > >TEST PLAN: > >0. Activate system preference "BorrowersLog". >1. In intra, edit a Borrowers messaging preferences. >2. In OPAC remove your messaging preferences. >3. SELECT * FROM action_logs ORDER BY timestamp DESC LIMIT 5; >3.1. You should see your new action logs entries. >--- > C4/Form/MessagingPreferences.pm | 39 +++++++++++++++++++++++++++++++++ > 1 file changed, 39 insertions(+) > >diff --git a/C4/Form/MessagingPreferences.pm b/C4/Form/MessagingPreferences.pm >index 01e2892304..c080882414 100644 >--- a/C4/Form/MessagingPreferences.pm >+++ b/C4/Form/MessagingPreferences.pm >@@ -20,6 +20,7 @@ package C4::Form::MessagingPreferences; > use strict; > use warnings; > >+use Data::Dumper; > use CGI qw ( -utf8 ); > use C4::Context; > use C4::Debug; >@@ -77,9 +78,12 @@ sub handle_form_action { > my $messaging_options = Koha::Patron::Message::Preferences->get_options; > # TODO: If a "NONE" box and another are checked somehow (javascript failed), we should pay attention to the "NONE" box > my $prefs_set = 0; >+ my $borrowernumber; >+ my $logEntries = []; > OPTION: foreach my $option ( @$messaging_options ) { > my $updater = { %{ $target_params }, > message_attribute_id => $option->{'message_attribute_id'} }; >+ $borrowernumber = $target_params->{borrowernumber} unless $borrowernumber; > > # find the desired transports > @{$updater->{'message_transport_types'}} = $query->multi_param( $option->{'message_attribute_id'} ); >@@ -110,6 +114,8 @@ sub handle_form_action { > $preference->set($updater)->store; > } > >+ _pushToActionLogBuffer($logEntries, $updater, $option); >+ > if ($query->param( $option->{'message_attribute_id'})){ > $prefs_set = 1; > } >@@ -122,6 +128,8 @@ sub handle_form_action { > } > # show the success message > $template->param( settings_updated => 1 ); >+ >+ _writeActionLogBuffer($logEntries, $borrowernumber); > } > > =head2 set_form_values >@@ -163,6 +171,37 @@ sub set_form_values { > $template->param(messaging_preferences => $messaging_options); > } > >+sub _pushToActionLogBuffer { >+ return unless C4::Context->preference("BorrowersLog"); >+ my ($logEntries, $updater, $option) = @_; >+ >+ if ($updater->{message_transport_types} && scalar(@{$updater->{message_transport_types}})) { >+ my $entry = {}; >+ $entry->{cc} = $updater->{categorycode} if $updater->{categorycode}; >+ $entry->{dig} = $updater->{wants_digest} if $updater->{wants_digest}; >+ $entry->{da} = $updater->{days_in_advance} if $updater->{days_in_advance}; >+ $entry->{mtt} = $updater->{message_transport_types}; >+ $entry->{_name} = $option->{message_name}; >+ push(@$logEntries, $entry); >+ } >+} >+ >+sub _writeActionLogBuffer { >+ return unless C4::Context->preference("BorrowersLog"); >+ my ($logEntries, $borrowernumber) = @_; >+ >+ if (scalar(@$logEntries)) { >+ my $d = Data::Dumper->new([$logEntries]); >+ $d->Indent(0); >+ $d->Purity(0); >+ $d->Terse(1); >+ C4::Log::logaction('MEMBERS', 'MOD MTT', $borrowernumber, $d->Dump($logEntries)); >+ } >+ else { >+ C4::Log::logaction('MEMBERS', 'MOD MTT', $borrowernumber, 'All message_transports removed') >+ } >+} >+ > =head1 TODO > > =over 4 >-- >2.17.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 14806
:
42482
|
42483
|
42484
|
42485
|
42486
|
75399
|
75400
|
94749
|
94750
|
94752
|
162961