} # else there is no browser to send fatals to!
}
-use Encode;
-use ZOOM;
-use Koha::Caches;
-use POSIX ();
+use Carp;
use DateTime::TimeZone;
+use Encode;
+use File::Spec;
use Module::Load::Conditional qw(can_load);
-use Carp;
+use POSIX ();
+use ZOOM;
use C4::Boolean;
use C4::Debug;
-use Koha;
-use Koha::Config;
+use Koha::Caches;
use Koha::Config::SysPref;
use Koha::Config::SysPrefs;
+use Koha::Config;
+use Koha;
=head1 NAME
sub set_preference {
my ( $self, $variable, $value, $explanation, $type, $options ) = @_;
+ my $variable_case = $variable;
$variable = lc $variable;
my $syspref = Koha::Config::SysPrefs->find($variable);
)->store;
} else {
$syspref = Koha::Config::SysPref->new(
- { variable => $variable,
+ { variable => $variable_case,
value => $value,
explanation => $explanation || undef,
type => $type,
return %versions;
}
+=head2 timezone
+
+ my $C4::Context->timzone
+
+ Returns a timezone code for the instance of Koha
+
+=cut
+
+sub timezone {
+ my $self = shift;
+
+ my $timezone = C4::Context->config('timezone') || $ENV{TZ} || 'local';
+ if ( !DateTime::TimeZone->is_valid_name( $timezone ) ) {
+ warn "Invalid timezone in koha-conf.xml ($timezone)";
+ $timezone = 'local';
+ }
+
+ return $timezone;
+}
=head2 tz
sub tz {
my $self = shift;
if (!defined $context->{tz}) {
- $context->{tz} = DateTime::TimeZone->new(name => 'local');
+ my $timezone = $self->timezone;
+ $context->{tz} = DateTime::TimeZone->new(name => $timezone);
}
return $context->{tz};
}
&& C4::Context->userenv->{branch};
}
+=head3 temporary_directory
+
+Returns root directory for temporary storage
+
+=cut
+
+sub temporary_directory {
+ my ( $class ) = @_;
+ return C4::Context->config('tmp_path') || File::Spec->tmpdir;
+}
+
+
1;
__END__