@@ -, +, @@ them - Go to Administration -> System preferences. - Test each of the updated preferences to confirm that the available options are correct and that your selections are correctly saved. - Single category selections, PatronSelfRegistrationDefaultCategory and GoogleOpenIDConnectDefaultCategory. With each of these you should see a dropdown where you can select of all the existing patron categories. - Multiple selections, OPACHoldsIfAvailableAtPickup and BatchCheckouts: These preferences should have an option for selecting one or more system preferences at once. - Test the pages affected by the updated system preferences: - With BatchCheckouts enabled, confirm that the batch checkout page is correctly limited by patron category. - Set the OPACHoldsIfAvailableAtPickup preference to "Don't allow" and select at least one patron category in the OPACHoldsIfAvailableAtPickupExceptions preference. - Log in to the OPAC as a patron whose category was not selected in the OPACHoldsIfAvailableAtPickupExceptions preference. - Try to place a hold on an item which is available at a library. - When confirming the hold, the libraries where the item is available should be disabled in the "Pick up location" dropdown. - Repeat the process as a patron whose category was selected in OPACHoldsIfAvailableAtPickupExceptions. There should be no disabled pickup locations. --- admin/preferences.pl | 27 ++++++++++++++++++++-- circ/circulation.pl | 2 +- installer/data/mysql/atomicupdate/bug_27652.perl | 11 +++++++++ .../intranet-tmpl/prog/en/includes/circ-menu.inc | 2 +- .../prog/en/modules/admin/preferences/admin.pref | 1 + .../en/modules/admin/preferences/circulation.pref | 6 +++-- .../prog/en/modules/admin/preferences/opac.pref | 2 +- opac/opac-reserve.pl | 2 +- 8 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_27652.perl --- a/admin/preferences.pl +++ a/admin/preferences.pl @@ -91,6 +91,7 @@ sub _get_chunk { $chunk->{'languages'} = getTranslatedLanguages( $interface, $theme, undef, $current_languages ); $chunk->{'type'} = 'languages'; } elsif ( $options{ 'choices' } ) { + my $add_blank; if ( $options{'choices'} && ref( $options{ 'choices' } ) eq '' ) { if ( $options{'choices'} eq 'class-sources' ) { my $sources = GetClassSources(); @@ -99,6 +100,9 @@ sub _get_chunk { $options{'choices'} = { map { $_ => $_ } getallthemes( 'opac' ) } } elsif ( $options{'choices'} eq 'staff-templates' ) { $options{'choices'} = { map { $_ => $_ } getallthemes( 'intranet' ) } + } elsif ( $options{choices} eq 'patron-categories' ) { + $options{choices} = { map { $_->categorycode => $_->description } Koha::Patron::Categories->search }; + $add_blank = 1; } else { die 'Unrecognized source of preference values: ' . $options{'choices'}; } @@ -106,12 +110,31 @@ sub _get_chunk { $value ||= 0; - $chunk->{'type'} = 'select'; + $chunk->{'type'} = ( $options{class} && $options{class} eq 'multiple' ) ? 'multiple' : 'select'; + + my @values; + @values = split /,/, $value if defined($value); $chunk->{'CHOICES'} = [ sort { $a->{'text'} cmp $b->{'text'} } - map { { text => $options{'choices'}->{$_}, value => $_, selected => ( $_ eq $value || ( $_ eq '' && ( $value eq '0' || !$value ) ) ) } } + map { + my $c = $_; + { + text => $options{'choices'}->{$c}, + value => $c, + selected => ( + grep { $_ eq $c || ( $c eq '' && ($value eq '0' || !$value ) ) } @values + ) ? 1 : 0, + } + } keys %{ $options{'choices'} } ]; + + # Add a first blank value if needed + unshift @{ $chunk->{CHOICES} }, { + text => '', + value => '', + } if $add_blank && $chunk->{type} eq 'select'; + } elsif ( $options{'multiple'} ) { my @values; @values = split /,/, $value if defined($value); --- a/circ/circulation.pl +++ a/circ/circulation.pl @@ -116,7 +116,7 @@ my $batch = $query->param('batch'); my $batch_allowed = 0; if ( $batch && C4::Context->preference('BatchCheckouts') ) { $template_name = q|circ/circulation_batch_checkouts.tt|; - my @batch_category_codes = split '\|', C4::Context->preference('BatchCheckoutsValidCategories'); + my @batch_category_codes = split ',', C4::Context->preference('BatchCheckoutsValidCategories'); my $categorycode = $patron->categorycode; if ( $categorycode && grep { $_ eq $categorycode } @batch_category_codes ) { $batch_allowed = 1; --- a/installer/data/mysql/atomicupdate/bug_27652.perl +++ a/installer/data/mysql/atomicupdate/bug_27652.perl @@ -0,0 +1,11 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + $dbh->do(q{ + UPDATE systempreferences + value=REPLACE(value, '|', ',') + WHERE variable="OPACHoldsIfAvailableAtPickupExceptions" + OR variable="BatchCheckoutsValidCategories" + }); + NewVersion( $DBversion, 27652, "Separate values for OPACHoldsIfAvailableAtPickupExceptions and BatchCheckoutsValidCategories with comma"); +} --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -125,7 +125,7 @@