Revision ad2e3220
Von Sven Schöling vor mehr als 14 Jahren hinzugefügt
SL/CVar.pm | ||
---|---|---|
669 | 669 |
return !$invalid; |
670 | 670 |
} |
671 | 671 |
|
672 |
sub custom_variables_validity_by_trans_id { |
|
673 |
$main::lxdebug->enter_sub(2); |
|
674 |
|
|
675 |
my $self = shift; |
|
676 |
my %params = @_; |
|
677 |
|
|
678 |
return sub { 0 } unless $params{trans_id}; |
|
679 |
|
|
680 |
my $myconfig = \%main::myconfig; |
|
681 |
my $form = $main::form; |
|
682 |
|
|
683 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
684 |
|
|
685 |
my $query = qq|SELECT config_id, COUNT(*) FROM custom_variables_validity WHERE trans_id = ? GROUP BY config_id|; |
|
686 |
|
|
687 |
my %invalids = selectall_as_map($form, $dbh, $query, 'config_id', 'count', $params{trans_id}); |
|
688 |
|
|
689 |
$main::lxdebug->leave_sub(2); |
|
690 |
|
|
691 |
return sub { !$invalids{+shift} }; |
|
692 |
} |
|
693 |
|
|
672 | 694 |
1; |
673 | 695 |
|
674 | 696 |
__END__ |
bin/mozilla/io.pl | ||
---|---|---|
2077 | 2077 |
my $form = $main::form; |
2078 | 2078 |
|
2079 | 2079 |
$form->{CVAR_CONFIGS} ||= { }; |
2080 |
$form->{CVAR_CONFIGS}->{IC} = CVar->get_configs(module => 'IC');
|
|
2080 |
$form->{CVAR_CONFIGS}->{IC} ||= CVar->get_configs(module => 'IC');
|
|
2081 | 2081 |
|
2082 | 2082 |
$main::lxdebug->leave_sub(); |
2083 | 2083 |
} |
... | ... | |
2094 | 2094 |
return; |
2095 | 2095 |
} |
2096 | 2096 |
|
2097 |
my $valid = CVar->custom_variables_validity_by_trans_id(trans_id => $params{part_id}); |
|
2098 |
|
|
2097 | 2099 |
my $num_visible_cvars = 0; |
2098 | 2100 |
foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) { |
2099 |
$cvar->{valid} = $params{part_id} && |
|
2100 |
CVar->get_custom_variables_validity(config_id => $cvar->{id}, trans_id => $params{part_id}); |
|
2101 |
$cvar->{valid} = $params{part_id} && $valid->($cvar->{id}); |
|
2101 | 2102 |
|
2102 | 2103 |
my $description = ''; |
2103 | 2104 |
if ($cvar->{flag_editable} && $cvar->{valid}) { |
Auch abrufbar als: Unified diff
CVar validity ausgelagert in eine Massenfunktion.
Reduziert die Anzahl der Datenbankzugriffe bei großen Belegen massiv.