From fd70d6289bc61680f83206ccd64346028e38c2fa Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 14 Nov 2024 11:28:05 +0000 Subject: [PATCH] Bug 30300: (QA follow-up) Prevent regression and improve clarity This patch amends the DB update to check the MembershipExpiryDaysNotice syspref and sets the flag for all patrons if the syspref is set It also improves the UI visiblity by hiding the messaging preference if the syspref isn't set and adding more clarity to the syspref definition --- ...00-add_expiration_to_messaging_preferences.pl | 16 ++++++++++++++++ .../en/includes/messaging-preference-form.inc | 1 + .../en/modules/admin/preferences/patrons.pref | 1 + .../bootstrap/en/modules/opac-messaging.tt | 1 + 4 files changed, 19 insertions(+) diff --git a/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl b/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl index db212f19b26..d8f37cd236b 100755 --- a/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl +++ b/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl @@ -1,5 +1,7 @@ use Modern::Perl; +use Koha::Patrons; + return { bug_number => "30300", description => "Add Patron expiry to messaging preference", @@ -44,6 +46,20 @@ return { ); say $out "MEMBERSHIP_EXPIRY added to message_transports"; + + my $days_notice = C4::Context->preference('MembershipExpiryDaysNotice'); + if($days_notice) { + my $patrons = Koha::Patrons->search(); + while ( my $patron = $patrons->next ) { + C4::Members::Messaging::SetMessagingPreference( + { + borrowernumber => $patron->borrowernumber, + message_attribute_id => $message_attribute_id, + message_transport_types => ['email'], + } + ); + } + } } else { say $out "Patron_Expiry message attribute exists, skipping update"; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc index 9a0d4f5886c..b7c0c63d9d0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc @@ -17,6 +17,7 @@ [% FOREACH messaging_preference IN messaging_preferences %] [% NEXT IF !Koha.Preference( 'ILLModule' ) && messaging_preference.message_name.match('^Ill_') %] + [% NEXT IF !Koha.Preference('MembershipExpiryDaysNotice') && messaging_preference.Patron_Expiry %] [% NEXT IF messaging_preference.Auto_Renewals && Koha.Preference('AutoRenewalNotices') != 'preferences' %] [% NEXT IF !Koha.Preference('UseRecalls') && messaging_preference.message_name.match('^Recall_') %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index dac646d44db..05eca7662d9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -156,6 +156,7 @@ Patrons: class: integer - days. - "
NOTE: This system preference requires the misc/cronjobs/membership_expiry.pl cronjob. Ask your system administrator to schedule it." + - "
NOTE: The parameters you use to select patrons when running the cronjob will supersede a user's messaging preferences. For example, a user may have opted to receive the expiry notice but if they are not included in the search parameters on the cronjob then they will not receive the notice." Notices and notifications: - - pref: EnhancedMessagingPreferences diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt index 5e45443173a..38a88151d22 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -59,6 +59,7 @@ [% FOREACH messaging_preference IN messaging_preferences %] [% NEXT IF !Koha.Preference( 'ILLModule' ) && messaging_preference.message_name.match('^Ill_') %] + [% NEXT IF !Koha.Preference('MembershipExpiryDaysNotice') && messaging_preference.Patron_Expiry %] [% NEXT IF messaging_preference.Auto_Renewals && Koha.Preference('AutoRenewalNotices') != 'preferences' %] [% NEXT IF !Koha.Preference('UseRecalls') && messaging_preference.message_name.match('^Recall_') %] -- 2.39.3 (Apple Git-146)