From: Moritz Bunkus Date: Wed, 16 May 2007 13:23:39 +0000 (+0000) Subject: Das Löschen von Benutzern etwas anders implementiert. X-Git-Tag: release-2.4.3^2~300 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6c33f0a4ad5f95ce3ea39ed371816ac8efa56f53;p=kivitendo-erp.git Das Löschen von Benutzern etwas anders implementiert. --- diff --git a/bin/mozilla/admin.pl b/bin/mozilla/admin.pl index ef985f40c..4c5e9dc80 100644 --- a/bin/mozilla/admin.pl +++ b/bin/mozilla/admin.pl @@ -40,6 +40,7 @@ use CGI; use SL::Form; use SL::User; use SL::Common; +use SL::Inifile; require "bin/mozilla/common.pl"; @@ -477,81 +478,28 @@ sub save { } sub delete { - - $form->{templates} = - ($form->{templates}) - ? "$templates/$form->{templates}" - : "$templates/$form->{login}"; - $form->error($locale->text('File locked!')) if (-f ${memberfile} . LCK); open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!"); close(FH); - open(CONF, "+<$memberfile") or $form->error("$memberfile : $!"); - - @config = ; - - seek(CONF, 0, 0); - truncate(CONF, 0); - - while ($line = shift @config) { - - if ($line =~ /^\[/) { - last if ($line =~ /\[$form->{login}\]/); - $login = login_name($line); - } - - if ($line =~ /^templates=/) { - $user{$login} = get_value($line); - } - - print CONF $line; - } - - # remove everything up to next login or EOF - # and save template variable - while ($line = shift @config) { - if ($line =~ /^templates=/) { - $templatedir = get_value($line); - } - last if ($line =~ /^\[/); - } - - # this one is either the next login or EOF - print CONF $line; - - $login = login_name($line); - - while ($line = shift @config) { - if ($line =~ /^\[/) { - $login = login_name($line); - } - - if ($line =~ /^templates=/) { - $user{$login} = get_value($line); - } - - print CONF $line; - } - - close(CONF); + my $members = Inifile->new($memberfile); + my $templates = $members->{$form->{login}}->{templates}; + delete $members->{$form->{login}}; + $members->write(); unlink "${memberfile}.LCK"; - # scan %user for $templatedir - foreach $login (keys %user) { - last if ($found = ($templatedir eq $user{$login})); - } - - # if found keep directory otherwise delete - if (!$found) { + if ($templates) { + my $templates_in_use = 0; + foreach $login (keys %{ $members }) { + next if $login =~ m/^[A-Z]+$/; + next if $members->{$login}->{templates} ne $templates; + $templates_in_use = 1; + last; + } - # delete it if there is a template directory - $dir = "$form->{templates}"; - if (-d "$dir") { - unlink <$dir/*.html>; - unlink <$dir/*.tex>; - unlink <$dir/*.sty>; - rmdir "$dir"; + if (!$templates_in_use && -d $templates) { + unlink <$templates/*>; + rmdir $templates; } }