Bugzilla – Attachment 160106 Details for
Bug 12802
Send notices using several email addresses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12802: Clarify system preferences
Bug-12802-Clarify-system-preferences.patch (text/plain), 10.48 KB, created by
Martin Renvoize (ashimema)
on 2023-12-20 12:09:19 UTC
(
hide
)
Description:
Bug 12802: Clarify system preferences
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-12-20 12:09:19 UTC
Size:
10.48 KB
patch
obsolete
>From 6c5bf8ade91ee86334ea081e9a5e3cfbf374c297 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 20 Dec 2023 11:43:34 +0000 >Subject: [PATCH] Bug 12802: Clarify system preferences > >I felt the switch to multi in the EmailFieldPrimary preference was a bit >confusing given that type exposes a 'select all' option which doesn't >make sense with the pre-existing 'first valid' option being an override >in the code. > >This patch opts to switch it back to 'Choice', meaning that only one >option can be picked and adds a 'selected addresses' option which >prompts the use of a new 'EmailFieldSelection' preference which allows >for the multi-select as before. > >To test: >1) Run though the test plan for 'Update notice_email_address method to > return a list' but with the following ammendments: > >* 2) As aposed to being able to select multiple options under > EmailFieldPrimary, you should now only be able to select one option at > a time, but a new 'selected addresses' option should be present. >* 8) Select the 'selected addresses' option for 'EmailFieldPrimary' and > also select multiple fields for the new 'EmailFieldSelection' > preference. >--- > Koha/Patron.pm | 24 ++++++++++++------- > .../data/mysql/atomicupdate/bug_12802.pl | 11 +++++++-- > installer/data/mysql/mandatory/sysprefs.sql | 3 ++- > .../en/modules/admin/preferences/patrons.pref | 13 ++++++++-- > t/db_dependent/Koha/Patron.t | 22 ++++++++++++----- > 5 files changed, 53 insertions(+), 20 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index b1f3f972de4..19c5c50bca9 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1616,19 +1616,25 @@ sub notice_email_address{ > my ( $self ) = @_; > > my $which_address = C4::Context->preference("EmailFieldPrimary"); >- my @addresses; >- for my $email_field ( split ",", $which_address ) { > >- # if syspref is set to 'first valid' (value == OFF), look up email address >- if ( $email_field eq 'OFF' ) { >- return $self->first_valid_email_address; >- } >+ # if syspref is set to 'first valid' (value == OFF), look up email address >+ if ( $which_address eq 'OFF' ) { >+ return $self->first_valid_email_address; >+ } > >- my $email_address = $self->$email_field; >- push @addresses, $email_address if $email_address; >+ # if syspref is set to 'selected addresses' (value == MULTI), look up email addresses >+ if ( $which_address eq 'MULTI' ) { >+ my @addresses; >+ my $selected_fields = C4::Context->preference("EmailFieldSelection"); >+ for my $email_field ( split ",", $selected_fields ) { >+ my $email_address = $self->$email_field; >+ push @addresses, $email_address if $email_address; >+ } >+ return join(",",@addresses); > } > >- return join(",",@addresses); >+ return $self->$which_address || ''; >+ > } > > =head3 first_valid_email_address >diff --git a/installer/data/mysql/atomicupdate/bug_12802.pl b/installer/data/mysql/atomicupdate/bug_12802.pl >index 55def6be3fb..3be76811701 100755 >--- a/installer/data/mysql/atomicupdate/bug_12802.pl >+++ b/installer/data/mysql/atomicupdate/bug_12802.pl >@@ -7,8 +7,15 @@ return { > my ($args) = @_; > my ( $dbh, $out ) = @$args{qw(dbh out)}; > >- $dbh->do("UPDATE systempreferences SET type='multiple' WHERE variable='EmailFieldPrimary'"); >+ $dbh->do( >+ "UPDATE systempreferences SET options='email|emailpro|B_email|cardnumber|OFF|MULTI' WHERE variable='EmailFieldPrimary'" >+ ); >+ say $out "Updated system preference 'EmailFieldPrimary' to include 'selected addresses' option"; > >- say $out "Updated system preference 'EmailFieldPrimary' to have type 'multiple'"; >+ $dbh->do( >+ "INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('EmailFieldSelection','email|emailpro|B_email','','Selection list of patron email fields to use whern AutoEmailPrimaryAddress is set to selected addresses','multiple')" >+ ); >+ >+ say $out "Added new system preference 'EmailFieldSelection'"; > }, > }; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 2ad55fbd2f2..75bfa216c15 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -225,7 +225,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('EmailAddressForPatronRegistrations', '', '', ' If you choose EmailAddressForPatronRegistrations you have to enter a valid email address: ', 'free'), > ('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'), > ('EmailFieldPrecedence','email|emailpro|B_email','','Ordered list of patron email fields to use when AutoEmailPrimaryAddress is set to first valid','multiple'), >-('EmailFieldPrimary','OFF','email|emailpro|B_email|cardnumber|OFF','Defines the default email address field where patron email notices are sent.','multiple'), >+('EmailFieldPrimary','OFF','email|emailpro|B_email|cardnumber|OFF|MULTI','Defines the default email address field where patron email notices are sent.','Choice'), >+('EmailFieldSelection','email|emailpro|B_email','','Selection list of patron email fields to use whern AutoEmailPrimaryAddress is set to selected addresses','multiple'), > ('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'), > ('EmailOverduesNoEmail','1',NULL,'Send send overdues of patrons without email address to staff','YesNo'), > ('EmailPatronRegistrations', '0', '0|EmailAddressForPatronRegistrations|BranchEmailAddress|KohaAdminEmailAddress', 'Choose email address that new patron registrations will be sent to: ', 'Choice'), >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 1775058db91..297f24312cc 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 >@@ -194,15 +194,16 @@ Patrons: > - "Use the patron's" > - pref: EmailFieldPrimary > default: "OFF" >- multiple: >+ choices: > email: primary email > emailpro: secondary email > B_email: alternate email > cardnumber: cardnumber > "OFF": first valid email address >+ "MULTI": selected addresses > - 'for sending out email notices.' > - '<br><strong>NOTE:</strong> If set to "first valid", the order in which the email addresses are checked is set in <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=EmailFieldPrecedence">EmailFieldPrecedence</a>.' >- - '<br><strong>NOTE:</strong> To send notices to multiple email fields, ensure "first valid" is <strong>unchecked</strong>.' >+ - '<br><strong>NOTE:</strong> If set to "selected addresses", the selection refers to the email address fields set in <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=EmailFieldSelection">EmailFieldSelection</a>.' > - > - "When <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=EmailFieldPrimary'>EmailFieldPrimary</a> is set to '<strong>first valid</strong>', check the patron email address fields in the following order and use the first valid email address found:" > - pref: EmailFieldPrecedence >@@ -210,6 +211,14 @@ Patrons: > - '<br><strong>NOTE:</strong> All patron fields can be used, but to work correctly they must contain a valid email address or an empty string.' > - "Valid options are the <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> of the borrowers table, separated by | (pipe)." > - "Example: email|emailpro|B_email" >+ - >+ - "When <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=EmailFieldPrimary'>EmailFieldPrimary</a> is set to '<strong>selected addresses</strong>', send email to all valid email addresses in the selected fields:" >+ - pref: EmailFieldSelection >+ default: "email" >+ multiple: >+ email: primary email >+ emailpro: secondary email >+ B_email: alternate email > - > - pref: TalkingTechItivaPhoneNotification > choices: >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 583d61f292f..9d5e3e0c6cb 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -1793,17 +1793,27 @@ subtest 'notice_email_address' => sub { > plan tests => 3; > $schema->storage->txn_begin; > >- my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > > t::lib::Mocks::mock_preference( 'EmailFieldPrecedence', 'email|emailpro' ); >- t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'OFF' ); >- is ($patron->notice_email_address, $patron->email, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is off"); >+ t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'OFF' ); >+ is( >+ $patron->notice_email_address, $patron->email, >+ "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is off" >+ ); > > t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'emailpro' ); >- is ($patron->notice_email_address, $patron->emailpro, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is emailpro"); >+ is( >+ $patron->notice_email_address, $patron->emailpro, >+ "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is emailpro" >+ ); > >- t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'email,emailpro' ); >- is ($patron->notice_email_address, $patron->email.",".$patron->emailpro, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is email|emailpro"); >+ t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'MULTI' ); >+ t::lib::Mocks::mock_preference( 'EmailFieldSelection', 'email,emailpro' ); >+ is( >+ $patron->notice_email_address, $patron->email . "," . $patron->emailpro, >+ "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is 'MULTI' and EmailFieldSelection is 'email,emailpro'" >+ ); > > $patron->delete; > $schema->storage->txn_rollback; >-- >2.43.0
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 12802
:
31058
|
31059
|
31132
|
31382
|
31383
|
31384
|
31833
|
33864
|
33865
|
33866
|
33867
|
35890
|
35891
|
35892
|
35893
|
35926
|
35927
|
35928
|
35929
|
35930
|
36055
|
36056
|
36057
|
36058
|
36059
|
39762
|
39770
|
40167
|
45476
|
45477
|
45478
|
45479
|
45480
|
45481
|
45482
|
57296
|
61878
|
61879
|
61880
|
61881
|
61882
|
61883
|
61884
|
66934
|
66935
|
66936
|
66937
|
66938
|
66939
|
66940
|
68002
|
68003
|
68004
|
68005
|
68006
|
68007
|
68008
|
68009
|
68010
|
68011
|
68012
|
68013
|
68375
|
68376
|
68377
|
68378
|
68379
|
68380
|
119016
|
149232
|
153540
|
154076
|
159780
|
159857
|
160051
|
160052
|
160090
|
160091
|
160092
|
160103
|
160104
|
160105
|
160106
|
165494
|
165495
|
165496
|
165497