Lines 368-373
sub new {
Link Here
|
368 |
$self->{"activeuser"} = undef; # current active user |
368 |
$self->{"activeuser"} = undef; # current active user |
369 |
$self->{"shelves"} = undef; |
369 |
$self->{"shelves"} = undef; |
370 |
$self->{tz} = undef; # local timezone object |
370 |
$self->{tz} = undef; # local timezone object |
|
|
371 |
$self->{sysprefs} = {}; |
371 |
|
372 |
|
372 |
bless $self, $class; |
373 |
bless $self, $class; |
373 |
$self->{db_driver} = db_scheme2dbi($self->config('db_scheme')); # cache database driver |
374 |
$self->{db_driver} = db_scheme2dbi($self->config('db_scheme')); # cache database driver |
Lines 505-533
with this method.
Link Here
|
505 |
# FIXME: running this under mod_perl will require a means of |
506 |
# FIXME: running this under mod_perl will require a means of |
506 |
# flushing the caching mechanism. |
507 |
# flushing the caching mechanism. |
507 |
|
508 |
|
508 |
my %sysprefs; |
|
|
509 |
my $use_syspref_cache = 1; |
509 |
my $use_syspref_cache = 1; |
510 |
|
510 |
|
511 |
sub preference { |
511 |
sub preference { |
512 |
my $self = shift; |
512 |
my $self = shift; |
513 |
my $var = shift; # The system preference to return |
513 |
my $var = shift; # The system preference to return |
|
|
514 |
my $lc_var = lc $var; |
514 |
|
515 |
|
515 |
if ($use_syspref_cache && exists $sysprefs{lc $var}) { |
516 |
$self = $context unless ref $self; |
516 |
return $sysprefs{lc $var}; |
517 |
|
517 |
} |
518 |
return $self->{sysprefs}{$lc_var} if $use_syspref_cache && $self && exists $self->{sysprefs}{$lc_var}; |
518 |
|
519 |
|
519 |
my $dbh = C4::Context->dbh or return 0; |
520 |
my $dbh = C4::Context->dbh or return 0; |
520 |
|
521 |
|
521 |
my $value; |
522 |
my $value; |
522 |
if ( defined $ENV{"OVERRIDE_SYSPREF_$var"} ) { |
523 |
if ( defined $ENV{"OVERRIDE_SYSPREF_$var"} ) { |
523 |
$value = $ENV{"OVERRIDE_SYSPREF_$var"}; |
524 |
$value = $ENV{"OVERRIDE_SYSPREF_$var"}; |
524 |
} else { |
525 |
} elsif ( my $syspref = Koha::Config::SysPrefs->find( $lc_var ) ) { |
525 |
my $syspref; |
526 |
$value = $syspref->value(); |
526 |
eval { $syspref = Koha::Config::SysPrefs->find( lc $var ) }; |
|
|
527 |
$value = $syspref ? $syspref->value() : undef; |
528 |
} |
527 |
} |
529 |
|
528 |
|
530 |
$sysprefs{lc $var} = $value; |
529 |
$self->{sysprefs}{$lc_var} = $value if $use_syspref_cache && $self; |
531 |
return $value; |
530 |
return $value; |
532 |
} |
531 |
} |
533 |
|
532 |
|
Lines 578-584
will not be seen by this process.
Link Here
|
578 |
=cut |
577 |
=cut |
579 |
|
578 |
|
580 |
sub clear_syspref_cache { |
579 |
sub clear_syspref_cache { |
581 |
%sysprefs = (); |
580 |
my ($self) = @_; |
|
|
581 |
|
582 |
$self = $context unless ref $self; |
583 |
|
584 |
$self->{sysprefs} = {} if $self; |
582 |
} |
585 |
} |
583 |
|
586 |
|
584 |
=head2 set_preference |
587 |
=head2 set_preference |
Lines 595-600
sub set_preference {
Link Here
|
595 |
my $var = lc(shift); |
598 |
my $var = lc(shift); |
596 |
my $value = shift; |
599 |
my $value = shift; |
597 |
|
600 |
|
|
|
601 |
$self = $context unless ref $self; |
602 |
|
598 |
my $syspref = Koha::Config::SysPrefs->find( $var ); |
603 |
my $syspref = Koha::Config::SysPrefs->find( $var ); |
599 |
my $type = $syspref ? $syspref->type() : undef; |
604 |
my $type = $syspref ? $syspref->type() : undef; |
600 |
|
605 |
|
Lines 612-620
sub set_preference {
Link Here
|
612 |
$syspref = Koha::Config::SysPref->new( { variable => $var, value => $value } )->store(); |
617 |
$syspref = Koha::Config::SysPref->new( { variable => $var, value => $value } )->store(); |
613 |
} |
618 |
} |
614 |
|
619 |
|
615 |
if ($syspref) { |
620 |
$self->{sysprefs}{$var} = $value if $use_syspref_cache && $self; |
616 |
$sysprefs{$var} = $value; |
|
|
617 |
} |
618 |
} |
621 |
} |
619 |
|
622 |
|
620 |
=head2 Zconn |
623 |
=head2 Zconn |