Bugzilla – Attachment 103446 Details for
Bug 18595
Move C4::Members::Messaging to Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18595: Move C4::Members::Messaging::SetMessagingPreferencesFromDefaults
Bug-18595-Move-C4MembersMessagingSetMessagingPrefe.patch (text/plain), 7.67 KB, created by
Jonathan Druart
on 2020-04-22 09:26:05 UTC
(
hide
)
Description:
Bug 18595: Move C4::Members::Messaging::SetMessagingPreferencesFromDefaults
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-04-22 09:26:05 UTC
Size:
7.67 KB
patch
obsolete
>From add6f4512d2218e61dca5d33e4bd0495250a93f5 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Thu, 27 Oct 2016 14:18:34 +0300 >Subject: [PATCH] Bug 18595: Move > C4::Members::Messaging::SetMessagingPreferencesFromDefaults >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch moves C4::Members::SetMessagingPreferencesFromDefaults to >Koha::Patron->set_default_messaging_preferences > >The patch makes a heavy touch on core messaging preference features, >but should not introduce any visible changes for end user. Keep this in mind >if testing. If you notice any changes in Koha, something is probably wrong! > >To test: > >Make sure you have enabled the following system preferences: >- EnhancedMessagingPreferences > >---- GENERAL ---- >1. Apply patch >2. Search Koha source code for references of "SetMessagingPreferencesFromDefaults" > (grep -r 'SetMessagingPreferencesFromDefaults'). >3. Observe no results in source code. > >---- INTRANET ---- >1. Login to intranet. >2. Go to Administration -> Patron categories -> Edit (for any category) >3. Scroll down to observe default messaging preferences for this patron category >4. Observe the preferences, remember them for the next step. >5. Go to cgi-bin/koha/members/memberentry.pl?op=add&categorycode=XXX, replace XXX > with the categorycode you were just editing. >6. Look at messaging preferences. They should be same as in step 4. >7. Fill in required data, do not modify messaging preferences, click Save. >8. Observe a new patron with default messaging preferences. > >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: David Bourgault <david.bourgault@inlibro.com> >--- > C4/Auth_with_ldap.pm | 2 +- > C4/Auth_with_shibboleth.pm | 2 +- > C4/Form/MessagingPreferences.pm | 6 ++-- > C4/Members/Messaging.pm | 35 ------------------- > Koha/Patrons/Import.pm | 7 +--- > .../borrowers-force-messaging-defaults.pl | 7 ++-- > 6 files changed, 10 insertions(+), 49 deletions(-) > >diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm >index 36b9071426..5271095c6d 100644 >--- a/C4/Auth_with_ldap.pm >+++ b/C4/Auth_with_ldap.pm >@@ -226,7 +226,7 @@ sub checkpw_ldap { > )->store; > die "Insert of new patron failed" unless $patron; > $borrowernumber = $patron->borrowernumber; >- C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrowernumber, categorycode => $borrower{'categorycode'} } ); >+ $patron->set_default_messaging_preferences; > } else { > return 0; # B2, D2 > } >diff --git a/C4/Auth_with_shibboleth.pm b/C4/Auth_with_shibboleth.pm >index 1e89020c02..f2bb0dbe4d 100644 >--- a/C4/Auth_with_shibboleth.pm >+++ b/C4/Auth_with_shibboleth.pm >@@ -140,7 +140,7 @@ sub _autocreate { > } > > my $patron = Koha::Patron->new( \%borrower )->store; >- C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $patron->borrowernumber, categorycode => $patron->categorycode } ); >+ $patron->set_default_messaging_preferences; > > return ( 1, $patron->cardnumber, $patron->userid ); > } >diff --git a/C4/Form/MessagingPreferences.pm b/C4/Form/MessagingPreferences.pm >index 4b171f586e..a6c938a64a 100644 >--- a/C4/Form/MessagingPreferences.pm >+++ b/C4/Form/MessagingPreferences.pm >@@ -25,6 +25,7 @@ use C4::Context; > use C4::Members::Messaging; > use C4::Debug; > use Koha::Patron::Message::Preferences; >+use Koha::Patrons; > > use constant MAX_DAYS_IN_ADVANCE => 30; > >@@ -105,8 +106,9 @@ sub handle_form_action { > } > if (! $prefs_set && $insert){ > # this is new borrower, and we have no preferences set, use the defaults >- $target_params->{categorycode} = $categorycode; >- C4::Members::Messaging::SetMessagingPreferencesFromDefaults( $target_params ); >+ $target_params->{categorycode} = $categorycode; >+ my $patron = Koha::Patrons->find($target_params->{'borrowernumber'}); >+ $patron->set_default_messaging_preferences if $patron; > } > # show the success message > $template->param( settings_updated => 1 ); >diff --git a/C4/Members/Messaging.pm b/C4/Members/Messaging.pm >index 09d4d4387b..6019eedf03 100644 >--- a/C4/Members/Messaging.pm >+++ b/C4/Members/Messaging.pm >@@ -182,41 +182,6 @@ END_SQL > return; > } > >-=head2 SetMessagingPreferencesFromDefaults >- >- C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrower->{'borrowernumber'} >- categorycode => 'CPL' } ); >- >-Given a borrowernumber and a patron category code (from the C<borrowernumber> and C<categorycode> keys >-in the parameter hashref), replace all of the patron's current messaging preferences with >-whatever defaults are defined for the patron category. >- >-=cut >- >-sub SetMessagingPreferencesFromDefaults { >- my $params = shift; >- >- foreach my $required ( qw( borrowernumber categorycode ) ) { >- unless ( exists $params->{ $required } ) { >- die "SetMessagingPreferencesFromDefaults called without required parameter: $required"; >- } >- } >- >- my $messaging_options = Koha::Patron::Message::Preferences->get_options; >- OPTION: foreach my $option ( @$messaging_options ) { >- my $default_pref = GetMessagingPreferences( { categorycode => $params->{categorycode}, >- message_name => $option->{'message_name'} } ); >- # FIXME - except for setting the borrowernumber, it really ought to be possible >- # to have the output of GetMessagingPreferences be able to be the input >- # to SetMessagingPreference >- my @message_transport_types = keys %{ $default_pref->{transports} }; >- $default_pref->{message_attribute_id} = $option->{'message_attribute_id'}; >- $default_pref->{message_transport_types} = \@message_transport_types; >- $default_pref->{borrowernumber} = $params->{borrowernumber}; >- SetMessagingPreference( $default_pref ); >- } >-} >- > =head1 TABLES > > =head2 message_queue >diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm >index 56b18023ce..f5ab265161 100644 >--- a/Koha/Patrons/Import.pm >+++ b/Koha/Patrons/Import.pm >@@ -372,12 +372,7 @@ sub import_patrons { > } > > if ($set_messaging_prefs) { >- C4::Members::Messaging::SetMessagingPreferencesFromDefaults( >- { >- borrowernumber => $patron->borrowernumber, >- categorycode => $patron->categorycode, >- } >- ); >+ $patron->set_default_messaging_preferences; > } > > $imported++; >diff --git a/misc/maintenance/borrowers-force-messaging-defaults.pl b/misc/maintenance/borrowers-force-messaging-defaults.pl >index c446ca0f1c..22cf525313 100755 >--- a/misc/maintenance/borrowers-force-messaging-defaults.pl >+++ b/misc/maintenance/borrowers-force-messaging-defaults.pl >@@ -29,6 +29,7 @@ BEGIN { > use Koha::Script; > use C4::Context; > use C4::Members::Messaging; >+use Koha::Patrons; > use Getopt::Long; > use Pod::Usage; > >@@ -65,10 +66,8 @@ WHERE bo.dateenrolled >= ?|; > while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) { > print "$borrowernumber: $categorycode\n"; > next unless $doit; >- C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { >- borrowernumber => $borrowernumber, >- categorycode => $categorycode, >- } ); >+ my $patron = Koha::Patrons->find($borrowernumber); >+ $patron->set_default_messaging_preferences if $patron; > $cnt++; > } > $dbh->commit(); >-- >2.20.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 18595
:
63435
|
63436
|
63437
|
63438
|
63439
|
63440
|
63441
|
63794
|
63795
|
63796
|
63797
|
63798
|
63799
|
63800
|
63813
|
63815
|
63816
|
63817
|
63818
|
63819
|
63820
|
63821
|
63822
|
63823
|
63824
|
63825
|
63826
|
63827
|
63828
|
63829
|
69441
|
69442
|
69443
|
69444
|
69445
|
69446
|
69447
|
69448
|
69449
|
69450
|
69451
|
69452
|
69453
|
69667
|
69668
|
69669
|
69670
|
69671
|
69672
|
69673
|
69674
|
93873
|
93874
|
93875
|
93876
|
93877
|
93878
|
93879
|
93880
|
93908
|
94753
|
94754
|
103444
|
103445
|
103446
|
103447
|
103448
|
103449
|
103450
|
103451
|
103452
|
110151
|
110152
|
110153
|
110154
|
110155
|
110156
|
110157
|
110158
|
110159
|
112147
|
112148
|
112149
|
112150
|
112151
|
112152
|
112153
|
112154
|
112155
|
112690
|
113126
|
113192
|
113221
|
113222
|
113769
|
146541
|
146542
|
146543
|
146544
|
146545
|
146546
|
146547
|
146548
|
146549
|
146550
|
146551
|
146552