Bugzilla – Attachment 162961 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 - Log changes to borrower message preferences to action logs
Bug-14806---Log-changes-to-borrower-message-prefer.patch (text/plain), 3.37 KB, created by
Lari Strand
on 2024-03-08 12:56:08 UTC
(
hide
)
Description:
Bug 14806 - Log changes to borrower message preferences to action logs
Filename:
MIME Type:
Creator:
Lari Strand
Created:
2024-03-08 12:56:08 UTC
Size:
3.37 KB
patch
obsolete
>From 2f82ce61609a5996249511991f1ada1a96d26620 Mon Sep 17 00:00:00 2001 >From: lmstrand <lmstrand@gmail.com> >Date: Fri, 8 Mar 2024 12:40:01 +0200 >Subject: [PATCH] Bug 14806 - Log changes to borrower message preferences to > action logs > >--- > C4/Members/Messaging.pm | 44 ++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 41 insertions(+), 3 deletions(-) > >diff --git a/C4/Members/Messaging.pm b/C4/Members/Messaging.pm >index 25e6a04a0f..cb54779971 100644 >--- a/C4/Members/Messaging.pm >+++ b/C4/Members/Messaging.pm >@@ -20,8 +20,8 @@ package C4::Members::Messaging; > use strict; > use warnings; > use C4::Context; >- >- >+use JSON qw( to_json ); >+use C4::Log qw( logaction ); > > =head1 NAME > >@@ -120,7 +120,7 @@ returns nothing useful. > > sub SetMessagingPreference { > my $params = shift; >- >+ > unless (exists $params->{borrowernumber} xor exists $params->{categorycode}) { # yes, xor > warn "SetMessagingPreference called without exactly one of borrowernumber or categorycode"; > return; >@@ -131,6 +131,8 @@ sub SetMessagingPreference { > return; > } > } >+ my $preferences_json = to_json(GetPatronMessagingPreferences($params->{borrowernumber}, $params->{message_attribute_id}),{ utf8 => 1, canonical => 1 }); >+ > $params->{'days_in_advance'} = undef unless exists ( $params->{'days_in_advance'} ); > $params->{'wants_digest'} = 0 unless exists ( $params->{'wants_digest'} ); > >@@ -181,6 +183,22 @@ END_SQL > foreach my $transport ( @{$params->{'message_transport_types'}}) { > my $success = $sth->execute( $borrower_message_preference_id, $transport ); > } >+ >+ my $new_preferences_json = to_json(GetPatronMessagingPreferences($params->{borrowernumber}, $params->{message_attribute_id}),{ utf8 => 1, canonical => 1 }); >+ >+ if ( $preferences_json ne $new_preferences_json ) { >+ my $info; >+ $preferences_json =~ s/,/, /g; >+ $new_preferences_json =~ s/,/, /g; >+ $preferences_json =~ s/\[\]/null/g; >+ $new_preferences_json =~ s/\[\]/null/g; >+ >+ $info = { >+ before => $preferences_json, >+ after => $new_preferences_json >+ }; >+ logaction("MEMBERS","MODIFY",$params->{borrowernumber}, "Messaging preference: after: ". $new_preferences_json . " before: " . $preferences_json); >+ } > } > return; > } >@@ -259,6 +277,26 @@ sub SetMessagingPreferencesFromDefaults { > } > } > >+sub GetPatronMessagingPreferences { >+ my ($borrowernumber, $message_attribute_id) = @_; >+ my $sql = <<'END_SQL'; >+SELECT message_name, days_in_advance, wants_digest, >+borrower_message_transport_preferences.message_transport_type >+FROM borrower_message_preferences >+INNER JOIN borrower_message_transport_preferences >+ON borrower_message_transport_preferences.borrower_message_preference_id = borrower_message_preferences.borrower_message_preference_id >+INNER JOIN message_attributes >+ON borrower_message_preferences.message_attribute_id = message_attributes.message_attribute_id >+ AND borrowernumber = ? >+ AND borrower_message_preferences.message_attribute_id = ? >+END_SQL >+ >+ my $sth = C4::Context->dbh->prepare($sql); >+ $sth->execute($borrowernumber, $message_attribute_id); >+ my $rows = $sth->fetchall_arrayref({}); >+ return $rows; >+} >+ > =head1 TABLES > > =head2 message_queue >-- >2.34.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