Bug 31577: Use patron category multi-select for OpacHiddenItemsExceptions system preference

We are now using the patron category selects on almost all system
preferences, but OpacHiddenItemsExceptions was still missing.

To test:
- Before applying the patch:
- Add patron categories to OpacHiddenItemsExceptions using |
- Add configuration to OpacHiddenItems
- Verify all works as expected in the OPAC
- Apply patch, run database update
- Verify the system preference shows the correct settings from before
- Verify feature still works as expected

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Katrin Fischer 2022-09-19 21:32:12 +00:00 committed by Tomas Cohen Arazi
parent 043017af13
commit e982b7d953
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
5 changed files with 25 additions and 5 deletions

View File

@ -202,7 +202,7 @@ TODO: Remove on bug 22547
sub override_hidden_items {
my ($self) = @_;
return any { $_ eq $self->categorycode }
split( /\|/, C4::Context->preference('OpacHiddenItemsExceptions') );
split( ',', C4::Context->preference('OpacHiddenItemsExceptions') );
}
=head3 can_make_suggestions

View File

@ -0,0 +1,18 @@
use Modern::Perl;
return {
bug_number => "31577",
description => "Add category list pull-down to OpacHiddenItemsExceptions",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
# Do you stuffs here
$dbh->do(q{
UPDATE systempreferences SET value = REPLACE(value,"|",","),
explanation = REPLACE(explanation,"separated by |,","separated by comma,")
WHERE variable = "OpacHiddenItemsExceptions"
});
# Print useful stuff here
say $out "Settings for OpacHiddenItemsExceptions have been updated";
},
};

View File

@ -441,7 +441,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('OPACFinesTab','1','','If OFF the patron fines tab in the OPAC is disabled.','YesNo'),
('OPACFRBRizeEditions','0','','If ON, the OPAC will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'),
('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at the OPAC. See http://wiki.koha-community.org/wiki/OpacHiddenItems for more information.','Textarea'),
('OpacHiddenItemsExceptions','',NULL,'List of borrower categories, separated by |, that can see items otherwise hidden by OpacHiddenItems','Textarea'),
('OpacHiddenItemsExceptions','',NULL,'List of borrower categories, separated by comma, that can see items otherwise hidden by OpacHiddenItems','Textarea'),
('OpacHiddenItemsHidesRecord','1','','Hide biblio record when all its items are hidden because of OpacHiddenItems','YesNo'),
('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'),
('OPACHoldingsDefaultSortField','first_column','first_column|homebranch|holdingbranch','Default sort field for the holdings table at the OPAC','choice'),

View File

@ -592,8 +592,10 @@ OPAC:
class: code
- Define custom rules to hide specific items from search and view on the OPAC. How to write these rules is documented on the <a href="http://wiki.koha-community.org/wiki/OpacHiddenItems" target="_blank">Koha wiki</a>.
-
- 'List of patron categories, separated by |, that can see items otherwise hidden by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OpacHiddenItems">OpacHiddenItems</a>:'
- 'List of patron categories, that can see items otherwise hidden by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OpacHiddenItems">OpacHiddenItems</a>:'
- pref: OpacHiddenItemsExceptions
choices: patron-categories
class: multiple
-
- pref: OpacHiddenItemsHidesRecord
default: 1

View File

@ -155,12 +155,12 @@ subtest 'override_hidden_items() tests' => sub {
my $category_1 = $builder->build_object({ class => 'Koha::Patron::Categories' });
my $category_2 = $builder->build_object({ class => 'Koha::Patron::Categories' });
t::lib::Mocks::mock_preference( 'OpacHiddenItemsExceptions', $category_1->categorycode . '|' . $category_2->categorycode . '|RANDOM' );
t::lib::Mocks::mock_preference( 'OpacHiddenItemsExceptions', $category_1->categorycode . ',' . $category_2->categorycode . ',RANDOM' );
ok( $category_1->override_hidden_items, 'Category configured to override' );
ok( $category_2->override_hidden_items, 'Category configured to override' );
t::lib::Mocks::mock_preference( 'OpacHiddenItemsExceptions', 'RANDOM|' . $category_2->categorycode );
t::lib::Mocks::mock_preference( 'OpacHiddenItemsExceptions', 'RANDOM,' . $category_2->categorycode );
ok( !$category_1->override_hidden_items, 'Category not configured to override' );
ok( $category_2->override_hidden_items, 'Category configured to override' );