View | Details | Raw Unified | Return to bug 15494
Collapse All | Expand All

(-)a/C4/Circulation.pm (-4 / +5 lines)
Lines 4108-4122 sub _item_denied_renewal { Link Here
4108
    my $item = $params->{item};
4108
    my $item = $params->{item};
4109
    return unless $item;
4109
    return unless $item;
4110
4110
4111
    my $yaml = C4::Context->preference('ItemsDeniedRenewal');
4111
    my @lines = split /\n/, C4::Context->preference('ItemsDeniedRenewal')//'';
4112
    my @lines = split /\n/, $yaml;
4113
    my $denyingrules;
4112
    my $denyingrules;
4114
    foreach my $line (@lines){
4113
    foreach my $line (@lines){
4115
        my ($field,$array) = split /:/, $line;
4114
        my ($field,$array) = split /:/, $line;
4115
        next if !$array;
4116
        $field =~ s/^\s*|\s*$//g;
4116
        $array =~ s/[ [\]\r]//g;
4117
        $array =~ s/[ [\]\r]//g;
4117
        my @array = split /,/, $array;
4118
        my @array = split /,/, $array;
4119
        @array = map { $_ eq '""' || $_ eq "''" ? '' : $_ } @array;
4118
        @array = map { $_ eq 'NULL' ? undef : $_ } @array;
4120
        @array = map { $_ eq 'NULL' ? undef : $_ } @array;
4119
        @array = map { $_ eq '""' || $_ eq "''" ? undef : $_ } @array;
4120
        $denyingrules->{$field} = \@array;
4121
        $denyingrules->{$field} = \@array;
4121
    }
4122
    }
4122
    return unless $denyingrules;
4123
    return unless $denyingrules;
Lines 4126-4132 sub _item_denied_renewal { Link Here
4126
            if ( any { !defined $_ }  @{$denyingrules->{$field}} ){
4127
            if ( any { !defined $_ }  @{$denyingrules->{$field}} ){
4127
                return 1;
4128
                return 1;
4128
            }
4129
            }
4129
        } elsif (any { $val eq $_ } @{$denyingrules->{$field}}) {
4130
        } elsif (any { defined($_) && $val eq $_ } @{$denyingrules->{$field}}) {
4130
           # If the results matches the values in the syspref
4131
           # If the results matches the values in the syspref
4131
           # We return true if match found
4132
           # We return true if match found
4132
            return 1;
4133
            return 1;
(-)a/t/db_dependent/Circulation.t (-3 / +12 lines)
Lines 2212-2218 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
2212
};
2212
};
2213
2213
2214
subtest 'ItemsDeniedRenewal preference' => sub {
2214
subtest 'ItemsDeniedRenewal preference' => sub {
2215
    plan tests => 16;
2215
    plan tests => 18;
2216
2216
2217
    t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', '' );
2217
    t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', '' );
2218
2218
Lines 2289-2295 subtest 'ItemsDeniedRenewal preference' => sub { Link Here
2289
    is( $idr_mayrenew, 1, 'Renewal allowed when 1 rules not matched (withdrawn)' );
2289
    is( $idr_mayrenew, 1, 'Renewal allowed when 1 rules not matched (withdrawn)' );
2290
    is( $idr_error, undef, 'Renewal allowed when 1 rules not matched (withdrawn)' );
2290
    is( $idr_error, undef, 'Renewal allowed when 1 rules not matched (withdrawn)' );
2291
2291
2292
    $idr_rules="withdrawn: [1]\ntype: [HIDE,INVISILE]";
2292
    $idr_rules="withdrawn: [1]\nitype: [HIDE,INVISIBLE]";
2293
2293
2294
    t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules );
2294
    t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules );
2295
    ( $idr_mayrenew, $idr_error ) =
2295
    ( $idr_mayrenew, $idr_error ) =
Lines 2318-2324 subtest 'ItemsDeniedRenewal preference' => sub { Link Here
2318
    ( $idr_mayrenew, $idr_error ) =
2318
    ( $idr_mayrenew, $idr_error ) =
2319
    CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber );
2319
    CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber );
2320
    is( $idr_mayrenew, 0, 'Renewal blocked for undef when NULL in pref' );
2320
    is( $idr_mayrenew, 0, 'Renewal blocked for undef when NULL in pref' );
2321
    $idr_rules="itemcallnumber: ['']";
2322
    t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules );
2323
    ( $idr_mayrenew, $idr_error ) =
2324
    CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber );
2325
    is( $idr_mayrenew, 1, 'Renewal not blocked for undef when "" in pref' );
2321
2326
2327
    $idr_rules="itemnotes: [NULL]";
2328
    t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules );
2329
    ( $idr_mayrenew, $idr_error ) =
2330
    CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber );
2331
    is( $idr_mayrenew, 1, 'Renewal not blocked for "" when NULL in pref' );
2322
    $idr_rules="itemnotes: ['']";
2332
    $idr_rules="itemnotes: ['']";
2323
    t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules );
2333
    t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules );
2324
    ( $idr_mayrenew, $idr_error ) =
2334
    ( $idr_mayrenew, $idr_error ) =
2325
- 

Return to bug 15494