|
Lines 101-113
use DBIx::Connector;
Link Here
|
| 101 |
use Encode; |
101 |
use Encode; |
| 102 |
use ZOOM; |
102 |
use ZOOM; |
| 103 |
use XML::Simple; |
103 |
use XML::Simple; |
| 104 |
use C4::Boolean; |
|
|
| 105 |
use C4::Debug; |
| 106 |
use POSIX (); |
104 |
use POSIX (); |
| 107 |
use DateTime::TimeZone; |
105 |
use DateTime::TimeZone; |
| 108 |
use Module::Load::Conditional qw(can_load); |
106 |
use Module::Load::Conditional qw(can_load); |
| 109 |
use Carp; |
107 |
use Carp; |
| 110 |
|
108 |
|
|
|
109 |
use C4::Boolean; |
| 110 |
use C4::Debug; |
| 111 |
use Koha::SysPrefs; |
| 112 |
|
| 111 |
=head1 NAME |
113 |
=head1 NAME |
| 112 |
|
114 |
|
| 113 |
C4::Context - Maintain and manipulate the context of a Koha script |
115 |
C4::Context - Maintain and manipulate the context of a Koha script |
|
Lines 554-567
sub preference {
Link Here
|
| 554 |
if ( defined $ENV{"OVERRIDE_SYSPREF_$var"} ) { |
556 |
if ( defined $ENV{"OVERRIDE_SYSPREF_$var"} ) { |
| 555 |
$value = $ENV{"OVERRIDE_SYSPREF_$var"}; |
557 |
$value = $ENV{"OVERRIDE_SYSPREF_$var"}; |
| 556 |
} else { |
558 |
} else { |
| 557 |
# Look up systempreferences.variable==$var |
559 |
my $syspref = Koha::SysPrefs->find( lc $var ); |
| 558 |
my $sql = q{ |
560 |
$value = $syspref ? $syspref->value() : undef; |
| 559 |
SELECT value |
|
|
| 560 |
FROM systempreferences |
| 561 |
WHERE variable = ? |
| 562 |
LIMIT 1 |
| 563 |
}; |
| 564 |
$value = $dbh->selectrow_array( $sql, {}, lc $var ); |
| 565 |
} |
561 |
} |
| 566 |
|
562 |
|
| 567 |
$sysprefs{lc $var} = $value; |
563 |
$sysprefs{lc $var} = $value; |
|
Lines 632-654
sub set_preference {
Link Here
|
| 632 |
my $var = lc(shift); |
628 |
my $var = lc(shift); |
| 633 |
my $value = shift; |
629 |
my $value = shift; |
| 634 |
|
630 |
|
| 635 |
my $dbh = C4::Context->dbh or return 0; |
631 |
my $syspref = Koha::SysPrefs->find( $var ); |
| 636 |
|
632 |
my $type = $syspref ? $syspref->type() : undef; |
| 637 |
my $type = $dbh->selectrow_array( "SELECT type FROM systempreferences WHERE variable = ?", {}, $var ); |
|
|
| 638 |
|
633 |
|
| 639 |
$value = 0 if ( $type && $type eq 'YesNo' && $value eq '' ); |
634 |
$value = 0 if ( $type && $type eq 'YesNo' && $value eq '' ); |
| 640 |
|
635 |
|
| 641 |
my $sth = $dbh->prepare( " |
636 |
if ($syspref) { |
| 642 |
INSERT INTO systempreferences |
637 |
$syspref = $syspref->set( { value => $value } )->store(); |
| 643 |
( variable, value ) |
638 |
} |
| 644 |
VALUES( ?, ? ) |
639 |
else { |
| 645 |
ON DUPLICATE KEY UPDATE value = VALUES(value) |
640 |
$syspref = Koha::Syspref->new( { variable => $var, value => $value } )->store(); |
| 646 |
" ); |
641 |
} |
| 647 |
|
642 |
|
| 648 |
if($sth->execute( $var, $value )) { |
643 |
if ($syspref) { |
| 649 |
$sysprefs{$var} = $value; |
644 |
$sysprefs{$var} = $value; |
| 650 |
} |
645 |
} |
| 651 |
$sth->finish; |
|
|
| 652 |
} |
646 |
} |
| 653 |
|
647 |
|
| 654 |
# AUTOLOAD |
648 |
# AUTOLOAD |