From 011c6c8becb3ae40d8aecffcb46b23a9d81b801c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 22 Oct 2021 09:46:43 +0200 Subject: [PATCH] Bug 11175: Add syspref MaxComponentRecords to remove hardcoded limit --- catalogue/detail.pl | 2 +- installer/data/mysql/atomicupdate/bug_11175.perl | 3 +++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/cataloguing.pref | 8 ++++++-- .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 4 ++-- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt | 4 ++-- opac/opac-detail.pl | 2 +- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 1660ac15d3b..8eae1832b03 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -214,7 +214,7 @@ foreach my $subscription (@subscriptions) { # Get component parts details my $showcomp = C4::Context->preference('ShowComponentRecords'); if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { - if ( my $components = $biblio->get_marc_components(300) ) { + if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) { my $parts; for my $part ( @{$components} ) { $part = C4::Search::new_record_from_zebra( 'biblioserver', $part ); diff --git a/installer/data/mysql/atomicupdate/bug_11175.perl b/installer/data/mysql/atomicupdate/bug_11175.perl index 3f56e7e2c45..fda51788e47 100644 --- a/installer/data/mysql/atomicupdate/bug_11175.perl +++ b/installer/data/mysql/atomicupdate/bug_11175.perl @@ -1,6 +1,9 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { $dbh->do("INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('ShowComponentRecords', 'nowhere', 'nowhere|staff|opac|both','In which record detail pages to show list of the component records, as linked via 773','Choice')"); + + $dbh->do("INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('MaxComponentRecords', '300', '','Max number of component records to display','Integer')"); + SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 11175: Show component records in detail views)\n"; } diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 5c36bd769ab..61cae7c84c4 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -618,6 +618,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('ShelfBrowserUsesLocation','1','1','Use the item location when finding items for the shelf browser.','YesNo'), ('ShowAllCheckins', '0', '', 'Show all checkins', 'YesNo'), ('ShowComponentRecords', 'nowhere', 'nowhere|staff|opac|both','In which record detail pages to show list of the component records, as linked via 773','Choice'), +('MaxComponentRecords', '300', '','Max number of component records to display','Integer'), ('showLastPatron','0','','If ON, enables the last patron feature in the intranet','YesNo'), ('ShowPatronImageInWebBasedSelfCheck','0','','If ON, displays patron image when a patron uses web-based self-checkout','YesNo'), ('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index 8ee80ebd22b..50f35083ec5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -268,14 +268,18 @@ Cataloging: - "
  • subfields a and b of fields 245
  • " - "
  • all subfields of fields 600
  • " - - - Show a list of component records, as linked via field 773, in + - "Show a list of component records, as linked via field 773, in" - pref: ShowComponentRecords choices: nowhere: "no" staff: "staff interface" opac: "OPAC" both: "both staff interface and OPAC" - - record detail pages. UNIMARC is not supported. + - "record detail pages." + - "A maximum of" + - pref: MaxComponentRecords + - "records will be displayed." + - "
    UNIMARC is not supported." Importing: - - When matching on ISBN with the record import tool, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 8eed703682d..8e4c8375f1e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -692,8 +692,8 @@ Note that permanent location is a code, and location may be an authval. [% END %] - [% IF ComponentParts.size == 300 %] -

    Only 300 results are shown: show all component parts

    + [% IF ComponentParts.size == Koha.Preference('MaxComponentRecords')%] +

    Only [% ComponentParts.size %] results are shown: show all component parts

    [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 3a7e6c7e9ea..4d0b28e456c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -581,8 +581,8 @@ [% END %] - [% IF ComponentParts.size == 300 %] -

    Only 300 results are shown: show all component parts

    + [% IF ComponentParts.size == Koha.Preference('MaxComponentRecords')%] +

    Only [% ComponentParts.size %] results are shown: show all component parts

    [% END %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 0e647f7bc61..eb3124a06d8 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -661,7 +661,7 @@ my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 5 my $showcomp = C4::Context->preference('ShowComponentRecords'); my $parts; if ( $showcomp eq 'both' || $showcomp eq 'opac' ) { - if ( my $components = $biblio->get_marc_components(300) ) { + if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) { for my $part ( @{$components} ) { $part = C4::Search::new_record_from_zebra( 'biblioserver', $part ); -- 2.25.1