Bug 20310: Adding a pref to control behavior
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tue, 8 Sep 2020 13:29:45 +0000 (13:29 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 12 Jul 2021 13:47:34 +0000 (15:47 +0200)
If people want to control the redirection, we could add a pref
like ArticleRequestsHostRedirection. If it is not enabled,
the party is over.

Test plan:
Test if redirection stops on a child and host when you disable.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/Biblio.pm
installer/data/mysql/atomicupdate/bug_20130.perl [new file with mode: 0644]
installer/data/mysql/mandatory/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
t/db_dependent/Koha/Biblio/host_record.t

index 3b38a82..12b22d9 100644 (file)
@@ -910,6 +910,7 @@ sub host_record {
     my ($self, $params) = @_;
     my $no_items = $params->{no_items};
     return if C4::Context->preference('marcflavour') eq 'UNIMARC'; # TODO
+    return if !C4::Context->preference('ArticleRequestsHostRedirection');
     return if $params->{no_items} && $self->items->count > 0;
 
     my $record;
diff --git a/installer/data/mysql/atomicupdate/bug_20130.perl b/installer/data/mysql/atomicupdate/bug_20130.perl
new file mode 100644 (file)
index 0000000..c8e7143
--- /dev/null
@@ -0,0 +1,8 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+            ('ArticleRequestsHostRedirection', '0', NULL, 'Enables redirection from child to host', 'YesNo')
+    });
+    NewVersion( $DBversion, 20310, "Add pref ArticleRequestsHostRedirection");
+}
index 3430bc2..a795c81 100644 (file)
@@ -56,6 +56,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'),
 ('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for suggestion and checkout history privacy',''),
 ('ArticleRequests', '0', NULL, 'Enables the article request feature', 'YesNo'),
+('ArticleRequestsHostRedirection', '0', NULL, 'Enables redirection from child to host', 'YesNo'),
 ('ArticleRequestsLinkControl', 'calc', 'always|calc', 'Control display of article request link on search results', 'Choice'),
 ('ArticleRequestsMandatoryFields', '', NULL, 'Comma delimited list of required fields for bibs where article requests rule = ''yes''', 'multiple'),
 ('ArticleRequestsMandatoryFieldsItemOnly', '', NULL, 'Comma delimited list of required fields for bibs where article requests rule = ''item_only''', 'multiple'),
index 348a455..e8ca2ff 100644 (file)
@@ -1193,6 +1193,12 @@ Circulation:
                   0: "Don't enable"
             - patrons to place article requests.
         -
+            - pref: ArticleRequestsHostRedirection
+              choices:
+                  yes: Enable
+                  no: Disable
+            - " redirection from child to host based on MARC21 773$w when the child has no items."
+        -
             - pref: ArticleRequestsLinkControl
               choices:
                   always: Always show
index 59b9f13..bf728f1 100644 (file)
@@ -40,6 +40,7 @@ subtest 'host_record' => sub {
 
     t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' );
     t::lib::Mocks::mock_preference( 'MARCOrgCode', 'xyz' );
+    t::lib::Mocks::mock_preference( 'ArticleRequestsHostRedirection', 1 );
 
     my $bib1 = $builder->build_object({ class => 'Koha::Biblios' });
     my $bib2 = $builder->build_object({ class => 'Koha::Biblios' });