1#  This is the new configuration file for LedgerSMB.  Eventually all system
2# configuration directives will go here,  This will probably not fully replace
3# the ledgersmb.conf until 1.3, however.
4
5package LedgerSMB::Sysconfig;
6
7use LedgerSMB::Form;
8use Config::Std;
9use DBI qw(:sql_types);
10
11binmode STDOUT, ':utf8';
12
13# For Win32, change $pathsep to ';';
14$pathsep = ':';
15
16$session = 'DB';
17$logging = 0;      # No logging on by default
18$max_post_size = 1024 * 1024; # Default to 1MB
19@io_lineitem_columns = qw(unit onhand sellprice discount linetotal);
20
21# Whitelist for redirect destination
22@scripts = (
23    'aa.pl', 'admin.pl', 'am.pl',      'ap.pl',
24    'ar.pl', 'arap.pl',  'arapprn.pl', 'bp.pl',
25    'ca.pl', 'cp.pl',    'ct.pl',      'gl.pl',
26    'hr.pl', 'ic.pl',    'io.pl',      'ir.pl',
27    'is.pl', 'jc.pl',    'login.pl',   'menu.pl',
28    'oe.pl', 'pe.pl',    'pos.pl',     'ps.pl',
29    'pw.pl', 'rc.pl',    'rp.pl'
30);
31
32# if you have latex installed set to 1
33$latex = 1;
34
35# spool directory for batch printing
36$spool = "spool";
37
38# path to user configuration files
39$userspath = "users";
40
41# templates base directory
42$templates = "templates";
43
44# Temporary files stored at"
45$tempdir = ( $ENV{TEMP} || '/tmp' );
46
47# Backup path
48$backuppath = $tempdir;
49
50# member file
51$memberfile = "users/members";
52
53# location of sendmail
54$sendmail = "/usr/sbin/sendmail -t";
55
56# SMTP settings
57$smtphost   = '';
58$smtptimout = 60;
59
60# set language for login and admin
61$language = "";
62
63# Maximum number of invoices that can be printed on a check
64$check_max_invoices = 5;
65
66# program to use for file compression
67$gzip = "gzip -S .gz";
68
69# Path to the translation files
70$localepath = 'locale/po';
71
72# available printers
73%printer = (
74    Laser => 'lpr -Plaser',
75    Epson => 'lpr -PEpson',
76);
77
78my %config;
79read_config( 'ledgersmb.conf' => %config ) or die;
80
81# We should clean this code up for 1.3 :-) Chris T.
82
83$logging = $config{''}{logging} if $config{''}{logging};
84$check_max_invoices = $config{''}{check_max_invoices}
85  if $config{''}{check_max_invoices};
86$language = $config{''}{language} if $config{''}{language};
87$session  = $config{''}{session}  if $config{''}{session};
88$latex    = $config{''}{latex}    if $config{''}{latex};
89
90if (ref $config{environment}{PATH} eq 'ARRAY') {
91    $ENV{PATH} .= $pathsep . ( join $pathsep, @{ $config{environment}{PATH} } );
92} elsif ($config{environment}{PATH}) {
93    $ENV{PATH} .= $pathsep . $config{environment}{PATH};
94}
95if (ref $config{environment}{PERL5LIB} eq 'ARRAY') {
96    $ENV{PERL5LIB} .= ":" . ( join ':', @{ $config{environment}{PERL5LIB} } );
97} elsif ($config{environment}{PERL5LIB}) {
98    $ENV{PERL5LIB} .= ":" . $config{environment}{PERL5LIB};
99}
100
101%printer = %{ $config{printers} } if $config{printers};
102
103$localepath = $config{paths}{localepath} if $config{paths}{localepath};
104$spool      = $config{paths}{spool}      if $config{paths}{spool};
105$templates  = $config{paths}{templates}  if $config{paths}{templates};
106$tempdir    = $config{paths}{tempdir}    if $config{paths}{tempdir};
107$userspath =
108  ( $config{paths}{userspath} ) ? $config{paths}{userspath} : $tempdir;
109$gzip = $config{programs}{gzip} if $config{programs}{gzip};
110
111$sendmail    = $config{mail}{sendmail}    if $config{mail}{sendmail};
112$smtphost    = $config{mail}{smtphost}    if $config{mail}{smtphost};
113$smtptimeout = $config{mail}{smtptimeout} if $config{mail}{smtptimeout};
114
115# We used to have a global dbconnect but have moved to single entries
116$globalDBhost = $config{globaldb}{DBhost} if $config{globaldb}{DBhost};
117$globalDBport = $config{globaldb}{DBport} if $config{globaldb}{DBport};
118$globalDBname = $config{globaldb}{DBname} if $config{globaldb}{DBname};
119$globalDBUserName = $config{globaldb}{DBUserName}
120  if $config{globaldb}{DBUserName};
121$globalDBPassword = $config{globaldb}{DBPassword}
122  if $config{globaldb}{DBPassword};
123
124#putting this in an if clause for now so not to break other devel users
125if ( $config{globaldb}{DBname} ) {
126    my $dbconnect = "dbi:Pg:dbname=$globalDBname host=$globalDBhost
127		port=$globalDBport user=$globalDBUserName
128		password=$globalDBPassword";    # for easier debugging
129    $GLOBALDBH = DBI->connect($dbconnect);
130    if ( !$GLOBALDBH ) {
131        $form = new Form;
132        $form->error("No GlobalDBH Configured or Could not Connect");
133    }
134    $GLOBALDBH->{pg_enable_utf8} = 1;
135}
136
137# These lines prevent other apps in mod_perl from seeing the global db
138# connection info
139
140my $globalDBConnect = undef;
141my $globalUserName  = undef;
142my $globalPassword  = undef;
143
1441;
145