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

(-)a/C4/Context.pm (-13 lines)
Lines 559-577 sub delete_preference { Link Here
559
    return 0;
559
    return 0;
560
}
560
}
561
561
562
=head2 select_systempreferences
563
my $row = C4::Context->select_systempreferences($name);
564
565
This subroutine retrieves and returns the value and type of systempreference records matching the variable value $name
566
=cut
567
568
sub select_systempreferences {
569
    my ($self, $name) = @_;
570
    my $row = Koha::Config::SysPrefs->find($name);
571
    return $row;
572
}
573
574
575
=head2 Zconn
562
=head2 Zconn
576
563
577
  $Zconn = C4::Context->Zconn
564
  $Zconn = C4::Context->Zconn
(-)a/Koha/Config/SysPref.pm (-8 / +5 lines)
Lines 68-86 sub delete { Link Here
68
}
68
}
69
69
70
=head3 select_systempreferences
70
=head3 select_systempreferences
71
my $row = Koha::Config::SysPrefs->find($name);
71
my $row = Koha::Config::SysPref->select_systempreferences($name);
72
72
73
This subroutine retrieves systempreference records with a specific variable value
73
This subroutine retrieves the value and type values for systempreference records with a specific variable value
74
=cut
74
=cut
75
75
76
sub select_systempreferences {
76
sub select_systempreferences {
77
    my ($self, $name) = @_;
77
    my ($self, $name) = @_;
78
    my $schema = Koha::Database->new()->schema();
78
    my $dbh = C4::Context->dbh;
79
    my $syspref = $schema->resultset('Systempreference')->search(
79
    my $row = $dbh->selectrow_hashref( "SELECT value, type FROM systempreferences WHERE variable = ?", {}, $name );
80
            {variable => $name}
80
    return $row;
81
    );
82
    return $syspref;
83
84
}
81
}
85
82
86
=head3 type
83
=head3 type
(-)a/admin/preferences.pl (-1 / +1 lines)
Lines 158-164 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 = C4::Context->select_systempreferences($name);
161
                        my $row = Koha::Config::SysPref->select_systempreferences($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( $row->{'value'} ) && $row->{'type'} ne 'YesNo' ) ) && defined( $piece->{'default'} ) ) {
164
                            $value = $piece->{'default'};
164
                            $value = $piece->{'default'};
(-)a/t/db_dependent/sysprefs.t (-8 / +4 lines)
Lines 63-78 is(C4::Context->preference('testpreference'), undef, 'clearing preference cache' Link Here
63
63
64
sub select_systempreferences {
64
sub select_systempreferences {
65
   my ($name) = @_;
65
   my ($name) = @_;
66
   my $schema = Koha::Database->new()->schema();
66
   my $dbh = C4::Context->dbh;
67
   my $syspref = $schema->resultset('Systempreference')->search(
67
   my $sth = $dbh->selectrow_hashref( "SELECT value, type FROM systempreferences WHERE variable = ?", {}, $name );
68
            {variable => $name}
68
   return $sth;
69
   );
70
   return $syspref;
71
}
69
}
72
70
73
74
my $syspref = select_systempreferences('OPACHEADER');
71
my $syspref = select_systempreferences('OPACHEADER');
75
is( $syspref, 1, 'correct number of syspref found');
72
is( $syspref->{'type'}, "Textarea", 'correct number of syspref found');
76
73
77
74
78
$dbh->rollback;
75
$dbh->rollback;
79
- 

Return to bug 18291