Revision 6c33f0a4
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
bin/mozilla/admin.pl | ||
---|---|---|
40 | 40 |
use SL::Form; |
41 | 41 |
use SL::User; |
42 | 42 |
use SL::Common; |
43 |
use SL::Inifile; |
|
43 | 44 |
|
44 | 45 |
require "bin/mozilla/common.pl"; |
45 | 46 |
|
... | ... | |
477 | 478 |
} |
478 | 479 |
|
479 | 480 |
sub delete { |
480 |
|
|
481 |
$form->{templates} = |
|
482 |
($form->{templates}) |
|
483 |
? "$templates/$form->{templates}" |
|
484 |
: "$templates/$form->{login}"; |
|
485 |
|
|
486 | 481 |
$form->error($locale->text('File locked!')) if (-f ${memberfile} . LCK); |
487 | 482 |
open(FH, ">${memberfile}.LCK") or $form->error("${memberfile}.LCK : $!"); |
488 | 483 |
close(FH); |
489 | 484 |
|
490 |
open(CONF, "+<$memberfile") or $form->error("$memberfile : $!"); |
|
491 |
|
|
492 |
@config = <CONF>; |
|
493 |
|
|
494 |
seek(CONF, 0, 0); |
|
495 |
truncate(CONF, 0); |
|
496 |
|
|
497 |
while ($line = shift @config) { |
|
498 |
|
|
499 |
if ($line =~ /^\[/) { |
|
500 |
last if ($line =~ /\[$form->{login}\]/); |
|
501 |
$login = login_name($line); |
|
502 |
} |
|
503 |
|
|
504 |
if ($line =~ /^templates=/) { |
|
505 |
$user{$login} = get_value($line); |
|
506 |
} |
|
507 |
|
|
508 |
print CONF $line; |
|
509 |
} |
|
510 |
|
|
511 |
# remove everything up to next login or EOF |
|
512 |
# and save template variable |
|
513 |
while ($line = shift @config) { |
|
514 |
if ($line =~ /^templates=/) { |
|
515 |
$templatedir = get_value($line); |
|
516 |
} |
|
517 |
last if ($line =~ /^\[/); |
|
518 |
} |
|
519 |
|
|
520 |
# this one is either the next login or EOF |
|
521 |
print CONF $line; |
|
522 |
|
|
523 |
$login = login_name($line); |
|
524 |
|
|
525 |
while ($line = shift @config) { |
|
526 |
if ($line =~ /^\[/) { |
|
527 |
$login = login_name($line); |
|
528 |
} |
|
529 |
|
|
530 |
if ($line =~ /^templates=/) { |
|
531 |
$user{$login} = get_value($line); |
|
532 |
} |
|
533 |
|
|
534 |
print CONF $line; |
|
535 |
} |
|
536 |
|
|
537 |
close(CONF); |
|
485 |
my $members = Inifile->new($memberfile); |
|
486 |
my $templates = $members->{$form->{login}}->{templates}; |
|
487 |
delete $members->{$form->{login}}; |
|
488 |
$members->write(); |
|
538 | 489 |
unlink "${memberfile}.LCK"; |
539 | 490 |
|
540 |
# scan %user for $templatedir |
|
541 |
foreach $login (keys %user) { |
|
542 |
last if ($found = ($templatedir eq $user{$login})); |
|
543 |
} |
|
544 |
|
|
545 |
# if found keep directory otherwise delete |
|
546 |
if (!$found) { |
|
491 |
if ($templates) { |
|
492 |
my $templates_in_use = 0; |
|
493 |
foreach $login (keys %{ $members }) { |
|
494 |
next if $login =~ m/^[A-Z]+$/; |
|
495 |
next if $members->{$login}->{templates} ne $templates; |
|
496 |
$templates_in_use = 1; |
|
497 |
last; |
|
498 |
} |
|
547 | 499 |
|
548 |
# delete it if there is a template directory |
|
549 |
$dir = "$form->{templates}"; |
|
550 |
if (-d "$dir") { |
|
551 |
unlink <$dir/*.html>; |
|
552 |
unlink <$dir/*.tex>; |
|
553 |
unlink <$dir/*.sty>; |
|
554 |
rmdir "$dir"; |
|
500 |
if (!$templates_in_use && -d $templates) { |
|
501 |
unlink <$templates/*>; |
|
502 |
rmdir $templates; |
|
555 | 503 |
} |
556 | 504 |
} |
557 | 505 |
|
Auch abrufbar als: Unified diff
Das Löschen von Benutzern etwas anders implementiert.