From b7956605401be015d34367ce474a1b3b574c31ca Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 14 Apr 2021 11:25:57 +0000 Subject: [PATCH] Bug 21260: (follow-up) Consolidate preference The bug added a local preference. This should now become a real one. Renamed in the process to better reflect its use. Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- C4/XSLT.pm | 2 +- installer/data/mysql/atomicupdate/bug21260.perl | 8 ++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/opac.pref | 4 ++++ t/db_dependent/XSLT.t | 8 ++++---- 5 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug21260.perl diff --git a/C4/XSLT.pm b/C4/XSLT.pm index cd183fbe51..12c97db41e 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -316,7 +316,7 @@ sub buildKohaItemsNamespace { my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; my $xml = ''; my %descs = map { $_->{authorised_value} => $_ } Koha::AuthorisedValues->get_descriptions_by_koha_field( { kohafield => 'items.notforloan' } ); - my $ref_status = C4::Context->preference('Available_NFL') || '1|2'; + my $ref_status = C4::Context->preference('Reference_NFL_Statuses') || '1|2'; for my $item (@items) { my $status; diff --git a/installer/data/mysql/atomicupdate/bug21260.perl b/installer/data/mysql/atomicupdate/bug21260.perl new file mode 100644 index 0000000000..46050dca65 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug21260.perl @@ -0,0 +1,8 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) + VALUES ('Reference_NFL_Statuses','1|2',NULL,'Contains not for loan statuses considered as available for reference','Free') + }); + NewVersion( $DBversion, 21260, "Add preference Reference_NFL_Statuses"); +} diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index d73357bc40..40e5dc3ee5 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -551,6 +551,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'), ('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'), ('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'), +('Reference_NFL_Statuses','1|2',NULL,'Contains not for loan statuses considered as available for reference','Free'), ('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'), ('RenewAccruingItemWhenPaid','0','','If enabled, when the fines on an item accruing is paid off, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'), ('RenewAccruingItemInOpac','0','','If enabled, when the fines on an item accruing is paid off in the OPAC via a payment plugin, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index c7f0bd8111..8e56f74984 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -350,6 +350,10 @@ OPAC: top: "top" footer: "only footer" - "." + - + - "List the following not for loan statuses as available for reference in OPAC search results:" + - pref: Reference_NFL_Statuses + - "(Use | as delimiter.)" Features: - - pref: OPACReportProblem diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t index 16487db5ec..87e00a4bf5 100755 --- a/t/db_dependent/XSLT.t +++ b/t/db_dependent/XSLT.t @@ -36,7 +36,7 @@ $schema->storage->txn_begin; subtest 'buildKohaItemsNamespace status tests' => sub { plan tests => 14; - t::lib::Mocks::mock_preference('Available_NFL', '1|2'); + t::lib::Mocks::mock_preference('Reference_NFL_Statuses', '1|2'); my $itype = $builder->build_object({ class => 'Koha::ItemTypes' }); my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); @@ -73,10 +73,10 @@ subtest 'buildKohaItemsNamespace status tests' => sub { like($xml,qr{reference},"reference if positive notforloan value"); # But now make status notforloan==1 count under Not available - t::lib::Mocks::mock_preference('Available_NFL', '2'); + t::lib::Mocks::mock_preference('Reference_NFL_Statuses', '2'); $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); - like($xml,qr{reallynotforloan},"reallynotforloan when we change Avaiable_NFL"); - t::lib::Mocks::mock_preference('Available_NFL', '1|2'); + like($xml,qr{reallynotforloan},"reallynotforloan when we change Reference_NFL_Statuses"); + t::lib::Mocks::mock_preference('Reference_NFL_Statuses', '1|2'); } $item->onloan('2001-01-01')->store; -- 2.39.5