From 913e3a8267c1240d8639b82f771454ef11aa21a5 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 8 Feb 2023 16:57:14 +0000 Subject: [PATCH] Bug 32911: Remove ILL partner_code config from koha-conf.xml and turn it into a system preference Preparation: 1) apply patch 2) run reset_all 3) enable ILLModule sys preference 4) install a backend (e.g. FreeForm) 5) go into system preferences and confirm that ILLPartnerCode exists and is the default inter-library loan (IL) Test plan: 1) create an ILL request 2) ensure the patron of category 'IL' has a primary e-mail configured 3) click on "place request with partners" 4) verify that the patron(s) of said category are on the partners list Upgrade test: 1) Remove the system preference from the database, run query: delete from systempreferences where variable="ILLPartnerCode"; 2) Check or edit the value or partner_code in koha-conf.xml and run atomicupdate: installer/data/mysql/updatedatabase.pl 3) Confirm the value in koha-conf.xml has been successfully migrated into the system preference, run query: select * from systempreferences where variable="ILLPartnerCode"; Optional tests: - Set a patron category in the sys pref and then delete said patron category (needs to not have patrons in it) - Check the about page -> System information and confirm the warning message is correct - Set the sys pref to the empty option - Check the about page -> System information and confirm the warning message is correct - Set the sys pref to a category that has no patrons of its type (ktd examples: Board, or Library) - Check the about page -> System information and confirm the warning message is correct Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- Koha/Illrequest/Config.pm | 2 +- about.pl | 11 +++++++---- installer/data/mysql/mandatory/sysprefs.sql | 1 + koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 12 ++++++++++-- .../admin/preferences/interlibrary_loans.pref | 5 +++++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Koha/Illrequest/Config.pm b/Koha/Illrequest/Config.pm index 02dac2ca65..84f4067df3 100644 --- a/Koha/Illrequest/Config.pm +++ b/Koha/Illrequest/Config.pm @@ -319,7 +319,7 @@ sub _load_configuration { if ( $reply_date && 'hide' eq $reply_date ); # ILL Partners - $configuration->{partner_code} = $xml_config->{partner_code} || 'IL'; + $configuration->{partner_code} = C4::Context->preference('ILLPartnerCode') || 'IL'; return $configuration; } diff --git a/about.pl b/about.pl index 886fef9c7b..1a9b93a1a3 100755 --- a/about.pl +++ b/about.pl @@ -304,13 +304,16 @@ if ( C4::Context->preference('ILLModule') ) { $warnILLConfiguration = 1; } - # Check partner_code - if ( !Koha::Patron::Categories->find($ill_config->partner_code) ) { - $template->param( ill_partner_code_doesnt_exist => $ill_config->partner_code ); + # Check ILLPartnerCode sys pref + if ( !Koha::Patron::Categories->find( C4::Context->preference('ILLPartnerCode') ) ) { + $template->param( ill_partner_code_doesnt_exist => C4::Context->preference('ILLPartnerCode') ); + $warnILLConfiguration = 1; + } elsif ( !Koha::Patrons->search( { categorycode => C4::Context->preference('ILLPartnerCode') } )->count ) { + $template->param( ill_partner_code_no_patrons => C4::Context->preference('ILLPartnerCode') ); $warnILLConfiguration = 1; } - if ( !$ill_config_from_file->{partner_code} ) { + if ( !C4::Context->preference('ILLPartnerCode') ) { # partner code not defined $template->param( ill_partner_code_not_defined => 1 ); $warnILLConfiguration = 1; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index f8fd314f2c..4e4124614b 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -291,6 +291,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea'), ('ILLModuleUnmediated','0','','If enabled, try to immediately progress newly placed ILL requests.','YesNo'), ('ILLOpacbackends',NULL,NULL,'ILL backends to enabled for OPAC initiated requests','multiple'), +('ILLPartnerCode','IL','','Patrons from this patron category will be used as partners to place ILL requests with','free'), ('ILLSendStaffNotices', NULL, NULL, 'Send these ILL notices to staff', 'multiple'), ('ILS-DI','0','','Enables ILS-DI services at OPAC.','YesNo'), ('ILS-DI:AuthorizedIPs','','Restricts usage of ILS-DI to some IPs','.','Free'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index cb36cbc284..a90a71c0d0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -504,7 +504,15 @@ Warning - The ILL module is enabled, but no 'partner_code' defined in koha-conf.xml. Falling back to the hardcoded 'IL'. + The ILL module is enabled, but ILLPartnerCode system preference is empty. Falling back to the hardcoded 'IL'. + + + [% END %] + [% IF ill_partner_code_no_patrons %] + + Warning + + The ILL module is enabled and ILLPartnerCode system preference configured, but there are no patrons in [% ill_partner_code_no_patrons | html %] category. [% END %] @@ -520,7 +528,7 @@ Warning - The ILL module is enabled, but the configured 'partner_code' ([% ill_partner_code_doesnt_exist | html %]) is not defined on the system. + The ILL module is enabled, but the configured ILLPartnerCode ([% ill_partner_code_doesnt_exist | html %]) is not defined on the system. [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/interlibrary_loans.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/interlibrary_loans.pref index 2f724d4151..73cb9c12f5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/interlibrary_loans.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/interlibrary_loans.pref @@ -44,6 +44,11 @@ Interlibrary loans: - pref: ILLSendStaffNotices class: multi - "(separated with |). e.g. ILL_REQUEST_CANCEL|ILL_REQUEST_MODIFIED If left empty, no staff ILL notices will be sent." + - + - "Use patrons from category" + - pref: ILLPartnerCode + choices: patron-categories + - "as partners to place ILL requests with." - - "Fallback email address for staff ILL notices to be sent to in the absence of a library address:" - pref: ILLDefaultStaffEmail -- 2.40.1