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