From acbd58183348f40ecf77e5ba27a2371a56ba7833 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 20 Dec 2021 14:03:22 +0000 Subject: [PATCH] Bug 14364: (follow-up) Cleanup duplicate code and adjust notices and prefs This patch removes a duplicated stanza left form moving routine Changes the routines to use inbound_library_address Improves the display if the system preferences Updates the update file Moves smaple notice Signed-off-by: Katrin Fischer --- C4/Reserves.pm | 42 ++----------------- Koha/Hold.pm | 3 -- .../data/mysql/atomicupdate/bug_14364.perl | 31 ++++++++------ .../mysql/en/mandatory/sample_notices.yml | 16 +++++++ .../fr-FR/1-Obligatoire/sample_notices.sql | 4 +- installer/data/mysql/mandatory/sysprefs.sql | 2 +- .../admin/preferences/circulation.pref | 9 ++-- 7 files changed, 46 insertions(+), 61 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 61a543ce65..a77cc76384 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1818,7 +1818,6 @@ The following tables are availalbe witin the notice: sub _koha_notify_reserve { my $reserve_id = shift; - my $notify_library = shift; my $hold = Koha::Holds->find($reserve_id); my $borrowernumber = $hold->borrowernumber; @@ -1834,15 +1833,14 @@ sub _koha_notify_reserve { } ); my $library = Koha::Libraries->find( $hold->branchcode ); - my $admin_email_address = $library->from_email_address; - $library = $library->unblessed; + my $inbound_email_address = $library->inbound_email_address; my %letter_params = ( module => 'reserves', branchcode => $hold->branchcode, lang => $patron->lang, tables => { - 'branches' => $library, + 'branches' => $library->unblessed, 'borrowers' => $patron->unblessed, 'biblio' => $hold->biblionumber, 'biblioitems' => $hold->biblionumber, @@ -1866,7 +1864,7 @@ sub _koha_notify_reserve { C4::Letters::EnqueueLetter( { letter => $letter, borrowernumber => $borrowernumber, - from_address => $admin_email_address, + from_address => $inbound_email_address, message_transport_type => $mtt, } ); }; @@ -1887,37 +1885,6 @@ sub _koha_notify_reserve { &$send_notification('print', 'HOLD'); } - if ($notify_library) { - my $letter = C4::Letters::GetPreparedLetter( - module => 'reserves', - letter_code => 'HOLD_CHANGED', - branchcode => $hold->branchcode, - substitute => { today => output_pref( dt_from_string ) }, - tables => { - 'branches' => $library, - 'borrowers' => $patron->unblessed, - 'biblio' => $hold->biblionumber, - 'biblioitems' => $hold->biblionumber, - 'reserves' => $hold->unblessed, - 'items' => $hold->itemnumber, - }, - ); - - my $email = - C4::Context->preference('ExpireReservesAutoFillEmail') - || $library->{branchemail} - || C4::Context->preference('KohaAdminEmailAddress'); - - C4::Letters::EnqueueLetter( - { - letter => $letter, - borrowernumber => $borrowernumber, - message_transport_type => 'email', - from_address => $email, - to_address => $email, - } - ); - } } =head2 _koha_notify_hold_changed @@ -1951,8 +1918,7 @@ sub _koha_notify_hold_changed { my $email = C4::Context->preference('ExpireReservesAutoFillEmail') - || $library->branchemail - || C4::Context->preference('KohaAdminEmailAddress'); + || $library->inbound_email_address; C4::Letters::EnqueueLetter( { diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 1ec5c15e5e..540803fa4b 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -533,12 +533,9 @@ Cancel a hold: sub cancel { my ( $self, $params ) = @_; -<<<<<<< HEAD -======= my $autofill_next = $params->{autofill} && $self->itemnumber && $self->found && $self->found eq 'W'; ->>>>>>> Bug 14364: Allow automatically canceled expired waiting holds to fill the next hold $self->_result->result_source->schema->txn_do( sub { my $patron = $self->patron; diff --git a/installer/data/mysql/atomicupdate/bug_14364.perl b/installer/data/mysql/atomicupdate/bug_14364.perl index 2b50da6913..5a8b657c64 100644 --- a/installer/data/mysql/atomicupdate/bug_14364.perl +++ b/installer/data/mysql/atomicupdate/bug_14364.perl @@ -1,12 +1,19 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - $dbh->do(q{ - INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES - ('ExpireReservesAutoFill','0',NULL,'Automatically fill the next hold with a automatically canceled expired waiting hold.','YesNo'), - ('ExpireReservesAutoFillEmail','', NULL,'If ExpireReservesAutoFill and an email is defined here, the email notification for the change in the hold will be sent to this address.','Free'); - }); +use Modern::Perl; - $dbh->do(q{ +return { + bug_number => "14364", + description => "Allow automatically canceled expired waiting holds to fill the next hold", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('ExpireReservesAutoFill','0',NULL,'Automatically fill the next hold with a automatically canceled expired waiting hold.','YesNo'), + ('ExpireReservesAutoFillEmail','', NULL,'. Send email notification of hold filled from automatically expired/cancelled hold to this address. If not defined, Koha will fallback to the library reply to address','Free'); + }); + say $out "Added ExpireReservesAutoFill system preferences"; + + $dbh->do(q{ INSERT IGNORE INTO letter(module,code,branchcode,name,is_html,title,content,message_transport_type) VALUES ( 'reserves', 'HOLD_CHANGED', '', 'Canceled Hold Available for Different Patron', '0', 'Canceled Hold Available for Different Patron', 'The patron picking up <> (<>) has changed to <> <> (<>). @@ -14,9 +21,9 @@ Please update the hold information for this item. Title: <> Author: <> -Copy: <> +Item: <> Pickup location: <>', 'email'); - }); - - NewVersion( $DBversion, 14364, "Allow automatically canceled expired waiting holds to fill the next hold"); + }); + say $out "Added HOLD_CHANGED notice"; + }, } diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index 42d1d08351..879209af3d 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -1279,6 +1279,22 @@ tables: content: - "A hold has been placed on the following item : <> (<>) by the user <> <> (<>)." + - module: reserves + code: HOLD_CHANGED + branchcode: "" + name: "Canceled hold available for different patron" + is_html: 0 + title: "Canceled hold available for different patron" + message_transport_type: email + lang: default + content: + - "The patron picking up <> (<>) has changed to <> <> (<>)." + - "Please update the hold information for this item." + - "Title: <>" + - "Author: <>" + - "Item: <>" + - "Pickup location: <>" + - module: reserves code: HOLD_REMINDER branchcode: "" diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql index eb85dbf5fe..2eb4ff9421 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql @@ -504,11 +504,11 @@ INSERT IGNORE INTO letter (module, code, name, title, content, message_transport [% END %] ", 'email'); INSERT INTO letter(module,code,branchcode,name,is_html,title,content,message_transport_type) - VALUES ( 'reserves', 'HOLD_CHANGED', '', 'Canceled Hold Available for Different Patron', '0', 'Canceled Hold Available for Different Patron', 'The patron picking up <> (<>) has changed to <> <> (<>). + VALUES ( 'reserves', 'HOLD_CHANGED', '', 'Canceled hold available for different patron', '0', 'Canceled hold available for different patron', 'The patron picking up <> (<>) has changed to <> <> (<>). Please update the hold information for this item. Title: <> Author: <> -Copy: <> +Item: <> Pickup location: <>', 'email'); diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 27e41a71b5..0993af7c65 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -208,7 +208,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('EnhancedMessagingPreferencesOPAC', '1', NULL, 'If ON, show patrons messaging setting on the OPAC.', 'YesNo'), ('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'), ('ExpireReservesAutoFill','0',NULL,'Automatically fill the next hold with a automatically canceled expired waiting hold.','YesNo'), -('ExpireReservesAutoFillEmail','', NULL,'If ExpireReservesAutoFill and an email is defined here, the email notification for the change in the hold will be sent to this address.','Free'), +('ExpireReservesAutoFillEmail','', NULL,'Send email notification of hold filled from automatically expired/cancelled hold to this address. If not defined, Koha will fallback to the library reply to address','Free'), ('ExpireReservesMaxPickUpDelay','0','','Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay','YesNo'), ('ExpireReservesMaxPickUpDelayCharge','0',NULL,'If ExpireReservesMaxPickUpDelay is enabled, and this field has a non-zero value, than a borrower whose waiting hold has expired will be charged this amount.','free'), ('ExpireReservesOnHolidays', '1', NULL, 'If false, reserves at a library will not be canceled on days the library is not open.', 'YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 691cdd74dd..d770404255 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -739,17 +739,16 @@ Circulation: choices: 1: Allow 0: "Don't allow" - - 'holds to expire automatically if they have not been picked by within the time period specified in the ReservesMaxPickUpDelay system preference.' - - '
NOTE: This system preference requires the misc/cronjobs/holds/cancel_expired_holds.pl cronjob. Ask your system administrator to schedule it.
' + - 'holds to expire automatically if they have not been picked by within the time period specified in the ReservesMaxPickUpDelay system preference.
' - pref: ExpireReservesAutoFill choices: 1: "Do" 0: "Don't" - - automatically fill the next hold using the item. If enabled, an email notification will be sent to either the email address defined in ExpireReservesAutoFillEmail, the item's holding library's email address, or the email address defined in KohaAdminEmailAddress in that order. - - + - automatically fill the next hold using the item. - Send email notification of the new hold filled with a canceled item to - pref: ExpireReservesAutoFillEmail - - . If no address is defined here, the email will be sent to either the item's holding library or the email address defined in KohaAdminEmailAddress in that order. + - . If no address is defined here, the email will be sent to the library's reply to address. + - '
NOTE: These system preferences require the misc/cronjobs/holds/cancel_expired_holds.pl cronjob. Ask your system administrator to schedule it.
' - - If using ExpireReservesMaxPickUpDelay, charge a patron who allows their waiting hold to expire a fee of - pref: ExpireReservesMaxPickUpDelayCharge -- 2.30.2