sub _send_email {
my ($posted_invoices, $printed_invoices) = @_;
- read_config 'config/lx_office.conf' => my %config;
+ my %config = %::lx_office_conf;
return if !$config{periodic_invoices} || !$config{periodic_invoices}->{send_email_to} || !scalar @{ $posted_invoices };
use English qw(-no_match_vars);
use SL::Auth;
use SL::LXDebug;
+use SL::LxOfficeConf;
use SL::Locale;
use SL::Common;
use SL::Helper::DateTime;
}
sub pre_startup_setup {
- read_config 'config/lx_office.conf' => %::lx_office_conf;
- _decode_recursively(\%::lx_office_conf);
+ SL::LxOfficeConf->read;
_init_environment();
eval {
return $self->{interface} =~ m/f(?:ast)cgi/i ? $self->{request}->GetHandles() : (\*STDIN, \*STDOUT, \*STDERR);
}
-sub _decode_recursively {
- my ($obj) = @_;
-
- while (my ($key, $value) = each %{ $obj }) {
- if (ref($value) eq 'HASH') {
- _decode_recursively($value);
- } else {
- $obj->{$key} = decode('UTF-8', $value);
- }
- }
-}
-
sub _init_environment {
my %key_map = ( lib => { name => 'PERL5LIB', append_path => 1 },
path => { name => 'PATH', append_path => 1 },
--- /dev/null
+package SL::LxOfficeConf;
+
+use strict;
+
+use Config::Std;
+use Encode;
+
+sub read {
+ my $file = -f 'config/lx_office.conf' ? 'config/lx_office.conf' : 'config/lx_office.conf.default';
+ read_config $file => %::lx_office_conf;
+ _decode_recursively(\%::lx_office_conf);
+}
+
+sub _decode_recursively {
+ my ($obj) = @_;
+
+ while (my ($key, $value) = each %{ $obj }) {
+ if (ref($value) eq 'HASH') {
+ _decode_recursively($value);
+ } else {
+ $obj->{$key} = decode('UTF-8', $value);
+ }
+ }
+}
+
+1;
# The template file used for the email's body.
email_template = templates/webpages/oe/periodic_invoices_email.txt
-[Console]
+[console]
# autologin to use if none is given
login = mb
push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
}
-use Config::Std;
use Data::Dumper;
use Devel::REPL 1.002001;
use Term::ReadLine::Perl::Bind; # use sane key binding for rxvt users
-read_config 'config/lx_office.conf' => my %config;
+use SL::LxOfficeConf;
+SL::LxOfficeConf->read;
-my $login = shift || $config{Console}{login} || 'demo';
-my $history_file = $config{Console}{history_file} || '/tmp/lxoffice_console_history.log'; # fallback if users is not writable
-my $autorun = $config{Console}{autorun};
+my $login = shift || $::lx_office_conf{console}{login} || 'demo';
+my $history_file = $::lx_office_conf{console}{history_file} || '/tmp/lxoffice_console_history.log'; # fallback if users is not writable
+my $autorun = $::lx_office_conf{console}{autorun};
# will be configed eventually
my @plugins = qw(History LexEnv Colors MultiLine::PPI FancyPrompt PermanentHistory AutoloadModules);
use CGI qw( -no_xhtml);
use DateTime;
use SL::Auth;
-use SL::Dispatcher;
use SL::Form;
use SL::Helper::DateTime;
use SL::Locale;
package main;
- read_config 'config/lx_office.conf' => %::lx_office_conf;
- SL::Dispatcher::_decode_recursively(\%::lx_office_conf);
-
$::lxdebug = LXDebug->new;
$::locale = Locale->new($::lx_office_conf{system}->{language});
$::cgi = CGI->new qw();
use Text::Iconv;
use SL::LXDebug;
+use SL::LxOfficeConf;
-read_config "config/lx_office.conf" => our %lx_office_conf;
+SL::LxOfficeConf->read;
our $lxdebug = LXDebug->new();
use SL::Auth;
use SL::Form;
use SL::Locale;
use SL::LXDebug;
+use SL::LxOfficeConf;
use SL::DB::Helper::ALL;
use SL::DB::Helper::Mappings;
exit 1;
}
- read_config "config/lx_office.conf" => %lx_office_conf;
+ SL::LxOfficeConf->read;
my $login = shift @ARGV;
}
use CGI qw( -no_xhtml);
-use Config::Std;
use Cwd;
use Daemon::Generic;
use Data::Dumper;
use SL::Form;
use SL::Helper::DateTime;
use SL::LXDebug;
+use SL::LxOfficeConf;
use SL::Locale;
our %lx_office_conf;
sub gd_preconfig {
my $self = shift;
- read_config $self->{configfile} => %lx_office_conf;
+ SL::LxOfficeConf->read;
die "Missing section [task_server] in config file" unless $lx_office_conf{task_server};
die "Missing key 'login' in section [task_server] in config file" unless $lx_office_conf{task_server}->{login};
mkdir($pidbase) if !-d $pidbase;
-newdaemon(configfile => "${cwd}/config/lx_office.conf",
+my $file = -f "${cwd}/config/lx_office.conf" ? "${cwd}/config/lx_office.conf" : "${cwd}/config/lx_office.conf.default";
+newdaemon(configfile => $file,
progname => 'lx-office-task-server',
pidbase => "${pidbase}/",
);