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

(-)a/C4/Context.pm (+13 lines)
Lines 559-564 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
562
=head2 Zconn
575
=head2 Zconn
563
576
564
  $Zconn = C4::Context->Zconn
577
  $Zconn = C4::Context->Zconn
(-)a/Koha/Config/SysPref.pm (+16 lines)
Lines 67-72 sub delete { Link Here
67
    return $deleted;
67
    return $deleted;
68
}
68
}
69
69
70
=head3 select_systempreferences
71
my $row = Koha::Config::SysPrefs->find($name);
72
73
This subroutine retrieves systempreference records with a specific variable value
74
=cut
75
76
sub select_systempreferences {
77
    my ($self, $name) = @_;
78
    my $schema = Koha::Database->new()->schema();
79
    my $syspref = $schema->resultset('Systempreference')->search(
80
            {variable => $name}
81
    );
82
    return $syspref;
83
84
}
85
70
=head3 type
86
=head3 type
71
87
72
=cut
88
=cut
(-)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 = $dbh->selectrow_hashref( "SELECT value, type FROM systempreferences WHERE variable = ?", {}, $name );
161
                        my $row = C4::Context->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/Context.t (-1 lines)
Lines 7-13 use Test::More; Link Here
7
use Test::MockModule;
7
use Test::MockModule;
8
use vars qw($debug $koha $dbh $config $ret);
8
use vars qw($debug $koha $dbh $config $ret);
9
use t::lib::Mocks;
9
use t::lib::Mocks;
10
11
use Koha::Database;
10
use Koha::Database;
12
11
13
BEGIN {
12
BEGIN {
(-)a/t/db_dependent/sysprefs.t (-2 / +16 lines)
Lines 19-26 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 => 8;
22
use Test::More tests => 9;
23
use C4::Context;
23
use C4::Context;
24
use Koha::Database;
24
25
25
# Start transaction
26
# Start transaction
26
my $dbh = C4::Context->dbh;
27
my $dbh = C4::Context->dbh;
Lines 60-63 is(C4::Context->preference('testpreference'), 'def', 'caching preferences'); Link Here
60
C4::Context->clear_syspref_cache();
61
C4::Context->clear_syspref_cache();
61
is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');
62
is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');
62
63
64
sub select_systempreferences {
65
   my ($name) = @_;
66
   my $schema = Koha::Database->new()->schema();
67
   my $syspref = $schema->resultset('Systempreference')->search(
68
            {variable => $name}
69
   );
70
   return $syspref;
71
}
72
73
74
my $syspref = select_systempreferences('OPACHEADER');
75
is( $syspref, 1, 'correct number of syspref found');
76
77
63
$dbh->rollback;
78
$dbh->rollback;
64
- 

Return to bug 18291