X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fadmin.pl;h=6d518fcbdef8f871a8388afa0c30b19dd7d46e46;hb=772ec8725a6da1fd25a9e256d16e44b4c5231904;hp=c776961ab8aaadd1429115e26cf4b5b9768bfdd3;hpb=32c9d480547428dc9555539c8f354ab73d616a6e;p=kivitendo-erp.git diff --git a/bin/mozilla/admin.pl b/bin/mozilla/admin.pl index c776961ab..6d518fcbd 100755 --- a/bin/mozilla/admin.pl +++ b/bin/mozilla/admin.pl @@ -37,6 +37,9 @@ use Encode; use English qw(-no_match_vars); use Fcntl; use File::Copy; +use File::Find; +use File::Spec; +use Cwd; use IO::File; use POSIX qw(strftime); use Sys::Hostname; @@ -58,6 +61,13 @@ require "bin/mozilla/admin_printer.pl"; use strict; +# parserhappy(R): + +# $locale->text('periodic') +# $locale->text('income') +# $locale->text('perpetual') +# $locale->text('balance') + our $cgi; our $form; our $locale; @@ -428,16 +438,16 @@ sub edit_user_form { closedir TEMPLATEDIR; @alldir = grep !/\.(html|tex|sty|odt|xml|txb)$/, @alldir; - @alldir = grep !/^(webpages|mastertemplates|\.svn)$/, @alldir; + @alldir = grep !/^(webpages|print|\.svn)$/, @alldir; $form->{ALL_TEMPLATES} = [ map { { "name", => $_, "selected" => $_ eq $myconfig->{templates} } } @alldir ]; # mastertemplates - opendir TEMPLATEDIR, "$::lx_office_conf{paths}->{templates}/mastertemplates" or $form->error("$::lx_office_conf{paths}->{templates}/mastertemplates" . " : $ERRNO"); + opendir TEMPLATEDIR, "$::lx_office_conf{paths}->{templates}/print" or $form->error("$::lx_office_conf{paths}->{templates}/print" . " : $ERRNO"); my @allmaster = readdir(TEMPLATEDIR); closedir TEMPLATEDIR; - @allmaster = sort grep { -d ("$::lx_office_conf{paths}->{templates}/mastertemplates" . "/$_") && !/^\.\.?$/ } @allmaster; + @allmaster = sort grep { -d ("$::lx_office_conf{paths}->{templates}/print" . "/$_") && !/^\.\.?$/ } @allmaster; @allmaster = reverse grep !/Default/, @allmaster; push @allmaster, 'Default'; @allmaster = reverse @allmaster; @@ -539,26 +549,40 @@ sub save_user { umask(007); # copy templates to the directory - my $templatedir = "$::lx_office_conf{paths}->{templates}/mastertemplates/$form->{mastertemplates}"; - - opendir TEMPLATEDIR, $templatedir or $form->error($templatedir . " : $ERRNO"); - my @templates = grep /.*?\.(html|tex|sty|odt|xml|txb)$/, - readdir TEMPLATEDIR; - closedir TEMPLATEDIR; - foreach my $file (@templates) { - open(TEMP, "<", $templatedir . "/$file") - or $form->error($templatedir . "/$file : $ERRNO"); + my $oldcurrdir = getcwd(); + if (!chdir("$::lx_office_conf{paths}->{templates}/print/$form->{mastertemplates}")) { + $form->error("$ERRNO: chdir $::lx_office_conf{paths}->{templates}/print/$form->{mastertemplates}"); + } - open(NEW, ">", "$form->{templates}/$file") - or $form->error("$form->{templates}/$file : $ERRNO"); + my $newdir = File::Spec->catdir($oldcurrdir, $form->{templates}); + + find( + sub + { + next if ($_ eq "."); + + if (-d $_) { + if (!mkdir (File::Spec->catdir($newdir, $File::Find::name))) { + chdir($oldcurrdir); + $form->error("$ERRNO: mkdir $File::Find::name"); + } + } elsif (-l $_) { + if (!symlink (readlink($_), + File::Spec->catfile($newdir, $File::Find::name))) { + chdir($oldcurrdir); + $form->error("$ERRNO: symlink $File::Find::name"); + } + } elsif (-f $_) { + if (!copy($_, File::Spec->catfile($newdir, $File::Find::name))) { + chdir($oldcurrdir); + $form->error("$ERRNO: cp $File::Find::name"); + } + } + }, "./"); + + chdir($oldcurrdir); - while (my $line = ) { - print NEW $line; - } - close(TEMP); - close(NEW); - } } else { $form->error("$ERRNO: $form->{templates}"); }