Bugzilla – Attachment 42485 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), 4.07 KB, created by
Olli-Antti Kivilahti
on 2015-09-11 14:42:33 UTC
(
hide
)
Description:
Bug 14806 - Action Log for Modifying message_transport_types
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2015-09-11 14:42:33 UTC
Size:
4.07 KB
patch
obsolete
>From 5da8bf4415146067e942df3bb60689f1b9c09e3f 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']}] >--- > C4/Form/MessagingPreferences.pm | 41 ++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 40 insertions(+), 1 deletion(-) > >diff --git a/C4/Form/MessagingPreferences.pm b/C4/Form/MessagingPreferences.pm >index bb981a6..6dc1634 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::Members::Messaging; >@@ -76,13 +77,16 @@ sub handle_form_action { > my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); > # 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->param( $option->{'message_attribute_id'} ); >- next OPTION unless $updater->{'message_transport_types'}; >+ next OPTION unless $updater->{'message_transport_types'}; #Shouldn't this be "unless scalar(@{$updater->{'message_transport_types'}});" however this would never let existing message_preferences to be deleted :) > > if ( $option->{'has_digest'} ) { > if ( List::Util::first { $_ == $option->{'message_attribute_id'} } $query->param( 'digest' ) ) { >@@ -98,6 +102,8 @@ sub handle_form_action { > > C4::Members::Messaging::SetMessagingPreference( $updater ); > >+ _pushToActionLogBuffer($logEntries, $updater, $option); >+ > if ($query->param( $option->{'message_attribute_id'})){ > $prefs_set = 1; > } >@@ -109,6 +115,8 @@ sub handle_form_action { > } > # show the success message > $template->param( settings_updated => 1 ); >+ >+ _writeActionLogBuffer($logEntries, $borrowernumber); > } > > =head2 set_form_values >@@ -149,6 +157,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 >-- >1.9.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