From 482f3f1630e990097dff1c1d2961b407adaf047c 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 Signed-off-by: Tomas Cohen Arazi --- C4/Reserves.pm | 42 ++----------------- Koha/Hold.pm | 3 -- .../data/mysql/atomicupdate/bug_14364.perl | 31 ++++++++------ .../mysql/en/mandatory/sample_notices.yml | 16 +++++++ installer/data/mysql/mandatory/sysprefs.sql | 2 +- .../admin/preferences/circulation.pref | 9 ++-- 6 files changed, 44 insertions(+), 59 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 90d4e56cbe..d5e01f283d 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1875,7 +1875,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; @@ -1891,15 +1890,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, @@ -1923,7 +1921,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, } ); }; @@ -1944,37 +1942,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 @@ -2008,8 +1975,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 6e180daebf..e5573ba024 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -637,12 +637,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 416b16bff0..cdb8ab18d0 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -1306,6 +1306,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/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index bc6813a1ca..2e6c261937 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -216,7 +216,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 fb1aaf38b2..70918540b8 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 @@ -770,17 +770,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.39.5