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

(-)a/misc/admin/koha-preferences (-9 / +16 lines)
Lines 60-73 sub _set_preference { Link Here
60
60
61
    _debug( "Setting $preference to $value" );
61
    _debug( "Setting $preference to $value" );
62
62
63
    C4::Context->set_preference( $preference, $value );
63
    if (   $preference->{type} eq 'YesNo'
64
        && $value ne '0'
65
        && $value ne '1' )
66
    {
67
        print STDERR sprintf "System preference %s is YesNo and expects 1 or 0. '%s' was given, using '0'\n",
68
          $preference->{variable}, $value;
69
        $value = 0;
70
    }
71
72
    C4::Context->set_preference( $preference->{variable}, $value );
64
}
73
}
65
74
66
sub GetPreferences {
75
sub GetPreferences {
67
    my $dbh = C4::Context->dbh;
76
    my $dbh = C4::Context->dbh;
68
77
69
    return {
78
    return {
70
        map { $_->{'variable'},  $_ }
79
        map { $_->{variable},  $_->{value} }
71
        @{ $dbh->selectall_arrayref( "
80
        @{ $dbh->selectall_arrayref( "
72
            SELECT
81
            SELECT
73
              variable, value, type
82
              variable, value, type
Lines 91-102 sub SetPreferences { Link Here
91
100
92
    exit 2 if ( scalar( @$current_state ) != scalar( keys %preferences ) );
101
    exit 2 if ( scalar( @$current_state ) != scalar( keys %preferences ) );
93
102
94
    # Iterate through again, now that we've checked all of the YesNo sysprefs
95
96
    foreach my $row ( @$current_state ) {
103
    foreach my $row ( @$current_state ) {
97
        next if ( $preferences{$row->{'variable'}} eq $row->{'value'} );
104
        my $new_value = $preferences{ $row->{variable} };
105
        next if $new_value && $row->{value} && $new_value eq $row->{value};
98
106
99
        _set_preference( $row->{'variable'}, $preferences{$row->{'variable'}} );
107
        _set_preference( $row, $new_value );
100
    }
108
    }
101
109
102
    # FIXME This may be not needed
110
    # FIXME This may be not needed
Lines 134-140 sub SetPreference { Link Here
134
142
135
    exit 3 if ( $value eq $row->{'value'} ); #FIXME exit??
143
    exit 3 if ( $value eq $row->{'value'} ); #FIXME exit??
136
144
137
    _set_preference( $preference, $value );
145
    _set_preference( $row, $value );
138
}
146
}
139
147
140
sub ClearPreference {
148
sub ClearPreference {
Lines 148-154 sub ClearPreference { Link Here
148
156
149
    exit 3 if ( $value eq $row->{'value'} );
157
    exit 3 if ( $value eq $row->{'value'} );
150
158
151
    _set_preference( $preference, $value );
159
    _set_preference( $row, $value );
152
}
160
}
153
161
154
=head1 OPTIONS
162
=head1 OPTIONS
155
- 

Return to bug 22824