Bugzilla – Attachment 89192 Details for
Bug 5770
Email librarian when purchase suggestion made
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5770: (QA follow-up) Allow feature to be disable
Bug-5770-QA-follow-up-Allow-feature-to-be-disable.patch (text/plain), 8.25 KB, created by
Martin Renvoize
on 2019-05-01 18:04:01 UTC
(
hide
)
Description:
Bug 5770: (QA follow-up) Allow feature to be disable
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2019-05-01 18:04:01 UTC
Size:
8.25 KB
patch
obsolete
>From b664d9d3d15fe453acba66cc3e15c82d66c59e3f Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 1 May 2019 14:14:38 +0100 >Subject: [PATCH] Bug 5770: (QA follow-up) Allow feature to be disable > >This patch adds 'None' to the available options for the feature so it >may be disabled entirely (and sets that as default) > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Suggestions.pm | 59 ++++++++++--------- > .../data/mysql/atomicupdate/bug_5770.perl | 2 +- > installer/data/mysql/sysprefs.sql | 2 +- > .../en/modules/admin/preferences/admin.pref | 3 +- > t/db_dependent/Suggestions.t | 13 +++- > 5 files changed, 47 insertions(+), 32 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 6958967d9d..25328d0982 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -456,33 +456,38 @@ sub NewSuggestion { > my $rs = Koha::Database->new->schema->resultset('Suggestion'); > my $new_id = $rs->create($suggestion)->id; > >- my $full_suggestion = GetSuggestion( $new_id ); >- if ( >- my $letter = C4::Letters::GetPreparedLetter( >- module => 'suggestions', >- letter_code => 'NEW_SUGGESTION', >- tables => { >- 'branches' => $full_suggestion->{branchcode}, >- 'borrowers' => $full_suggestion->{suggestedby}, >- 'suggestions' => $full_suggestion, >- }, >- ) >- ){ >- my $emailpurchasesuggestions = C4::Context->preference("EmailPurchaseSuggestions"); >- >- my $toaddress = ( $emailpurchasesuggestions eq "BranchEmailAddress" ) >- ? ( Koha::Libraries->find($full_suggestion->{branchcode})->branchemail || C4::Context->preference('KohaAdminEmailAddress') ) >- : C4::Context->preference( $emailpurchasesuggestions ) ; >- >- C4::Letters::EnqueueLetter( >- { >- letter => $letter, >- borrowernumber => $full_suggestion->{suggestedby}, >- suggestionid => $full_suggestion->{suggestionid}, >- to_address => $toaddress, >- message_transport_type => 'email', >- } >- ) or warn "can't enqueue letter $letter"; >+ my $emailpurchasesuggestions = C4::Context->preference("EmailPurchaseSuggestions"); >+ if ($emailpurchasesuggestions) { >+ my $full_suggestion = GetSuggestion( $new_id ); >+ if ( >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'suggestions', >+ letter_code => 'NEW_SUGGESTION', >+ tables => { >+ 'branches' => $full_suggestion->{branchcode}, >+ 'borrowers' => $full_suggestion->{suggestedby}, >+ 'suggestions' => $full_suggestion, >+ }, >+ ) >+ ){ >+ >+ my $toaddress = >+ ( $emailpurchasesuggestions eq "BranchEmailAddress" ) >+ ? ( Koha::Libraries->find( $full_suggestion->{branchcode} ) >+ ->branchemail >+ || C4::Context->preference('KohaAdminEmailAddress') ) >+ : C4::Context->preference($emailpurchasesuggestions); >+ >+ C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $full_suggestion->{suggestedby}, >+ suggestionid => $full_suggestion->{suggestionid}, >+ to_address => $toaddress, >+ message_transport_type => 'email', >+ } >+ ) or warn "can't enqueue letter $letter"; >+ } > } > > return $new_id; >diff --git a/installer/data/mysql/atomicupdate/bug_5770.perl b/installer/data/mysql/atomicupdate/bug_5770.perl >index 12e0d09c9c..627415ac55 100644 >--- a/installer/data/mysql/atomicupdate/bug_5770.perl >+++ b/installer/data/mysql/atomicupdate/bug_5770.perl >@@ -2,7 +2,7 @@ $DBversion = '18.12.00.XXX'; # will be replaced by the RM > if( CheckVersion( $DBversion ) ) { > $dbh->do( q{ > INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES >- ('EmailPurchaseSuggestions','KohaAdminEmailAddress','EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that will be sent new purchase suggestions','Choice'), >+ ('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that will be sent new purchase suggestions','Choice'), > ('EmailAddressForSuggestions','','','If you choose EmailAddressForSuggestions you should enter a valid email address','free') > }); > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 0d50342173..f3277f1239 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -160,7 +160,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL), > ('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'), > ('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'), >-('EmailPurchaseSuggestions','KohaAdminEmailAddress','EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'), >+('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'), > ('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'), > ('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'), > ('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >index 5347f270a0..adf86d77fb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >@@ -9,8 +9,9 @@ Administration: > - > - "Choose email address that new purchase suggestions will be sent to: " > - pref: EmailPurchaseSuggestions >- default: KohaAdminEmailAddress >+ default: 0 > choices: >+ 0: None > EmailAddressForSuggestions: EmailAddressForSuggestions > BranchEmailAddress: email address of branch > KohaAdminEmailAddress: KohaAdminEmailAddress >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 56e7d2240e..816786a2f8 100644 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -469,15 +469,24 @@ subtest 'DelSuggestionsOlderThan' => sub { > }; > > subtest 'EmailPurchaseSuggestions' => sub { >- plan tests => 5; >+ plan tests => 6; > > $dbh->do(q|DELETE FROM message_queue|); > > Koha::Libraries->find('CPL')->update({ branchemail => 'branchemail@b.c' }); > t::lib::Mocks::mock_preference( "KohaAdminEmailAddress", 'root@localhost'); > t::lib::Mocks::mock_preference( "EmailAddressForSuggestions", 'a@b.c'); >- t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", "KohaAdminEmailAddress"); # EmailAddressForSuggestions or BranchEmailAddress or KohaAdminEmailAddress > >+ # EmailAddressForSuggestions or BranchEmailAddress or KohaAdminEmailAddress or 0 >+ t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", "0"); >+ NewSuggestion($my_suggestion); >+ my $newsuggestions_messages = C4::Letters::GetQueuedMessages({ >+ borrowernumber => $borrowernumber >+ }); >+ >+ is( @$newsuggestions_messages, 0, 'NewSuggestions does not send an email when disabled' ); >+ >+ t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", "KohaAdminEmailAddress"); > NewSuggestion($my_suggestion); > my $newsuggestions_messages = C4::Letters::GetQueuedMessages({ > borrowernumber => $borrowernumber, >-- >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 5770
:
83384
|
83385
|
83386
|
83387
|
83388
|
83390
|
83615
|
83616
|
83617
|
84463
|
84812
|
89139
|
89140
|
89141
|
89142
|
89144
|
89145
|
89146
|
89147
|
89188
|
89189
|
89190
|
89191
| 89192 |
89193
|
89194
|
89195