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

(-)a/Koha/Config/SysPref.pm (-13 lines)
Lines 67-85 sub delete { Link Here
67
    return $deleted;
67
    return $deleted;
68
}
68
}
69
69
70
=head3 select_systempreferences
71
my $row = Koha::Config::SysPref->select_systempreferences($name);
72
73
This subroutine retrieves the value and type values for systempreference records with a specific variable value
74
=cut
75
76
sub select_systempreferences {
77
    my ($self, $name) = @_;
78
    my $dbh = C4::Context->dbh;
79
    my $row = $dbh->selectrow_hashref( "SELECT value, type FROM systempreferences WHERE variable = ?", {}, $name );
80
    return $row;
81
}
82
83
=head3 type
70
=head3 type
84
71
85
=cut
72
=cut
(-)a/admin/preferences.pl (-3 / +3 lines)
Lines 158-169 sub TransformPrefsToHTML { Link Here
158
                    my $name = $piece->{'pref'};
158
                    my $name = $piece->{'pref'};
159
159
160
                    if ( $name ) {
160
                    if ( $name ) {
161
                        my $row = Koha::Config::SysPref->select_systempreferences($name);
161
                        my $row = C4::Context->preference($name);
162
                        my $value;
162
                        my $value;
163
                        if ( ( !defined( $row ) || ( !defined( $row->{'value'} ) && $row->{'type'} ne 'YesNo' ) ) && defined( $piece->{'default'} ) ) {
163
                        if ( ( !defined( $row ) || ( !defined( $piece->{'value'} ) && $piece->{'type'} ne 'YesNo' ) ) && defined( $piece->{'default'} ) ) {
164
                            $value = $piece->{'default'};
164
                            $value = $piece->{'default'};
165
                        } else {
165
                        } else {
166
                            $value = $row->{'value'};
166
                            $value = $piece->{'value'};
167
                        }
167
                        }
168
                        my $chunk = _get_chunk( $value, %$piece );
168
                        my $chunk = _get_chunk( $value, %$piece );
169
169
(-)a/t/db_dependent/sysprefs.t (-13 / +1 lines)
Lines 19-25 Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 9;
22
use Test::More tests => 8;
23
use C4::Context;
23
use C4::Context;
24
use Koha::Database;
24
use Koha::Database;
25
25
Lines 61-75 is(C4::Context->preference('testpreference'), 'def', 'caching preferences'); Link Here
61
C4::Context->clear_syspref_cache();
61
C4::Context->clear_syspref_cache();
62
is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');
62
is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');
63
63
64
sub select_systempreferences {
65
   my ($name) = @_;
66
   my $dbh = C4::Context->dbh;
67
   my $sth = $dbh->selectrow_hashref( "SELECT value, type FROM systempreferences WHERE variable = ?", {}, $name );
68
   return $sth;
69
}
70
71
my $syspref = select_systempreferences('OPACHEADER');
72
is( $syspref->{'type'}, "Textarea", 'correct number of syspref found');
73
74
75
$dbh->rollback;
64
$dbh->rollback;
76
- 

Return to bug 18291