Revision 8c7e4493
Von Moritz Bunkus vor fast 17 Jahren hinzugefügt
SL/MoreCommon.pm | ||
---|---|---|
3 | 3 |
require Exporter; |
4 | 4 |
@ISA = qw(Exporter); |
5 | 5 |
|
6 |
@EXPORT = qw(save_form restore_form); |
|
6 |
@EXPORT = qw(save_form restore_form compare_numbers);
|
|
7 | 7 |
|
8 | 8 |
use YAML; |
9 | 9 |
|
10 |
use SL::AM; |
|
11 |
|
|
10 | 12 |
sub save_form { |
11 | 13 |
$main::lxdebug->enter_sub(); |
12 | 14 |
|
15 |
my @dont_dump_keys = @_; |
|
16 |
my %not_dumped_values; |
|
17 |
|
|
18 |
foreach my $key (@dont_dump_keys) { |
|
19 |
$not_dumped_values{$key} = $main::form->{$key}; |
|
20 |
delete $main::form->{$key}; |
|
21 |
} |
|
22 |
|
|
13 | 23 |
my $old_form = YAML::Dump($main::form); |
14 | 24 |
$old_form =~ s|!|!:|g; |
15 | 25 |
$old_form =~ s|\n|!n|g; |
16 | 26 |
$old_form =~ s|\r|!r|g; |
17 | 27 |
|
28 |
map { $main::form->{$_} = $not_dumped_values{$_} } keys %not_dumped_values; |
|
29 |
|
|
18 | 30 |
$main::lxdebug->leave_sub(); |
19 | 31 |
|
20 | 32 |
return $old_form; |
... | ... | |
23 | 35 |
sub restore_form { |
24 | 36 |
$main::lxdebug->enter_sub(); |
25 | 37 |
|
26 |
my ($old_form, $no_delete) = @_; |
|
38 |
my ($old_form, $no_delete, @keep_vars) = @_;
|
|
27 | 39 |
|
28 |
my $form = $main::form; |
|
40 |
my $form = $main::form; |
|
41 |
my %keep_vars_map = map { $_ => 1 } @keep_vars; |
|
29 | 42 |
|
30 |
map { delete $form->{$_}; } keys %{$form} unless ($no_delete); |
|
43 |
map { delete $form->{$_} if (!$keep_vars_map{$_}); } keys %{$form} unless ($no_delete);
|
|
31 | 44 |
|
32 | 45 |
$old_form =~ s|!r|\r|g; |
33 | 46 |
$old_form =~ s|!n|\n|g; |
34 | 47 |
$old_form =~ s|![!:]|!|g; |
35 | 48 |
|
36 | 49 |
my $new_form = YAML::Load($old_form); |
37 |
map { $form->{$_} = $new_form->{$_}; } keys %{$new_form};
|
|
50 |
map { $form->{$_} = $new_form->{$_} if (!$keep_vars_map{$_}) } keys %{ $new_form };
|
|
38 | 51 |
|
39 | 52 |
$main::lxdebug->leave_sub(); |
40 | 53 |
} |
41 | 54 |
|
55 |
sub compare_numbers { |
|
56 |
$main::lxdebug->enter_sub(); |
|
57 |
|
|
58 |
my $a = shift; |
|
59 |
my $a_unit = shift; |
|
60 |
my $b = shift; |
|
61 |
my $b_unit = shift; |
|
62 |
|
|
63 |
$main::all_units ||= AM->retrieve_units(\%main::myconfig, $main::form); |
|
64 |
my $units = $main::all_units; |
|
65 |
|
|
66 |
if (!$units->{$a_unit} || !$units->{$b_unit} || ($units->{$a_unit}->{base_unit} ne $units->{$b_unit}->{base_unit})) { |
|
67 |
$main::lxdebug->leave_sub(); |
|
68 |
return undef; |
|
69 |
} |
|
70 |
|
|
71 |
$a *= $units->{$a_unit}->{factor}; |
|
72 |
$b *= $units->{$b_unit}->{factor}; |
|
73 |
|
|
74 |
$main::lxdebug->leave_sub(); |
|
75 |
|
|
76 |
return $a <=> $b; |
|
77 |
} |
|
78 |
|
|
79 |
|
|
42 | 80 |
1; |
Auch abrufbar als: Unified diff
Umstellung der Benutzerverwaltung von Dateien im Verzeichnis "users" auf die Verwendung einer Authentifizierungsdatenbank.
Es ist erforderlich, die Dateien doc/UPGRADE und doc/INSTALL/index.html zu lesen und die angesprochenen Punkte auszuführen, um nach einem Upgrade weiter arbeiten zu können.