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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 56-62 use Koha::Account::Lines; Link Here
56
use Koha::Account::Offsets;
56
use Koha::Account::Offsets;
57
use Koha::Config::SysPrefs;
57
use Koha::Config::SysPrefs;
58
use Koha::Charges::Fees;
58
use Koha::Charges::Fees;
59
use Koha::Util::SystemPreferences;
59
use Koha::Config::SysPref;
60
use Koha::Checkouts::ReturnClaims;
60
use Koha::Checkouts::ReturnClaims;
61
use Koha::SearchEngine::Indexer;
61
use Koha::SearchEngine::Indexer;
62
use Carp;
62
use Carp;
Lines 1986-1992 sub AddReturn { Link Here
1986
    my $borrowernumber = $patron ? $patron->borrowernumber : undef;    # we don't know if we had a borrower or not
1986
    my $borrowernumber = $patron ? $patron->borrowernumber : undef;    # we don't know if we had a borrower or not
1987
    my $patron_unblessed = $patron ? $patron->unblessed : {};
1987
    my $patron_unblessed = $patron ? $patron->unblessed : {};
1988
1988
1989
    my $update_loc_rules = get_yaml_pref_hash('UpdateItemLocationOnCheckin');
1989
    my $update_loc_rules = Koha::Config::SysPrefs->find('UpdateItemLocationOnCheckin')->get_yaml_pref_hash();
1990
    map { $update_loc_rules->{$_} = $update_loc_rules->{$_}[0] } keys %$update_loc_rules; #We can only move to one location so we flatten the arrays
1990
    map { $update_loc_rules->{$_} = $update_loc_rules->{$_}[0] } keys %$update_loc_rules; #We can only move to one location so we flatten the arrays
1991
    if ($update_loc_rules) {
1991
    if ($update_loc_rules) {
1992
        if (defined $update_loc_rules->{_ALL_}) {
1992
        if (defined $update_loc_rules->{_ALL_}) {
(-)a/Koha/Config/SysPref.pm (-1 / +3 lines)
Lines 47-53 sub get_yaml_pref_hash { Link Here
47
    my ( $self ) = @_;
47
    my ( $self ) = @_;
48
    return if !defined( $self );
48
    return if !defined( $self );
49
49
50
    my @lines = split /\n/, $self->value//'';
50
    # We want to use C4::Context->preference in any cases
51
    # It's cached, and mock_preference still works from tests
52
    my @lines = split /\n/, C4::Context->preference($self->variable) // '';
51
    my $pref_as_hash;
53
    my $pref_as_hash;
52
    foreach my $line (@lines){
54
    foreach my $line (@lines){
53
        my ($field,$array) = split /:/, $line;
55
        my ($field,$array) = split /:/, $line;
(-)a/Koha/Util/SystemPreferences.pm (-70 lines)
Lines 1-69 Link Here
1
package Koha::Util::SystemPreferences;
2
3
# Copyright 2018 Koha Development Team
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use parent qw( Exporter );
23
24
our @EXPORT = qw(
25
  get_yaml_pref_hash
26
);
27
28
=head1 NAME
29
30
Koha::Util::SystemPreferences - utility class with System Preference routines
31
32
=head1 METHODS
33
34
=head2 get_yaml_pref_hash
35
36
Turn a pref defined via YAML as a hash
37
38
=cut
39
40
sub get_yaml_pref_hash {
41
    my ( $pref ) = @_;
42
    return if !defined( $pref );
43
44
    my @lines = split /\n/, C4::Context->preference($pref)//'';
45
    my $pref_as_hash;
46
    foreach my $line (@lines){
47
        my ($field,$array) = split /:/, $line;
48
        next if !$array;
49
        $field =~ s/^\s*|\s*$//g;
50
        $array =~ s/[ [\]\r]//g;
51
        my @array = split /,/, $array;
52
        @array = map { $_ eq '""' || $_ eq "''" ? '' : $_ } @array;
53
        @array = map { $_ eq 'NULL' ? undef : $_ } @array;
54
        $pref_as_hash->{$field} = \@array;
55
    }
56
57
    return $pref_as_hash;
58
}
59
60
1;
61
__END__
62
63
=head1 AUTHOR
64
65
Koha Development Team <http://koha-community.org/>
66
67
Nick Clemens <nick@bywatersolutions.com>
68
69
=cut
70
- 

Return to bug 27154