$myconfig->{$item} = $form->{$item};
}
- $myconfig->save_member($main::memberfile);
+ $myconfig->save_member;
my $auth = $main::auth;
sub delete_transaction {
$main::lxdebug->enter_sub();
- my ($self, $myconfig, $form, $spool) = @_;
+ my ($self, $myconfig, $form) = @_;
# connect to database
my $dbh = $form->dbconnect_noauto($myconfig);
sub delete_spool {
$main::lxdebug->enter_sub();
- my ($self, $myconfig, $form, $spool) = @_;
+ my ($self, $myconfig, $form) = @_;
+
+ my $spool = $::lx_office_conf{paths}->{spool};
# connect to database, turn AutoCommit off
my $dbh = $form->dbconnect_noauto($myconfig);
sub print_spool {
$main::lxdebug->enter_sub();
- my ($self, $myconfig, $form, $spool, $output) = @_;
+ my ($self, $myconfig, $form, $output) = @_;
+
+ my $spool = $::lx_office_conf{paths}->{spool};
# connect to database
my $dbh = $form->dbconnect($myconfig);
$form->throw_on_error(sub {
eval {
- $form->parse_template(\%::myconfig, $::userspath);
+ $form->parse_template(\%::myconfig);
1;
} || die $EVAL_ERROR->{error};
});
delete $form->{OUT};
- $form->parse_template($myconfig, $main::userspath);
+ $form->parse_template($myconfig);
$main::lxdebug->leave_sub();
}
PLUGIN_BASE => 'SL::Template::Plugin',
INCLUDE_PATH => '.:templates/webpages',
COMPILE_EXT => '.tcc',
- COMPILE_DIR => $::userspath . '/templates-cache',
+ COMPILE_DIR => $::lx_office_conf{paths}->{userspath} . '/templates-cache',
}) || croak;
return $self->{__basepriv_template_obj};
my $path;
if ($token =~ m|^(\d+)-(\d+)-(\d+)$|) {
- $path = "${main::userspath}/datev-export-${1}-${2}-${3}";
+ $path = $::lx_office_conf{paths}->{userspath} . "/datev-export-${1}-${2}-${3}";
}
$main::lxdebug->leave_sub();
sub clean_temporary_directories {
$main::lxdebug->enter_sub();
- foreach my $path (glob "${main::userspath}/datev-export-*") {
+ foreach my $path (glob($::lx_office_conf{paths}->{userspath} . "/datev-export-*")) {
next unless (-d $path);
my $mtime = (stat($path))[9];
sub save_dunning {
$main::lxdebug->enter_sub();
- my ($self, $myconfig, $form, $rows, $userspath, $spool) = @_;
+ my ($self, $myconfig, $form, $rows) = @_;
# connect to database
my $dbh = $form->dbconnect_noauto($myconfig);
$copies *= 1;
$copies = 1 unless $copies;
- my $inputfiles = join " ", map { "${main::spool}/$_ " x $copies } @{ $form->{DUNNING_PDFS} };
+ my $spool = $::lx_office_conf{paths}->{spool};
+ my $inputfiles = join " ", map { "$spool/$_ " x $copies } @{ $form->{DUNNING_PDFS} };
my $dunning_id = $form->{dunning_id};
$dunning_id =~ s|[^\d]||g;
$in->close();
- map { unlink("${main::spool}/$_") } @{ $form->{DUNNING_PDFS} };
+ map { unlink("$spool/$_") } @{ $form->{DUNNING_PDFS} };
$main::lxdebug->leave_sub();
}
$self->set_template_options($myconfig, $form);
my $filename = "dunning_${dunning_id}_" . Common::unique_id() . ".pdf";
- $form->{OUT} = ">${main::spool}/$filename";
+ my $spool = $::lx_office_conf{paths}->{spool};
+ $form->{OUT} = ">${spool}/$filename";
$form->{keep_tmpfile} = 1;
delete $form->{tmpfile};
push @{ $form->{DUNNING_PDFS} }, $filename;
- push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'filename' => "${main::spool}/$filename",
+ push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'filename' => "${spool}/$filename",
'name' => "dunning_${dunning_id}.pdf" };
- $form->parse_template($myconfig, $main::userspath);
+ $form->parse_template($myconfig);
$dbh->disconnect() unless $provided_dbh;
my $filename = Common::unique_id() . "dunning_invoice_${dunning_id}.pdf";
- $form->{OUT} = ">$main::spool/$filename";
+ my $spool = $::lx_office_conf{paths}->{spool};
+ $form->{OUT} = ">$spool/$filename";
$form->{keep_tmpfile} = 1;
delete $form->{tmpfile};
map { delete $form->{$_} } grep /^[a-z_]+_\d+$/, keys %{ $form };
- $form->parse_template($myconfig, $main::userspath);
+ $form->parse_template($myconfig);
restore_form($saved_form);
push @{ $form->{DUNNING_PDFS} }, $filename;
- push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'filename' => "${main::spool}/$filename",
+ push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'filename' => "${spool}/$filename",
'name' => "dunning_invoice_${dunning_id}.pdf" };
$dbh->disconnect() unless $provided_dbh;
my $myconfig = \%main::myconfig;
my $form = $main::form;
- my $spool = $main::spool;
+ my $spool = $::lx_office_conf{paths}->{spool};
# connect to database
my $dbh = $form->get_standard_dbh($myconfig);
# canonial globals. if it's not here, chances are it will get refactored someday.
{
no warnings 'once';
- $::userspath = "users";
- $::templates = "templates";
- $::memberfile = "users/members";
$::menufile = "menu.ini";
$::sendmail = "| /usr/sbin/sendmail -t";
$::lxdebug = LXDebug->new;
my $session_result = $::auth->restore_session;
$::auth->create_or_refresh_session;
- $::form->error($::locale->text('System currently down for maintenance!')) if -e "$::userspath/nologin" && $script ne 'admin';
+ $::form->error($::locale->text('System currently down for maintenance!')) if -e ($::lx_office_conf{paths}->{userspath} . "/nologin") && $script ne 'admin';
if ($script eq 'login' or $script eq 'admin' or $script eq 'kopf') {
$::form->{titlebar} = "Lx-Office " . $::locale->text('Version') . " $::form->{version}";
'PLUGIN_BASE' => 'SL::Template::Plugin',
'INCLUDE_PATH' => '.:templates/webpages',
'COMPILE_EXT' => '.tcc',
- 'COMPILE_DIR' => $::userspath . '/templates-cache',
+ 'COMPILE_DIR' => $::lx_office_conf{paths}->{userspath} . '/templates-cache',
})) || die;
}
sub parse_template {
$main::lxdebug->enter_sub();
- my ($self, $myconfig, $userspath) = @_;
+ my ($self, $myconfig) = @_;
my $out;
local (*IN, *OUT);
+ my $userspath = $::lx_office_conf{paths}->{userspath};
+
$self->{"cwd"} = getcwd();
$self->{"tmpdir"} = $self->{cwd} . "/${userspath}";
sub delete_invoice {
$main::lxdebug->enter_sub();
- my ($self, $myconfig, $form, $spool) = @_;
+ my ($self, $myconfig, $form) = @_;
# connect to database
my $dbh = $form->dbconnect_noauto($myconfig);
$dbh->disconnect;
if ($rc) {
+ my $spool = $::lx_office_conf{paths}->{spool};
map { unlink "$spool/$_" if -f "$spool/$_"; } @spoolfiles;
}
# to distinguish case A and B the variable pricegroup_id_$i is used
# for new articles this variable isn't defined, for loaded articles it is
# sellprice can't be used, as it already has 0,00 set
-
+
if ($pkr->{pricegroup_id} eq $form->{"pricegroup_id_$i"} and defined $form->{"pricegroup_id_$i"}) {
# Case A
$pkr->{selected} = ' selected';
- } elsif ($pkr->{pricegroup_id} eq $form->{customer_klass}
- and not defined $form->{"pricegroup_id_$i"}
+ } elsif ($pkr->{pricegroup_id} eq $form->{customer_klass}
+ and not defined $form->{"pricegroup_id_$i"}
and $pkr->{price} != 0 # only use customer pricegroup price if it has a value, else use default_sellprice
# for the case where pricegroup prices haven't been set
) {
sub delete {
$main::lxdebug->enter_sub();
- my ($self, $myconfig, $form, $spool) = @_;
+ my ($self, $myconfig, $form) = @_;
# connect to database
my $dbh = $form->dbconnect_noauto($myconfig);
$dbh->disconnect;
if ($rc) {
+ my $spool = $::lx_office_conf{paths}->{spool};
foreach $spoolfile (@spoolfiles) {
unlink "$spool/$spoolfile" if $spoolfile;
}
my %params = @_;
my $package = "SL::Template::" . $params{type};
- $package->new($params{file_name}, $params{form}, $params{myconfig} || \%::myconfig, $params{userspath} || $::userspath);
+ $package->new($params{file_name}, $params{form}, $params{myconfig} || \%::myconfig, $params{userspath} || $::lx_office_conf{paths}->{userspath});
}
1;
}
# update the tables
- if (!open(FH, ">$main::userspath/nologin")) {
+ if (!open(FH, ">" . $::lx_office_conf{paths}->{userspath} . "/nologin")) {
$form->show_generic_error($main::locale->text('A temporary file could not be created. ' .
'Please verify that the directory "#1" is writeable by the webserver.',
- $main::userspath),
+ $::lx_office_conf{paths}->{userspath}),
'back_button' => 1);
}
close(FH);
# remove lock file
- unlink("$main::userspath/nologin");
+ unlink($::lx_office_conf{paths}->{userspath} . "/nologin");
my $menufile =
$self->{"menustyle"} eq "v3" ? "menuv3.pl" :
::end_of_request();
}
- if (-f $main::memberfile) {
+ my $memberfile = $::lx_office_conf{paths}->{memberfile};
+ if (-f $memberfile) {
my $memberdir = "";
- if ($main::memberfile =~ m|^.*/|) {
+ if ($memberfile =~ m|^.*/|) {
$memberdir = $&;
}
$form->{title} = $locale->text('User data migration');
$form->header();
- print $form->parse_html_template('admin/user_migration', { 'memberfile' => $main::memberfile,
+ print $form->parse_html_template('admin/user_migration', { 'memberfile' => $memberfile,
'backupdir' => $backupdir });
::end_of_request();
$main::auth->set_session_value('rpw', $form->{rpw});
$main::auth->create_or_refresh_session();
- if (!-f $main::memberfile) {
+ my $memberfile = $::lx_office_conf{paths}->{memberfile};
+ if (!-f $memberfile) {
# New installation -- create a standard group with full access
my %members;
my $group = {
my $memberdir = "";
- if ($main::memberfile =~ m|^.*/|) {
+ my $memberfile = $::lx_office_conf{paths}->{memberfile};
+ if ($memberfile =~ m|^.*/|) {
$memberdir = $&;
}
$form->error(sprintf($locale->text('The directory "%s" could not be created:\n%s'), $backupdir, $!));
}
- copy $main::memberfile, "users/member-file-migration/members";
+ copy $memberfile, "users/member-file-migration/members";
- my $in = IO::File->new($main::memberfile, "r");
+ my $in = IO::File->new($memberfile, "r");
$form->error($locale->text('Could not open the old memberfile.')) if (!$in);
}
}
- unlink $main::memberfile;
+ unlink $memberfile;
my @member_list = sort { lc $a->{login} cmp lc $b->{login} } values %members;
map { $_->{templates} =~ s|.*/||; } values %members;
$form->{title} = "Lx-Office ERP " . $locale->text('Administration');
- $form->{LOCKED} = -e "$main::userspath/nologin";
+ $form->{LOCKED} = -e _nologin_file_name();
$form->{MEMBERS} = [ @members{sort { lc $a cmp lc $b } keys %members} ];
$form->header();
}
# is there a templates basedir
- if (!-d "$main::templates") {
- $form->error(sprintf($locale->text("The directory %s does not exist."), $main::templates));
+ if (!-d $::lx_office_conf{paths}->{templates}) {
+ $form->error(sprintf($locale->text("The directory %s does not exist."), $::lx_office_conf{paths}->{templates}));
}
- opendir TEMPLATEDIR, "$main::templates/." or $form->error("$main::templates : $ERRNO");
+ opendir TEMPLATEDIR, $::lx_office_conf{paths}->{templates} or $form->error($::lx_office_conf{paths}->{templates} . " : $ERRNO");
my @all = readdir(TEMPLATEDIR);
- my @alldir = sort grep { -d "$main::templates/$_" && !/^\.\.?$/ } @all;
- my @allhtml = sort grep { -f "$main::templates/$_" && /\.html$/ } @all;
+ my @alldir = sort grep { -d ($::lx_office_conf{paths}->{templates} . "/$_") && !/^\.\.?$/ } @all;
+ my @allhtml = sort grep { -f ($::lx_office_conf{paths}->{templates} . "/$_") && /\.html$/ } @all;
closedir TEMPLATEDIR;
@alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir;
}
# is there a basedir
- if (!-d "$main::templates") {
- $form->error(sprintf($locale->text("The directory %s does not exist."), $main::templates));
+ if (!-d $::lx_office_conf{paths}->{templates}) {
+ $form->error(sprintf($locale->text("The directory %s does not exist."), $::lx_office_conf{paths}->{templates}));
}
# add base directory to $form->{templates}
$form->{templates} =~ s|.*/||;
- $form->{templates} = "$main::templates/$form->{templates}";
+ $form->{templates} = $::lx_office_conf{paths}->{templates} . "/$form->{templates}";
my $myconfig = new User($form->{login});
$myconfig->save_member();
$form->{templates} =~ s|.*/||;
- $form->{templates} = "$main::templates/$form->{templates}";
+ $form->{templates} = $::lx_office_conf{paths}->{templates} . "/$form->{templates}";
$form->{mastertemplates} =~ s|.*/||;
# create user template directory and copy master files
umask(007);
# copy templates to the directory
- opendir TEMPLATEDIR, "$main::templates/." or $form->error("$main::templates : $ERRNO");
+ opendir TEMPLATEDIR, $::lx_office_conf{paths}->{templates} or $form->error($::lx_office_conf{paths}->{templates} . " : $ERRNO");
my @templates = grep /$form->{mastertemplates}.*?\.(html|tex|sty|odt|xml|txb)$/,
readdir TEMPLATEDIR;
closedir TEMPLATEDIR;
foreach my $file (@templates) {
- open(TEMP, "$main::templates/$file")
- or $form->error("$main::templates/$file : $ERRNO");
+ open(TEMP, $::lx_office_conf{paths}->{templates} . "/$file")
+ or $form->error($::lx_office_conf{paths}->{templates} . "/$file : $ERRNO");
$file =~ s/\Q$form->{mastertemplates}\E-//;
open(NEW, ">$form->{templates}/$file")
my $form = $main::form;
my $locale = $main::locale;
- unlink "$main::userspath/nologin";
+ unlink _nologin_file_name();;
$form->{callback} = "admin.pl?action=list_users";
my $form = $main::form;
my $locale = $main::locale;
- open(FH, ">$main::userspath/nologin")
+ open(FH, ">" . _nologin_file_name())
or $form->error($locale->text('Cannot create Lock!'));
close(FH);
::end_of_request() if SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(1);
}
+sub _nologin_file_name {
+ return $::lx_office_conf{paths}->{userspath} . '/nologin';
+}
+
1;
$main::auth->assert('general_ledger');
- if (AP->delete_transaction(\%myconfig, \%$form, $main::spool)) {
+ if (AP->delete_transaction(\%myconfig, \%$form)) {
# saving the history
if(!exists $form->{addition}) {
$form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{callback} .= "&header=1" if $form->{callback};
$form->redirect($locale->text('Removed spoolfiles!'))
- if (BP->delete_spool(\%myconfig, \%$form, $main::spool));
+ if (BP->delete_spool(\%myconfig, \%$form));
$form->error($locale->text('Cannot remove files!'));
$main::lxdebug->leave_sub();
if ($form->{"checked_$i"}) {
$form->info($locale->text('Printing ... '));
- if (BP->print_spool(\%myconfig, \%$form, $main::spool, "| $selected_printer")) {
+ if (BP->print_spool(\%myconfig, \%$form, "| $selected_printer")) {
print $locale->text('done');
$form->redirect($locale->text('Marked entries printed!'));
}
my $i = 0;
my $j = 0;
my $spoolfile;
+ my $spool = $::lx_office_conf{paths}->{spool};
foreach my $ref (@{ $form->{SPOOL} }) {
"<td><a href=$module?action=edit&id=$ref->{id}&type=$form->{type}&callback=$callback>$ref->{quonumber}</a></td>";
$column_data{name} = "<td>$ref->{name}</td>";
$column_data{spoolfile} =
- qq|<td><a href=$main::spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
+ qq|<td><a href=$spool/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
<input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
|;
foreach my $level (values %{ $levels }) {
next unless scalar @{ $level };
- DN->save_dunning(\%myconfig, $form, $level, $main::userspath, $main::spool);
+ DN->save_dunning(\%myconfig, $form, $level);
}
}
"customer_id" => $form->{"customer_id_$i"},
"next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
"email" => $form->{"email_$i"}, } ];
- DN->save_dunning(\%myconfig, $form, $level, $main::userspath, $main::spool);
+ DN->save_dunning(\%myconfig, $form, $level);
}
}
my $filename;
if ($filename = $queued{ $form->{formname} }) {
$form->{queued} =~ s/\Q$form->{formname} $filename\E//;
- unlink "$main::spool/$filename";
+ unlink $::lx_office_conf{paths}->{spool} . "/$filename";
$filename =~ s/\..*$//g;
} else {
$filename = time;
}
$filename .= ($form->{postscript}) ? '.ps' : '.pdf';
- $form->{OUT} = ">$main::spool/$filename";
+ $form->{OUT} = ">" . $::lx_office_conf{paths}->{spool} . "/$filename";
# add type
$form->{queued} .= " $form->{formname} $filename";
}
# /saving the history
- $form->parse_template(\%myconfig, $main::userspath);
+ $form->parse_template(\%myconfig);
$form->{callback} = "";
$main::auth->assert('invoice_edit');
- if (IS->delete_invoice(\%myconfig, \%$form, $main::spool)) {
+ if (IS->delete_invoice(\%myconfig, \%$form)) {
# saving the history
if(!exists $form->{addition}) {
$form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$msg = $locale->text('Quotation deleted!');
$err = $locale->text('Cannot delete quotation!');
}
- if (OE->delete(\%myconfig, \%$form, $main::spool)){
+ if (OE->delete(\%myconfig, \%$form)){
# saving the history
if(!exists $form->{addition}) {
$form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->{attachment_filename} = $locale->quote_special_chars('filenames', $locale->text("Statement") . "_$form->{todate}.$attachment_suffix");
$form->{attachment_filename} =~ s/\s+/_/g;
- $form->parse_template(\%myconfig, $main::userspath);
+ $form->parse_template(\%myconfig);
}
}
$userspath, $vertreter, $webdav, $xvfb_bin
);
-# path to user configuration files
-$userspath = "users";
-
-# spool directory for batch printing
-$spool = "spool";
-
-# templates base directory
-$templates = "templates";
-
-# member file
-$memberfile = "users/members";
-
# Wenn Einnahmen-Überschussrechnung, dann auf 1 setzen
# Wenn Bilanzierung (z.B. GmbH), dann auf 0 setzen
$eur = 1;
$userspath, $vertreter, $webdav, $xvfb_bin
);
-# path to user configuration files
-$userspath = "users";
-
-# spool directory for batch printing
-$spool = "spool";
-
-# templates base directory
-$templates = "templates";
-
-# member file
-$memberfile = "users/members";
-
# Wenn Einnahmen-Überschussrechnung, dann auf 1 setzen
# Wenn Bilanzierung (z.B. GmbH), dann auf 0 setzen
$eur = 1;
+[paths]
+# path to temporary files (must be writeable by the web server)
+userspath = users
+# spool directory for batch printing
+spool = spool
+# templates base directory
+templates = templates
+# Path to the old memberfile (ignored on new installations)
+memberfile = users/members
+
[task_server]
# User name to use for database access
login = mb
package main;
{ no warnings 'once';
- $::userspath = "users";
- $::templates = "templates";
$::sendmail = "| /usr/sbin/sendmail -t";
}
my $login = shift @ARGV;
- $::userspath = "users";
- $::templates = "templates";
$::sendmail = "| /usr/sbin/sendmail -t";
$::lxdebug = LXDebug->new();
push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
}
+
use DBI;
use Data::Dumper;
use SL::Form;
use SL::Template;
-$userspath = "users";
-$templates = "templates";
-$memberfile = "users/members";
$sendmail = "| /usr/sbin/sendmail -t";
$| = 1;
package main;
{ no warnings 'once';
- $::userspath = "users";
- $::templates = "templates";
$::sendmail = "| /usr/sbin/sendmail -t";
}